merge
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 23 Sep 2009 13:43:00 +0200
changeset 3434 6d0f22f5d31f
parent 3433 401ea5e03e9d (current diff)
parent 3430 e6d50513936c (diff)
child 3435 84036ad2c82d
merge
--- a/appobject.py	Wed Sep 23 13:42:48 2009 +0200
+++ b/appobject.py	Wed Sep 23 13:43:00 2009 +0200
@@ -370,15 +370,15 @@
 
     @deprecated('[3.6] use self.cw_rset.limited_rql')
     def limited_rql(self):
-        return self.rset.limited_rql()
+        return self.cw_rset.limited_rql()
 
     @deprecated('[3.6] use self.cw_rset.complete_entity(row,col) instead')
     def complete_entity(self, row, col=0, skip_bytes=True):
-        return self.rset.complete_entity(row, col, skip_bytes)
+        return self.cw_rset.complete_entity(row, col, skip_bytes)
 
     @deprecated('[3.6] use self.cw_rset.get_entity(row,col) instead')
     def entity(self, row, col=0):
-        return self.rset.get_entity(row, col)
+        return self.cw_rset.get_entity(row, col)
 
     @deprecated('[3.6] use self._cw.user_rql_callback')
     def user_rql_callback(self, args, msg=None):
--- a/common/mixins.py	Wed Sep 23 13:42:48 2009 +0200
+++ b/common/mixins.py	Wed Sep 23 13:43:00 2009 +0200
@@ -155,7 +155,7 @@
 
     def root(self):
         """return the root object"""
-        return self.req.entity_from_eid(self.path()[0])
+        return self._cw.entity_from_eid(self.path()[0])
 
 
 class EmailableMixIn(object):
@@ -209,7 +209,7 @@
         done = set()
     entity = view.rset.get_entity(row, col)
     if entity.eid in done:
-        msg = entity.req._('loop in %(rel)s relation (%(eid)s)') % {
+        msg = entity._cw._('loop in %(rel)s relation (%(eid)s)') % {
             'rel': entity.tree_attribute,
             'eid': entity.eid
             }
--- a/hooks/notification.py	Wed Sep 23 13:42:48 2009 +0200
+++ b/hooks/notification.py	Wed Sep 23 13:43:00 2009 +0200
@@ -12,7 +12,7 @@
 from cubicweb import RegistryException
 from cubicweb.selectors import entity_implements
 from cubicweb.server import hook
-
+from cubicweb.sobjects.supervising import SupervisionMailOp
 
 class RenderAndSendNotificationView(hook.Operation):
     """delay rendering of notification view until precommit"""
@@ -135,5 +135,5 @@
             # missing required relation
             title = '#%s' % eid
         self._cw.transaction_data.setdefault('pendingchanges', []).append(
-            ('delete_entity', (self.eid, str(self.entity.e_schema), title)))
+            ('delete_entity', (self.entity.eid, str(self.entity.e_schema), title)))
         return True
--- a/server/repository.py	Wed Sep 23 13:42:48 2009 +0200
+++ b/server/repository.py	Wed Sep 23 13:43:00 2009 +0200
@@ -173,6 +173,13 @@
         if config.open_connections_pools:
             self.open_connections_pools()
 
+    def _boostrap_hook_registry(self):
+        """called during bootstrap since we need the metadata hooks"""
+        hooksdirectory = join(CW_SOFTWARE_ROOT, 'hooks')
+        self.vreg.init_registration([hooksdirectory])
+        self.vreg.load_file(join(hooksdirectory, 'metadata.py'),
+                            'cubicweb.hooks.metadata')
+
     def open_connections_pools(self):
         config = self.config
         self._available_pools = Queue.Queue()
@@ -191,10 +198,7 @@
             for modname in ('__init__', 'authobjs', 'wfobjs'):
                 self.vreg.load_file(join(etdirectory, '%s.py' % modname),
                                 'cubicweb.entities.%s' % modname)
-            hooksdirectory = join(CW_SOFTWARE_ROOT, 'hooks')
-            self.vreg.init_registration([hooksdirectory])
-            self.vreg.load_file(join(hooksdirectory, 'metadata.py'),
-                                'cubicweb.hooks.metadata')
+            self._boostrap_hook_registry()
         else:
             # test start: use the file system schema (quicker)
             self.warning("set fs instance'schema")
--- a/sobjects/supervising.py	Wed Sep 23 13:42:48 2009 +0200
+++ b/sobjects/supervising.py	Wed Sep 23 13:43:00 2009 +0200
@@ -13,7 +13,7 @@
 from cubicweb.schema import display_name
 from cubicweb.view import Component
 from cubicweb.common.mail import format_mail
-from cubicweb.server.hookhelper import SendMailOp
+from cubicweb.server.hook import SendMailOp
 
 
 def filter_changes(changes):
@@ -63,13 +63,13 @@
     for eid in deleted:
         try:
             for change in index['delete_relation'].copy():
-                if change.eidfrom == eid:
+                if change[1].eidfrom == eid:
                     index['delete_relation'].remove(change)
-                elif change.eidto == eid:
+                elif change[1].eidto == eid:
                     index['delete_relation'].remove(change)
-                    if change.rtype == 'wf_info_for':
+                    if change[1].rtype == 'wf_info_for':
                         for change_ in index['delete_entity'].copy():
-                            if change_[1].eidfrom == change.eidfrom:
+                            if change_[1].eidfrom == change[1].eidfrom:
                                 index['delete_entity'].remove(change_)
         except KeyError:
             break
@@ -86,14 +86,14 @@
     __select__ = none_rset()
 
     def recipients(self):
-        return self.config['supervising-addrs']
+        return self._cw.vreg.config['supervising-addrs']
 
     def subject(self):
-        return self.req._('[%s supervision] changes summary') % self.config.appid
+        return self._cw._('[%s supervision] changes summary') % self._cw.vreg.config.appid
 
     def call(self, changes):
-        user = self.req.actual_session().user
-        self.w(self.req._('user %s has made the following change(s):\n\n')
+        user = self._cw.actual_session().user
+        self.w(self._cw._('user %s has made the following change(s):\n\n')
                % user.login)
         for event, changedescr in filter_changes(changes):
             self.w(u'* ')
@@ -106,31 +106,31 @@
                 'title': entity.dc_title()}
 
     def add_entity(self, changedescr):
-        msg = self.req._('added %(etype)s #%(eid)s (%(title)s)')
+        msg = self._cw._('added %(etype)s #%(eid)s (%(title)s)')
         self.w(u'%s\n' % (msg % self._entity_context(changedescr.entity)))
         self.w(u'  %s' % changedescr.entity.absolute_url())
 
     def update_entity(self, changedescr):
-        msg = self.req._('updated %(etype)s #%(eid)s (%(title)s)')
+        msg = self._cw._('updated %(etype)s #%(eid)s (%(title)s)')
         self.w(u'%s\n' % (msg % self._entity_context(changedescr.entity)))
         # XXX print changes
         self.w(u'  %s' % changedescr.entity.absolute_url())
 
     def delete_entity(self, (eid, etype, title)):
-        msg = self.req._('deleted %(etype)s #%(eid)s (%(title)s)')
-        etype = display_name(self.req, etype).lower()
+        msg = self._cw._('deleted %(etype)s #%(eid)s (%(title)s)')
+        etype = display_name(self._cw, etype).lower()
         self.w(msg % locals())
 
     def change_state(self, (entity, fromstate, tostate)):
-        msg = self.req._('changed state of %(etype)s #%(eid)s (%(title)s)')
+        msg = self._cw._('changed state of %(etype)s #%(eid)s (%(title)s)')
         self.w(u'%s\n' % (msg % self._entity_context(entity)))
         self.w(_('  from state %(fromstate)s to state %(tostate)s\n' %
                  {'fromstate': _(fromstate.name), 'tostate': _(tostate.name)}))
         self.w(u'  %s' % entity.absolute_url())
 
     def _relation_context(self, changedescr):
-        _ = self.req._
-        session = self.req.actual_session()
+        _ = self._cw._
+        session = self._cw.actual_session()
         def describe(eid):
             try:
                 return _(session.describe(eid)[0]).lower()
@@ -146,11 +146,11 @@
                 'toetype': describe(eidto)}
 
     def add_relation(self, changedescr):
-        msg = self.req._('added relation %(rtype)s from %(frometype)s #%(eidfrom)s to %(toetype)s #%(eidto)s')
+        msg = self._cw._('added relation %(rtype)s from %(frometype)s #%(eidfrom)s to %(toetype)s #%(eidto)s')
         self.w(msg % self._relation_context(changedescr))
 
-    def delete_relation(self, eidfrom, rtype, eidto):
-        msg = self.req._('deleted relation %(rtype)s from %(frometype)s #%(eidfrom)s to %(toetype)s #%(eidto)s')
+    def delete_relation(self, changedescr):
+        msg = self._cw._('deleted relation %(rtype)s from %(frometype)s #%(eidfrom)s to %(toetype)s #%(eidto)s')
         self.w(msg % self._relation_context(changedescr))
 
 
--- a/sobjects/test/unittest_notification.py	Wed Sep 23 13:42:48 2009 +0200
+++ b/sobjects/test/unittest_notification.py	Wed Sep 23 13:43:00 2009 +0200
@@ -70,8 +70,8 @@
 class StatusChangeViewsTC(CubicWebTC):
 
     def test_status_change_view(self):
-        req = self.session()
-        u = self.create_user('toto', req=req, commit=False)
+        req = self.request()
+        u = self.create_user('toto', req=req)
         u.fire_transition('deactivate', comment=u'yeah')
         self.failIf(MAILBOX)
         self.commit()