--- a/entity.py Mon Aug 03 09:37:13 2009 +0200
+++ b/entity.py Mon Aug 03 10:50:57 2009 +0200
@@ -265,7 +265,7 @@
continue
if card == '?':
restrictions[-1] += '?' # left outer join if not mandatory
- destcls = cls.vreg.etype_class(desttype)
+ destcls = cls.vreg['etypes'].etype_class(desttype)
destcls._fetch_restrictions(var, varmaker, destcls.fetch_attrs,
selection, orderby, restrictions,
user, ordermethod, visited=visited)
@@ -277,8 +277,9 @@
@classmethod
@cached
def parent_classes(cls):
- parents = [cls.vreg.etype_class(e.type) for e in cls.e_schema.ancestors()]
- parents.append(cls.vreg.etype_class('Any'))
+ parents = [cls.vreg['etypes'].etype_class(e.type)
+ for e in cls.e_schema.ancestors()]
+ parents.append(cls.vreg['etypes'].etype_class('Any'))
return parents
@classmethod
@@ -364,10 +365,10 @@
def has_perm(self, action):
return self.e_schema.has_perm(self.req, action, self.eid)
- def view(self, vid, **kwargs):
+ def view(self, vid, __registry='views', **kwargs):
"""shortcut to apply a view on this entity"""
- return self.vreg.render(vid, self.req, rset=self.rset,
- row=self.row, col=self.col, **kwargs)
+ return self.vreg[__registry].render(vid, self.req, rset=self.rset,
+ row=self.row, col=self.col, **kwargs)
def absolute_url(self, *args, **kwargs):
"""return an absolute url to view this entity"""
@@ -702,13 +703,13 @@
if len(targettypes) > 1:
fetchattrs_list = []
for ttype in targettypes:
- etypecls = self.vreg.etype_class(ttype)
+ etypecls = self.vreg['etypes'].etype_class(ttype)
fetchattrs_list.append(set(etypecls.fetch_attrs))
fetchattrs = reduce(set.intersection, fetchattrs_list)
rql = etypecls.fetch_rql(self.req.user, [restriction], fetchattrs,
settype=False)
else:
- etypecls = self.vreg.etype_class(targettypes[0])
+ etypecls = self.vreg['etypes'].etype_class(targettypes[0])
rql = etypecls.fetch_rql(self.req.user, [restriction], settype=False)
# optimisation: remove ORDERBY if cardinality is 1 or ? (though
# greater_card return 1 for those both cases)
@@ -764,7 +765,7 @@
else:
restriction += [cstr.restriction for cstr in constraints
if isinstance(cstr, RQLConstraint)]
- etypecls = self.vreg.etype_class(targettype)
+ etypecls = self.vreg['etypes'].etype_class(targettype)
rql = etypecls.fetch_rql(self.req.user, restriction,
mainvar=searchedvar, ordermethod=ordermethod)
# ensure we have an order defined