summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: dff2f00)
raw | patch | inline | side by side (parent: dff2f00)
author | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Tue, 10 Sep 2002 03:57:50 +0000 (03:57 +0000) | ||
committer | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Tue, 10 Sep 2002 03:57:50 +0000 (03:57 +0000) |
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@1118 57a73879-2fb5-44c3-a270-3262357dd7e2
roundup/cgi/templating.py | patch | blob | history | |
roundup/templates/classic/html/query.item | patch | blob | history |
index 904ee97d13af43b92e4804e702f85d7eacad43ae..f133edbe32d7781e71fb4ae6cae8c4d9c39f0f2c 100644 (file)
# new template, using the specified classname and request
pt = getTemplate(self._db.config.TEMPLATES, self.classname, name)
- # XXX handle PT rendering errors here nicely
- try:
- # use our fabricated request
- return pt.render(self._client, self.classname, req)
- except PageTemplate.PTRuntimeError, message:
- return '<strong>%s</strong><ol>%s</ol>'%(message,
- cgi.escape('<li>'.join(pt._v_errors)))
+ # use our fabricated request
+ return pt.render(self._client, self.classname, req)
class HTMLItem:
''' Accesses through an *item*
l.append('</table>')
return '\n'.join(l)
+ def renderQueryForm(self):
+ ''' Render this item, which is a query, as a search form.
+ '''
+ # create a new request and override the specified args
+ req = HTMLRequest(self._client)
+ req.classname = self._klass.get(self._nodeid, 'klass')
+ req.updateFromURL(self._klass.get(self._nodeid, 'url'))
+
+ # new template, using the specified classname and request
+ pt = getTemplate(self._db.config.TEMPLATES, req.classname, 'search')
+
+ # use our fabricated request
+ return pt.render(self._client, req.classname, req)
+
class HTMLUser(HTMLItem):
''' Accesses through the *user* (a special case of item)
'''
self.classname = client.classname
self.template = client.template
+ self._post_init()
+
+ def _post_init(self):
+ ''' Set attributes based on self.form
+ '''
# extract the index display information from the form
self.columns = []
if self.form.has_key(':columns'):
else:
self.startwith = 0
+ def updateFromURL(self, url):
+ ''' Parse the URL for query args, and update my attributes using the
+ values.
+ '''
+ self.form = {}
+ for name, value in cgi.parse_qsl(url):
+ if self.form.has_key(name):
+ if isinstance(self.form[name], type([])):
+ self.form[name].append(cgi.MiniFieldStorage(name, value))
+ else:
+ self.form[name] = [self.form[name],
+ cgi.MiniFieldStorage(name, value)]
+ else:
+ self.form[name] = cgi.MiniFieldStorage(name, value)
+ self._post_init()
+
def update(self, kwargs):
+ ''' Update my attributes using the keyword args
+ '''
self.__dict__.update(kwargs)
if kwargs.has_key('columns'):
self.show = ShowDict(self.columns)
index 681d75b6b50cb0d7cd1bdf91535a3654d451ee5c..2b5a64842b70cbee9a514f25d1a4817ca6d4ae9e 100755 (executable)
-<table class="form">
-<tr>
- <th>Class</th>
- <td tal:content="structure context/klass/field"></td>
-</tr>
-
-<tr>
- <th>Name</th>
- <td tal:content="structure context/name/field"></td>
-</tr>
-
-<tr>
- <td colspan=2>
- hrm. filterspec here...
- <display call="filterspec('klass','url')">
- </td>
-</tr>
-
-<tr>
- <td> </td>
- <td tal:content="structure context/submit">submit button here</td>
-</tr>
-</table>
+<span tal:content="structure context/renderQueryForm" />