Commit 0acc9de1 by Александр

changed cryst inputtype to be similar to textline

parent 79a2b2e6
......@@ -630,14 +630,41 @@ def imageinput(element, value, status, render_template, msg=''):
@register_render_function
def crystallography(element, value, status, render_template, msg=''):
eid = element.get('id')
if eid is None:
msg = 'cryst has no id: it probably appears outside of a known response type'
msg += "\nSee problem XML source line %s" % getattr(element, 'sourceline', '<unavailable>')
raise Exception(msg)
height = element.get('height')
width = element.get('width')
display_file = element.get('display_file')
context = {
'id': eid,
'width': width,
'height': height,
'display_file': display_file,
}
count = int(eid.split('_')[-2]) - 1 # HACK
size = element.get('size')
# if specified, then textline is hidden and id is stored in div of name given by hidden
hidden = element.get('hidden', '')
# Escape answers with quotes, so they don't crash the system!
escapedict = {'"': '&quot;'}
value = saxutils.escape(value, escapedict)
context = {'id': eid,
'value': value,
'state': status,
'count': count,
'size': size,
'msg': msg,
'hidden': hidden,
'inline': element.get('inline', ''),
'width': width,
'height': height,
'display_file': display_file,
}
html = render_template("crystallography.html", context)
return etree.XML(html)
\ No newline at end of file
try:
xhtml = etree.XML(html)
except Exception as err:
# TODO: needs to be self.system.DEBUG - but can't access system
if True:
log.debug('[inputtypes.textline] failed to parse XML for:\n%s' % html)
raise
return xhtml
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment