summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: be99dcf)
raw | patch | inline | side by side (parent: be99dcf)
author | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Sun, 14 Dec 2003 21:40:57 +0000 (21:40 +0000) | ||
committer | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Sun, 14 Dec 2003 21:40:57 +0000 (21:40 +0000) |
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@2023 57a73879-2fb5-44c3-a270-3262357dd7e2
roundup/cgi/templating.py | patch | blob | history |
index 6fa573e9d26483c066c576942a7a6f0788913b8b..cbc742bb44d488411204cf57959ce8a12271508d 100644 (file)
from roundup.cgi.TAL.TALInterpreter import TALInterpreter
from roundup.cgi import ZTUtils
-def input_html4(**attrs):
- """Generate an 'input' (html4) element with given attributes"""
- return '<input %s>'%' '.join(['%s="%s"'%item for item in attrs.items()])
-
-def input_xhtml(**attrs):
- """Generate an 'input' (xhtml) element with given attributes"""
- return '<input %s/>'%' '.join(['%s="%s"'%item for item in attrs.items()])
-
class NoTemplate(Exception):
pass
'''
return self.is_view_ok() and not self.is_edit_ok()
-class HTMLClass(HTMLPermissions):
+def input_html4(**attrs):
+ """Generate an 'input' (html4) element with given attributes"""
+ return '<input %s>'%' '.join(['%s="%s"'%item for item in attrs.items()])
+
+def input_xhtml(**attrs):
+ """Generate an 'input' (xhtml) element with given attributes"""
+ return '<input %s/>'%' '.join(['%s="%s"'%item for item in attrs.items()])
+
+class HTMLInputMixin:
+ ''' requires a _client property '''
+ def __init__(self):
+ html_version = 'html4'
+ if hasattr(self._client.instance.config, 'HTML_VERSION'):
+ html_version = self._client.instance.config.HTML_VERSION
+ if html_version == 'xhtml':
+ self.input = input_xhtml
+ else:
+ self.input = input_html4
+
+class HTMLClass(HTMLInputMixin, HTMLPermissions):
''' Accesses through a class (either through *class* or *db.<classname>*)
'''
def __init__(self, client, classname, anonymous=0):
self._klass = self._db.getclass(self.classname)
self._props = self._klass.getprops()
- html_version = 'html4'
- if hasattr(self._client.instance.config, 'HTML_VERSION'):
- html_version = self._client.instance.config.HTML_VERSION
- if html_version == 'xhtml':
- self.input = input_xhtml
- else:
- self.input = input_html4
+ HTMLInputMixin.__init__(self)
def __repr__(self):
return '<HTMLClass(0x%x) %s>'%(id(self), self.classname)
# use our fabricated request
return pt.render(self._client, self.classname, req)
-class HTMLItem(HTMLPermissions):
+class HTMLItem(HTMLInputMixin, HTMLPermissions):
''' Accesses through an *item*
'''
def __init__(self, client, classname, nodeid, anonymous=0):
# do we prefix the form items with the item's identification?
self._anonymous = anonymous
+ HTMLInputMixin.__init__(self)
+
def __repr__(self):
return '<HTMLItem(0x%x) %s %s>'%(id(self), self._classname,
self._nodeid)
self._classname) or (self._nodeid == self._client.userid and
self._db.user.get(self._client.userid, 'username') != 'anonymous')
-class HTMLProperty:
+class HTMLProperty(HTMLInputMixin):
''' String, Number, Date, Interval HTMLProperty
Has useful attributes:
else:
self._formname = name
- html_version = 'html4'
- if hasattr(self._client.instance.config, 'HTML_VERSION'):
- html_version = self._client.instance.config.HTML_VERSION
- if html_version == 'xhtml':
- self.input = input_xhtml
- else:
- self.input = input_html4
+ HTMLInputMixin.__init__(self)
def __repr__(self):
return '<HTMLProperty(0x%x) %s %r %r>'%(id(self), self._formname,
def __getitem__(self, name):
return self.columns.has_key(name)
-class HTMLRequest:
+class HTMLRequest(HTMLInputMixin):
''' The *request*, holding the CGI form and environment.
"form" the CGI form as a cgi.FieldStorage
'''
def __init__(self, client):
- self.client = client
+ # _client is needed by HTMLInputMixin
+ self._client = self.client = client
# easier access vars
self.form = client.form
# the special char to use for special vars
self.special_char = '@'
- html_version = 'html4'
- if hasattr(self.client.instance.config, 'HTML_VERSION'):
- html_version = self.client.instance.config.HTML_VERSION
- if html_version == 'xhtml':
- self.input = input_xhtml
- else:
- self.input = input_html4
+ HTMLInputMixin.__init__(self)
self._post_init()