1 """extend the generic VRegistry with some cubicweb specific stuff |
1 """extend the generic VRegistry with some cubicweb specific stuff |
2 |
2 |
3 :organization: Logilab |
3 :organization: Logilab |
4 :copyright: 2001-2008 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
4 :copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
5 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
5 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
6 """ |
6 """ |
7 __docformat__ = "restructuredtext en" |
7 __docformat__ = "restructuredtext en" |
8 |
8 |
9 from warnings import warn |
9 from warnings import warn |
10 |
10 |
11 from logilab.common.decorators import cached, clear_cache |
11 from logilab.common.decorators import cached, clear_cache |
12 |
12 |
13 from rql import RQLHelper |
13 from rql import RQLHelper |
14 |
14 |
15 from cubicweb import Binary, UnknownProperty |
15 from cubicweb import Binary, UnknownProperty, UnknownEid |
16 from cubicweb.vregistry import VRegistry, ObjectNotFound, NoSelectableObject |
16 from cubicweb.vregistry import VRegistry, ObjectNotFound, NoSelectableObject |
17 |
17 |
18 _ = unicode |
18 _ = unicode |
19 |
19 |
20 class DummyCursorError(Exception): pass |
20 class DummyCursorError(Exception): pass |
335 |
335 |
336 def parse(self, session, rql, args=None): |
336 def parse(self, session, rql, args=None): |
337 rqlst = self.rqlhelper.parse(rql) |
337 rqlst = self.rqlhelper.parse(rql) |
338 def type_from_eid(eid, session=session): |
338 def type_from_eid(eid, session=session): |
339 return session.describe(eid)[0] |
339 return session.describe(eid)[0] |
340 self.rqlhelper.compute_solutions(rqlst, {'eid': type_from_eid}, args) |
340 try: |
|
341 self.rqlhelper.compute_solutions(rqlst, {'eid': type_from_eid}, args) |
|
342 except UnknownEid: |
|
343 for select in rqlst.children: |
|
344 select.solutions = [] |
341 return rqlst |
345 return rqlst |
342 |
346 |
343 @property |
347 @property |
344 @cached |
348 @cached |
345 def rqlhelper(self): |
349 def rqlhelper(self): |