merge branches in tls-sprint (bis) tls-sprint
authorlogilab@eusebius.local
Tue, 17 Feb 2009 17:30:47 +0100
branchtls-sprint
changeset 678 4a29050fe143
parent 677 9b04bbfe3f90 (current diff)
parent 670 6c332f5c969c (diff)
child 679 d70fb8c9e369
merge branches in tls-sprint (bis)
--- a/common/registerers.py	Tue Feb 17 17:28:25 2009 +0100
+++ b/common/registerers.py	Tue Feb 17 17:30:47 2009 +0100
@@ -125,54 +125,6 @@
     
     def equivalent(self, other):
         return other.id == self.vobject.id
-
-
-class etype_rtype_registerer(registerer):
-    """registerer handling optional .etype and .rtype attributes.:
-    
-    * if .etype is set and is not an entity type defined in the
-      application schema, skip the wrapped class
-    * if .rtype or .relname is set and is not a relation type defined in
-      the application schema, skip the wrapped class
-    * register
-    """
-    def do_it_yourself(self, registered):
-        cls = self.vobject
-        if hasattr(cls, 'etype'):
-            if not self.schema.has_entity(cls.etype):
-                return
-        rtype = getattr(cls, 'rtype', None)
-        if rtype and not self.schema.has_relation(rtype):
-            return
-        return cls
-
-class etype_rtype_priority_registerer(etype_rtype_registerer):
-    """add priority behaviour to the etype_rtype_registerer
-    """
-    def do_it_yourself(self, registered):
-        cls = super(etype_rtype_priority_registerer, self).do_it_yourself(registered)
-        if cls:
-            registerer = priority_registerer(self.registry, cls)
-            cls = registerer.do_it_yourself(registered)
-        return cls
-
-class action_registerer(etype_rtype_registerer):
-    """'all in one' actions registerer, handling optional .accepts,
-    .etype and .rtype attributes:
-    
-    * if .etype is set and is not an entity type defined in the
-      application schema, skip the wrapped class
-    * if .rtype or .relname is set and is not a relation type defined in
-      the application schema, skip the wrapped class
-    * if .accepts is set, delegate to the accepts_registerer
-    * register
-    """
-    def do_it_yourself(self, registered):
-        cls = super(action_registerer, self).do_it_yourself(registered)
-        if hasattr(cls, 'accepts'):
-            registerer = accepts_registerer(self.registry, cls)
-            cls = registerer.do_it_yourself(registered)
-        return cls
     
 
 __all__ = [cls.__name__ for cls in globals().values()
--- a/goa/appobjects/sessions.py	Tue Feb 17 17:28:25 2009 +0100
+++ b/goa/appobjects/sessions.py	Tue Feb 17 17:30:47 2009 +0100
@@ -17,8 +17,8 @@
 
 from cubicweb import UnknownEid, BadConnectionId
 from cubicweb.dbapi import Connection, ConnectionProperties, repo_connect
+from cubicweb.selectors import none_rset, match_user_groups
 from cubicweb.server.session import Session
-from cubicweb.common.selectors import none_rset, match_user_groups
 from cubicweb.web import InvalidSession
 from cubicweb.web.application import AbstractSessionManager
 from cubicweb.web.application import AbstractAuthenticationManager
@@ -269,4 +269,9 @@
         self.w(u'%s repository sessions closed<br/>\n' % nbclosed)
         self.w(u'%s remaining sessions<br/>\n' % remaining)
         self.w(u'</div>')
+
         
+def registration_callback(vreg):
+    vreg.register(SessionsCleaner)
+    vreg.register(GAEAuthenticationManager, clear=True)
+    vreg.register(GAEPersistentSessionManager, clear=True)
--- a/vregistry.py	Tue Feb 17 17:28:25 2009 +0100
+++ b/vregistry.py	Tue Feb 17 17:30:47 2009 +0100
@@ -237,13 +237,20 @@
         return objects[0].selected(*args, **kwargs)
 
     # methods for explicit (un)registration ###################################
-    
-    def register(self, obj, registryname=None, oid=None):
+
+#     def clear(self, key):
+#         regname, oid = key.split('.')
+#         self[regname].pop(oid, None)
+        
+    def register(self, obj, registryname=None, oid=None, clear=False):
         """base method to add an object in the registry"""
         registryname = registryname or obj.__registry__
         oid = oid or obj.id
         registry = self._registries.setdefault(registryname, {})
-        vobjects = registry.setdefault(oid, [])
+        if clear:
+            vobjects = registry[oid] =  []
+        else:
+            vobjects = registry.setdefault(oid, [])
         # registered() is technically a classmethod but is not declared
         # as such because we need to compose registered in some cases
         vobject = obj.registered.im_func(cls, self)
@@ -426,8 +433,8 @@
 
     def load_module(self, module):
         self._registered = {}
-        if hasattr(module, 'cw_register_objects'):
-            module.cw_register_objects(self)
+        if hasattr(module, 'registration_callback'):
+            module.registration_callback(self)
         else:
             self.info('loading %s', module)
             for objname, obj in vars(module).items():
--- a/web/action.py	Tue Feb 17 17:28:25 2009 +0100
+++ b/web/action.py	Tue Feb 17 17:30:47 2009 +0100
@@ -11,7 +11,7 @@
                                 one_line_rset, may_add_relation, yes,
                                 accepts_compat, condition_compat, deprecate)
 from cubicweb.common.appobject import AppRsetObject
-from cubicweb.common.registerers import action_registerer
+from cubicweb.common.registerers import accepts_registerer
 
 _ = unicode
 
@@ -21,7 +21,7 @@
     request search state. 
     """
     __registry__ = 'actions'
-    __registerer__ = action_registerer
+    __registerer__ = accepts_registerer
     __selectors__ = (yes,) 
     
     property_defs = {
--- a/web/box.py	Tue Feb 17 17:28:25 2009 +0100
+++ b/web/box.py	Tue Feb 17 17:30:47 2009 +0100
@@ -13,9 +13,7 @@
 from cubicweb.selectors import (one_line_rset,  primary_view,
                                 match_context_prop, has_related_entities,
                                 accepts_compat, condition_compat)
-from cubicweb.common.registerers import (
-    accepts_registerer, extresources_registerer,
-    etype_rtype_priority_registerer)
+from cubicweb.common.registerers import accepts_registerer, priority_registerer
 #etype_rtype_selector, has_relation,
 from cubicweb.common.view import Template, ReloadableMixIn
 
@@ -104,7 +102,7 @@
     according to application schema and display according to connected
     user's rights) and rql attributes
     """
-    __registerer__ = etype_rtype_priority_registerer
+    __registerer__ = priority_registerer
 #XXX    __selectors__ = BoxTemplate.__selectors__ + (etype_rtype_selector,)
 
     rql  = None
--- a/web/component.py	Tue Feb 17 17:28:25 2009 +0100
+++ b/web/component.py	Tue Feb 17 17:30:47 2009 +0100
@@ -14,7 +14,7 @@
 from cubicweb.common.appobject import Component
 from cubicweb.common.utils import merge_dicts
 from cubicweb.common.view import View
-from cubicweb.common.registerers import action_registerer
+from cubicweb.common.registerers import accepts_registerer
 from cubicweb.common.uilib import html_escape
 
 _ = unicode
@@ -31,7 +31,7 @@
     """
     
     __registry__ = 'contentnavigation'
-    __registerer__ = action_registerer    
+    __registerer__ = accepts_registerer    
     __selectors__ = (one_line_rset, primary_view, match_context_prop,)
     registered = accepts_compat(has_relation_compat(condition_compat(View.registered.im_func)))