Skip to content

Commit e12c421

Browse files
author
Daniela Butano
committed
added username to Template
1 parent d223a63 commit e12c421

2 files changed

Lines changed: 26 additions & 2 deletions

File tree

intermine/query.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1835,8 +1835,31 @@ def __init__(self, *args, **kwargs):
18351835
super(Template, self).__init__(*args, **kwargs)
18361836
self.constraint_factory = constraints.TemplateConstraintFactory()
18371837
self.title = ''
1838+
self.user_name = ''
18381839
self.view_types = []
18391840

1841+
def clone(self):
1842+
"""
1843+
Performs a deep clone
1844+
=====================
1845+
1846+
This method will produce a clone that is independent,
1847+
and can be altered without affecting the original,
1848+
but starts off with the exact same state as it.
1849+
1850+
The only shared elements should be the model
1851+
and the service, which are shared by all queries
1852+
that refer to the same webservice.
1853+
1854+
@return: same class as caller
1855+
"""
1856+
newobj = super(Template, self).clone()
1857+
setattr(newobj, "user_name", getattr(self, "user_name"))
1858+
return newobj
1859+
1860+
def add_user_name(self, user_name):
1861+
self.user_name = user_name
1862+
18401863
@classmethod
18411864
def from_xml(cls, xml, *args, **kwargs):
18421865
"""
@@ -1914,7 +1937,7 @@ def to_query_params(self):
19141937
19151938
@rtype: dict
19161939
"""
1917-
p = {'name': self.name}
1940+
p = {'name': self.name, 'userName': self.user_name}
19181941
i = 1
19191942
for c in self.editable_constraints:
19201943
if not c.switched_on:
@@ -1964,6 +1987,7 @@ def get_adjusted_template(self, con_values):
19641987
@rtype: L{Template}
19651988
"""
19661989
clone = self.clone()
1990+
19671991
for code, options in list(con_values.items()):
19681992
con = clone.get_constraint(code)
19691993
if not con.editable:
@@ -2031,7 +2055,6 @@ def get_row_list(self, start=0, size=None, **con_values):
20312055
return super(Template, clone).get_row_list(start, size)
20322056

20332057
def rows(self, start=0, size=None, **con_values):
2034-
print("basil2")
20352058
"""Get an iterator over the rows returned by this query"""
20362059
clone = self.get_adjusted_template(con_values)
20372060
return super(Template, clone).rows(start, size)

intermine/webservice.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,7 @@ def get_template_by_user(self, name, username):
525525
+ name + "' at this service belonging to '" + username + "'")
526526
if not isinstance(t, Template):
527527
t = Template.from_xml(t, self.model, self)
528+
t.user_name = username
528529
self.all_templates[name] = t
529530
return t
530531

0 commit comments

Comments
 (0)