Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion intermine/pathfeatures.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def append(self, *sos):
"Sort orders must be either SortOrder instances,"
+ " or tuples of arguments: I got:" + so + sos)
def __repr__(self):
return '<' + self.class__.__name__ + ': [' + str(self) + ']>'
return '<' + self.__class__.__name__ + ': [' + str(self) + ']>'
def __str__(self):
return " ".join(map(str, self.sort_orders))
def clear(self):
Expand Down
43 changes: 42 additions & 1 deletion intermine/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ def from_xml(cls, xml, *args, **kwargs):
+ "Only one <query> element is allowed. Found %d" % len(queries))
q = queries[0]
obj.name = q.getAttribute('name')
obj.description = q.getAttribute('description')
obj.description = q.getAttribute('longDescription')
obj.add_view(q.getAttribute('view'))
for p in q.getElementsByTagName('pathDescription'):
path = p.getAttribute('pathString')
Expand Down Expand Up @@ -1703,6 +1703,47 @@ def __init__(self, *args, **kwargs):
"""
super(Template, self).__init__(*args, **kwargs)
self.constraint_factory = constraints.TemplateConstraintFactory()
self.title = ''

@classmethod
def from_xml(cls, xml, *args, **kwargs):
"""
Deserialise a template query serialised to XML
==============================================

This method is used to instantiate serialised templates.
It is used by intermine.webservice.Service objects
to instantiate Template objects and it can be used
to read in templates you have saved to a file.

@param xml: The xml as a file name, url, or string

@raise QueryParseError: if the query cannot be parsed

@rtype: L{Template}
"""
# Extract all Query (superclass) fields
obj = super(Template, cls).from_xml(xml, *args, **kwargs)

# Extract fields specific to Template, like title
obj.do_verification = False
f = openAnything(xml)
doc = minidom.parse(f)
f.close()

templates = doc.getElementsByTagName('template')
if len(templates) != 1:
raise QueryParseError(
"wrong number of templates in xml. "
+ "Only one <template> element is allowed. "
+ "Found %d" % len(templates))
t = templates[0]
obj.title = t.getAttribute('title')

obj.verify()

return obj

@property
def editable_constraints(self):
"""
Expand Down