Message6094
def cgi_escape_attrs(**attrs):
return ' '.join(['%s="%s"'%(k,cgi.escape(str(v), True))
for k,v in attrs.items()])
Using:
<span tal:condition="python:not InBatchUpdate"
tal:content="structure
python:context.title.field(id='title',
required="true")">title</span>
in an html template generates:
<input name="title" required="true" value="test" type="text"
id="title" size="30">
which is incorrect. If it's in html 4/5 required takes no value, so it
should be required not required="true". For xhtml it should be
required="required".
What should probably happen for all attributes passed through the field
and other functions is:
if the value is a string, generate attribute="string"
if the value is True (i.e. the boolean) generate attribute
for html and attribute="attribute" for xhtml
The functions in cgi/templating.py that need changing are:
def cgi_escape_attrs(**attrs):
return ' '.join(['%s="%s"'%(k,cgi.escape(str(v), True))
for k,v in attrs.items()])
def input_html4(**attrs):
"""Generate an 'input' (html4) element with given attributes"""
_set_input_default_args(attrs)
return '<input %s>'%cgi_escape_attrs(**attrs)
def input_xhtml(**attrs):
"""Generate an 'input' (xhtml) element with given attributes"""
_set_input_default_args(attrs)
return '<input %s/>'%cgi_escape_attrs(**attrs)
probably push the xhtml/html state down into cgi_escape_attrs and
check to see if the value is exactly True.
Do we need to handle False similarly to allow a user to:
tal:content="structure
python:context.title.field(id='title',
attrs, required=False )
to delete required if set in attrs? I suppose not as the user could
delete manually if "required" in attrs... |
|
Date |
User |
Action |
Args |
2018-06-24 23:45:50 | rouilj | set | recipients:
+ rouilj |
2018-06-24 23:45:50 | rouilj | set | messageid: <1529883950.23.0.56676864532.issue2550961@psf.upfronthosting.co.za> |
2018-06-24 23:45:49 | rouilj | link | issue2550961 messages |
2018-06-24 23:45:48 | rouilj | create | |
|