changed cryst inputtype to be similar to textline
This commit is contained in:
@@ -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 = {'"': '"'}
|
||||
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)
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user