--- a/cwvreg.py Wed Sep 16 14:17:12 2009 +0200
+++ b/cwvreg.py Wed Sep 16 14:24:31 2009 +0200
@@ -291,8 +291,7 @@
def set_schema(self, schema):
"""set instance'schema and load application objects"""
- self.schema = schema
- clear_cache(self, 'rqlhelper')
+ self._set_schema(schema)
# now we can load application's web objects
searchpath = self.config.vregistry_path()
self.reset(searchpath, force_reload=False)
@@ -303,6 +302,11 @@
etype = str(etype)
self.case_insensitive_etypes[etype.lower()] = etype
+ def _set_schema(self, schema):
+ """set instance'schema"""
+ self.schema = schema
+ clear_cache(self, 'rqlhelper')
+
def update_schema(self, schema):
"""update .schema attribute on registered objects, necessary for some
tests
@@ -386,16 +390,7 @@
# objects on automatic reloading
self._needs_iface.clear()
- def parse(self, session, rql, args=None):
- rqlst = self.rqlhelper.parse(rql)
- def type_from_eid(eid, session=session):
- return session.describe(eid)[0]
- try:
- self.rqlhelper.compute_solutions(rqlst, {'eid': type_from_eid}, args)
- except UnknownEid:
- for select in rqlst.children:
- select.solutions = []
- return rqlst
+ # rql parsing utilities ####################################################
@property
@cached
@@ -403,38 +398,19 @@
return RQLHelper(self.schema,
special_relations={'eid': 'uid', 'has_text': 'fti'})
-
- @deprecated('use vreg["etypes"].etype_class(etype)')
- def etype_class(self, etype):
- return self["etypes"].etype_class(etype)
-
- @deprecated('use vreg["views"].main_template(*args, **kwargs)')
- def main_template(self, req, oid='main-template', **context):
- return self["views"].main_template(req, oid, **context)
-
- @deprecated('use vreg[registry].possible_vobjects(*args, **kwargs)')
- def possible_vobjects(self, registry, *args, **kwargs):
- return self[registry].possible_vobjects(*args, **kwargs)
+ def solutions(self, req, rqlst, args):
+ def type_from_eid(eid, req=req):
+ return req.describe(eid)[0]
+ self.rqlhelper.compute_solutions(rqlst, {'eid': type_from_eid}, args)
- @deprecated('use vreg["actions"].possible_actions(*args, **kwargs)')
- def possible_actions(self, req, rset=None, **kwargs):
- return self["actions"].possible_actions(req, rest=rset, **kwargs)
-
- @deprecated("use vreg['boxes'].select_object(...)")
- def select_box(self, oid, *args, **kwargs):
- return self['boxes'].select_object(oid, *args, **kwargs)
-
- @deprecated("use vreg['components'].select_object(...)")
- def select_component(self, cid, *args, **kwargs):
- return self['components'].select_object(cid, *args, **kwargs)
-
- @deprecated("use vreg['actions'].select_object(...)")
- def select_action(self, oid, *args, **kwargs):
- return self['actions'].select_object(oid, *args, **kwargs)
-
- @deprecated("use vreg['views'].select(...)")
- def select_view(self, __vid, req, rset=None, **kwargs):
- return self['views'].select(__vid, req, rset=rset, **kwargs)
+ def parse(self, req, rql, args=None):
+ rqlst = self.rqlhelper.parse(rql)
+ try:
+ self.solutions(req, rqlst, args)
+ except UnknownEid:
+ for select in rqlst.children:
+ select.solutions = []
+ return rqlst
# properties handling #####################################################
@@ -507,6 +483,40 @@
self.warning('%s (you should probably delete that property '
'from the database)', ex)
+ # deprecated code ####################################################
+
+ @deprecated('[3.4] use vreg["etypes"].etype_class(etype)')
+ def etype_class(self, etype):
+ return self["etypes"].etype_class(etype)
+
+ @deprecated('[3.4] use vreg["views"].main_template(*args, **kwargs)')
+ def main_template(self, req, oid='main-template', **context):
+ return self["views"].main_template(req, oid, **context)
+
+ @deprecated('[3.4] use vreg[registry].possible_vobjects(*args, **kwargs)')
+ def possible_vobjects(self, registry, *args, **kwargs):
+ return self[registry].possible_vobjects(*args, **kwargs)
+
+ @deprecated('[3.4] use vreg["actions"].possible_actions(*args, **kwargs)')
+ def possible_actions(self, req, rset=None, **kwargs):
+ return self["actions"].possible_actions(req, rest=rset, **kwargs)
+
+ @deprecated('[3.4] use vreg["boxes"].select_object(...)')
+ def select_box(self, oid, *args, **kwargs):
+ return self['boxes'].select_object(oid, *args, **kwargs)
+
+ @deprecated('[3.4] use vreg["components"].select_object(...)')
+ def select_component(self, cid, *args, **kwargs):
+ return self['components'].select_object(cid, *args, **kwargs)
+
+ @deprecated('[3.4] use vreg["actions"].select_object(...)')
+ def select_action(self, oid, *args, **kwargs):
+ return self['actions'].select_object(oid, *args, **kwargs)
+
+ @deprecated('[3.4] use vreg["views"].select(...)')
+ def select_view(self, __vid, req, rset=None, **kwargs):
+ return self['views'].select(__vid, req, rset=rset, **kwargs)
+
from datetime import datetime, date, time, timedelta