backport stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 16 Nov 2012 11:53:17 +0100
changeset 8596 bd4f5052a532
parent 8595 01e1e44f1eb3 (current diff)
parent 8591 f7c07e9d4f2e (diff)
child 8609 112a04c0473d
backport stable
__pkginfo__.py
dbapi.py
hooks/__init__.py
req.py
selectors.py
server/hook.py
server/session.py
sobjects/ldapparser.py
web/data/cubicweb.ajax.js
--- a/.hgtags	Fri Nov 16 11:52:06 2012 +0100
+++ b/.hgtags	Fri Nov 16 11:53:17 2012 +0100
@@ -266,3 +266,5 @@
 7ad423a5b6a883dbdf00e6c87a5f8ab121041640 cubicweb-debian-version-3.15.3-1
 63260486de89a9dc32128cd0eacef891a668977b cubicweb-version-3.15.4
 70cb36c826df86de465f9b69647cef7096dcf12c cubicweb-debian-version-3.15.4-1
+b0e086f451b7213fe63141438edc91a6b2da9072 cubicweb-version-3.15.5
+19e115ae5442c427c0adbda8b9d8ceccf2931b5c cubicweb-debian-version-3.15.5-1
--- a/__pkginfo__.py	Fri Nov 16 11:52:06 2012 +0100
+++ b/__pkginfo__.py	Fri Nov 16 11:53:17 2012 +0100
@@ -22,7 +22,7 @@
 
 modname = distname = "cubicweb"
 
-numversion = (3, 15, 4)
+numversion = (3, 15, 5)
 version = '.'.join(str(num) for num in numversion)
 
 description = "a repository of entities / relations for knowledge management"
--- a/dbapi.py	Fri Nov 16 11:52:06 2012 +0100
+++ b/dbapi.py	Fri Nov 16 11:53:17 2012 +0100
@@ -307,6 +307,9 @@
     def from_controller(self):
         return 'view'
 
+    def get_option_value(self, option, foreid=None):
+        return self.cnx.get_option_value(option, foreid)
+
     def set_session(self, session, user=None):
         """method called by the session handler when the user is authenticated
         or an anonymous connection is open
--- a/debian/changelog	Fri Nov 16 11:52:06 2012 +0100
+++ b/debian/changelog	Fri Nov 16 11:53:17 2012 +0100
@@ -1,3 +1,9 @@
+cubicweb (3.15.5-1) unstable; urgency=low
+
+  * New upstream release
+
+ -- Aurélien Campéas <aurelien.campeas@logilab.fr>  Wed, 24 Oct 2012 12:07:00 +0200
+
 cubicweb (3.15.4-1) unstable; urgency=low
 
   * New upstream release
--- a/hooks/__init__.py	Fri Nov 16 11:52:06 2012 +0100
+++ b/hooks/__init__.py	Fri Nov 16 11:53:17 2012 +0100
@@ -23,9 +23,9 @@
 
 from cubicweb.server import hook
 
-class ServerStartupHook(hook.Hook):
-    """task to cleanup expirated auth cookie entities"""
-    __regid__ = 'cw.start-looping-tasks'
+class TransactionsCleanupStartupHook(hook.Hook):
+    """start task to cleanup transaction data"""
+    __regid__ = 'cw.looping-tasks.transactions-cleanup'
     events = ('server_startup',)
 
     def __call__(self):
@@ -49,6 +49,13 @@
         if self.repo.config['undo-enabled']:
             self.repo.looping_task(60*60*24, cleanup_old_transactions,
                                    self.repo)
+
+class UpdateFeedsStartupHook(hook.Hook):
+    """start task to update datafeed based sources"""
+    __regid__ = 'cw.looping-tasks.update-feeds'
+    events = ('server_startup',)
+
+    def __call__(self):
         def update_feeds(repo):
             # don't iter on repo.sources which doesn't include copy based
             # sources (the one we're looking for)
@@ -66,6 +73,13 @@
                     session.close()
         self.repo.looping_task(60, update_feeds, self.repo)
 
+
+class DataImportsCleanupStartupHook(hook.Hook):
+    """start task to cleanup old data imports (ie datafeed import logs)"""
+    __regid__ = 'cw.looping-tasks.dataimports-cleanup'
+    events = ('server_startup',)
+
+    def __call__(self):
         def expire_dataimports(repo=self.repo):
             for source in repo.sources_by_eid.itervalues():
                 if (not source.copy_based_source
@@ -74,7 +88,8 @@
                 session = repo.internal_session()
                 try:
                     mindate = datetime.now() - timedelta(seconds=source.config['logs-lifetime'])
-                    session.execute('DELETE CWDataImport X WHERE X start_timestamp < %(time)s', {'time': mindate})
+                    session.execute('DELETE CWDataImport X WHERE X start_timestamp < %(time)s',
+                                    {'time': mindate})
                     session.commit()
                 finally:
                     session.close()
--- a/req.py	Fri Nov 16 11:52:06 2012 +0100
+++ b/req.py	Fri Nov 16 11:53:17 2012 +0100
@@ -88,6 +88,9 @@
         self._ = self.__ = gettext
         self.pgettext = pgettext
 
+    def get_option_value(self, option, foreid=None):
+        raise NotImplementedError
+
     def property_value(self, key):
         """return value of the property with the given key, giving priority to
         user specific value if any, else using site value
--- a/server/hook.py	Fri Nov 16 11:52:06 2012 +0100
+++ b/server/hook.py	Fri Nov 16 11:53:17 2012 +0100
@@ -552,9 +552,14 @@
             raise Exception('bad .events attribute %s on %s.%s' % (
                 cls.events, cls.__module__, cls.__name__))
 
+    @classmethod
+    def __registered__(cls, reg):
+        cls.check_events()
+
     @classproperty
     def __registries__(cls):
-        cls.check_events()
+        if cls.events is None:
+            return []
         return ['%s_hooks' % ev for ev in cls.events]
 
     known_args = set(('entity', 'rtype', 'eidfrom', 'eidto', 'repo', 'timestamp'))
--- a/server/ldaputils.py	Fri Nov 16 11:52:06 2012 +0100
+++ b/server/ldaputils.py	Fri Nov 16 11:53:17 2012 +0100
@@ -137,13 +137,13 @@
     def _entity_update(self, source_entity):
         if self.urls:
             if len(self.urls) > 1:
-                raise ValidationError(source_entity, {'url': _('can only have one url')})
+                raise ValidationError(source_entity.eid, {'url': _('can only have one url')})
             try:
                 protocol, hostport = self.urls[0].split('://')
             except ValueError:
-                raise ValidationError(source_entity, {'url': _('badly formatted url')})
+                raise ValidationError(source_entity.eid, {'url': _('badly formatted url')})
             if protocol not in PROTO_PORT:
-                raise ValidationError(source_entity, {'url': _('unsupported protocol')})
+                raise ValidationError(source_entity.eid, {'url': _('unsupported protocol')})
 
     def update_config(self, source_entity, typedconfig):
         """update configuration from source entity. `typedconfig` is config
--- a/server/session.py	Fri Nov 16 11:52:06 2012 +0100
+++ b/server/session.py	Fri Nov 16 11:53:17 2012 +0100
@@ -287,6 +287,8 @@
             self.set_tx_data()
             return self.__threaddata.txdata
 
+    def get_option_value(self, option, foreid=None):
+        return self.repo.get_option_value(option, foreid)
 
     def hijack_user(self, user):
         """return a fake request/session using specified user"""
--- a/server/sources/ldapfeed.py	Fri Nov 16 11:52:06 2012 +0100
+++ b/server/sources/ldapfeed.py	Fri Nov 16 11:53:17 2012 +0100
@@ -15,11 +15,7 @@
 #
 # You should have received a copy of the GNU Lesser General Public License along
 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
-"""cubicweb ldap feed source
-
-unlike ldapuser source, this source is copy based and will import ldap content
-(beside passwords for authentication) into the system source.
-"""
+"""cubicweb ldap feed source"""
 
 from cubicweb.server.sources import datafeed
 from cubicweb.server import ldaputils
@@ -27,7 +23,10 @@
 
 class LDAPFeedSource(ldaputils.LDAPSourceMixIn,
                      datafeed.DataFeedSource):
-    """LDAP feed source"""
+    """LDAP feed source: unlike ldapuser source, this source is copy based and
+    will import ldap content (beside passwords for authentication) into the
+    system source.
+    """
     support_entities = {'CWUser': False}
     use_cwuri_as_url = False
 
--- a/sobjects/ldapparser.py	Fri Nov 16 11:52:06 2012 +0100
+++ b/sobjects/ldapparser.py	Fri Nov 16 11:53:17 2012 +0100
@@ -151,7 +151,8 @@
             elif self.sourceuris:
                 # pop from sourceuris anyway, else email may be removed by the
                 # source once import is finished
-                self.sourceuris.pop(str(userdict['dn'] + '@@' + emailaddr), None)
+                uri = userdict['dn'] + '@@' + emailaddr.encode('utf-8')
+                self.sourceuris.pop(uri, None)
             # XXX else check use_email relation?
 
     @cached
--- a/web/data/cubicweb.ajax.js	Fri Nov 16 11:52:06 2012 +0100
+++ b/web/data/cubicweb.ajax.js	Fri Nov 16 11:53:17 2012 +0100
@@ -696,7 +696,7 @@
 
 
 /**
- * .. function:: reload(domid, registry, formparams, *render_args)
+ * .. function:: reload(domid, compid, registry, formparams, *render_args)
  *
  * `js_render` based reloading of views and components.
  */
--- a/web/test/unittest_viewselector.py	Fri Nov 16 11:52:06 2012 +0100
+++ b/web/test/unittest_viewselector.py	Fri Nov 16 11:53:17 2012 +0100
@@ -53,6 +53,11 @@
 
 assert RDFVIEWS
 
+if hasattr(rdf, 'RDFView'): # not available if rdflib not installed
+    RDFVIEWS = [('rdf', rdf.RDFView)]
+else:
+    RDFVIEWS = []
+
 class ViewSelectorTC(CubicWebTC):
 
     def setup_database(self):