[repo] more deprecation
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 14 Aug 2009 15:53:12 +0200
changeset 2855 1d9be3dffa94
parent 2847 c2ee28f4d4b1
child 2867 e8581a4f1bae
[repo] more deprecation
server/hook.py
server/session.py
--- a/server/hook.py	Fri Aug 14 14:31:25 2009 +0200
+++ b/server/hook.py	Fri Aug 14 15:53:12 2009 +0200
@@ -39,6 +39,7 @@
 from logging import getLogger
 
 from logilab.common.decorators import classproperty
+from logilab.common.deprecation import deprecated
 from logilab.common.logging_ext import set_log_methods
 
 from cubicweb.cwvreg import CWRegistry, VRegistry
@@ -131,7 +132,7 @@
     events = None
     category = None
     order = 0
-    # XXX deprecates
+    # XXX deprecated
     enabled = True
 
     @classproperty
@@ -214,12 +215,6 @@
 
     def __init__(self, session, **kwargs):
         self.session = session
-        # XXX deprecates
-        self.user = session.user
-        self.repo = session.repo
-        self.schema = session.repo.schema
-        self.config = session.repo.config
-        # end deprecate
         self.__dict__.update(kwargs)
         self.register(session)
         # execution information
@@ -269,6 +264,26 @@
         operation list
         """
 
+    @property
+    @deprecated('[3.5] use self.session.user')
+    def user(self):
+        return self.session.user
+
+    @property
+    @deprecated('[3.5] use self.session.repo')
+    def repo(self):
+        return self.session.repo
+
+    @property
+    @deprecated('[3.5] use self.session.vreg.schema')
+    def schema(self):
+        return self.session.repo.schema
+
+    @property
+    @deprecated('[3.5] use self.session.vreg.config')
+    def config(self):
+        return self.session.repo.config
+
 set_log_methods(Operation, getLogger('cubicweb.session'))
 
 
--- a/server/session.py	Fri Aug 14 14:31:25 2009 +0200
+++ b/server/session.py	Fri Aug 14 15:53:12 2009 +0200
@@ -75,10 +75,6 @@
         return '<%ssession %s (%s 0x%x)>' % (self.cnxtype, self.user.login,
                                              self.id, id(self))
 
-    @property
-    def schema(self):
-        return self.repo.schema
-
     def add_relation(self, fromeid, rtype, toeid):
         if self.is_super_session:
             self.repo.glob_add_relation(self, fromeid, rtype, toeid)
@@ -278,6 +274,11 @@
 
     # request interface #######################################################
 
+    @property
+    def cursor(self):
+        """return a rql cursor"""
+        return self
+
     def set_entity_cache(self, entity):
         # XXX session level caching may be a pb with multiple repository
         #     instances, but 1. this is probably not the only one :$ and 2. it
@@ -364,11 +365,6 @@
         return self.super_session.execute(rql, kwargs, eid_key, build_descr,
                                           propagate)
 
-    @property
-    def cursor(self):
-        """return a rql cursor"""
-        return self
-
     def execute(self, rql, kwargs=None, eid_key=None, build_descr=True,
                 propagate=False):
         """db-api like method directly linked to the querier execute method
@@ -485,7 +481,6 @@
             self._threaddata.pending_operations = []
             return self._threaddata.pending_operations
 
-
     def add_operation(self, operation, index=None):
         """add an observer"""
         assert self.commit_state != 'commit'
@@ -565,6 +560,13 @@
             description.append(tuple(row_descr))
         return description
 
+    # deprecated ###############################################################
+
+    @property
+    @deprecated("[3.5] use session.vreg.schema")
+    def schema(self):
+        return self.repo.schema
+
     @deprecated("[3.4] use vreg['etypes'].etype_class(etype)")
     def etype_class(self, etype):
         """return an entity class for the given entity type"""