backport stable branch
authorNicolas Chauvat <nicolas.chauvat@logilab.fr>
Sun, 16 Aug 2009 20:27:28 +0200
changeset 2867 e8581a4f1bae
parent 2855 1d9be3dffa94 (current diff)
parent 2866 4c804711548d (diff)
child 2869 0cb160fd3cdf
backport stable branch
server/migractions.py
server/repository.py
server/serverctl.py
web/application.py
web/views/ajaxedit.py
web/views/basecontrollers.py
--- a/.hgtags	Fri Aug 14 15:53:12 2009 +0200
+++ b/.hgtags	Sun Aug 16 20:27:28 2009 +0200
@@ -54,3 +54,5 @@
 82fe8a6d077b34e972664c8e2bace3ae30c94b9d cubicweb-debian-version-3.3.5-1
 cfcc7f6121d6c6b53a1ef9bc96c3b7c82f33d169 cubicweb-version-3.4.2
 e6a8cd8cc910507e5f928ddba6de3cf5e5bdf3d4 cubicweb-debian-version-3.4.2-1
+b2add17d5bc437a807976cd13870f92d3a94f2a6 cubicweb-version-3.4.3
+a3828745e2cf0c4bf1cab6f5397c524ba0510df6 cubicweb-debian-version-3.4.3-1
--- a/_exceptions.py	Fri Aug 14 15:53:12 2009 +0200
+++ b/_exceptions.py	Sun Aug 16 20:27:28 2009 +0200
@@ -79,8 +79,6 @@
     msg = 'You are not allowed to perform this operation'
     msg1 = 'You are not allowed to perform %s operation on %s'
     var = None
-    #def __init__(self, *args):
-    #    self.args = args
 
     def __str__(self):
         try:
@@ -118,9 +116,6 @@
     this may be a programming/typo or a misconfiguration error
     """
 
-# class ViewNotFound(ObjectNotFound):
-#     """raised when an unregistered view is called"""
-
 class NoSelectableObject(RegistryException):
     """some views with the given vid have been found but no
     one is applyable to the result set
@@ -149,4 +144,3 @@
 
 # pylint: disable-msg=W0611
 from logilab.common.clcommands import BadCommandUsage
-
--- a/debian/changelog	Fri Aug 14 15:53:12 2009 +0200
+++ b/debian/changelog	Sun Aug 16 20:27:28 2009 +0200
@@ -1,3 +1,9 @@
+cubicweb (3.4.3-1) unstable; urgency=low
+
+  * new upstream release
+
+ -- Nicolas Chauvat <nicolas.chauvat@logilab.fr>  Fri, 14 Aug 2009 17:54:06 +0200
+
 cubicweb (3.4.2-1) unstable; urgency=low
 
   * new upstream release
@@ -132,37 +138,37 @@
 
  -- Sylvain Thénault <sylvain.thenault@logilab.fr>  Tue, 27 Jan 2009 16:05:12 +0100
 
-cubicweb (3.0.3-1) DISTRIBUTION; urgency=low
+cubicweb (3.0.3-1) unstable; urgency=low
 
   * new upstream release
 
  -- Aurélien Campéas <aurelien.campeas@logilab.fr>  Wed, 14 Jan 2009 18:25:21 +0100
 
-cubicweb (3.0.2-1) DISTRIBUTION; urgency=low
+cubicweb (3.0.2-1) unstable; urgency=low
 
   * new upstream release
 
  -- Sylvain Thénault <sylvain.thenault@logilab.fr>  Wed, 14 Jan 2009 13:25:21 +0100
 
-cubicweb (3.0.1-1) DISTRIBUTION; urgency=low
+cubicweb (3.0.1-1) unstable; urgency=low
 
   * new upstream release
 
  -- Sylvain Thénault <sylvain.thenault@logilab.fr>  Thu, 08 Jan 2009 18:27:37 +0100
 
-cubicweb (3.0.0-1) DISTRIBUTION; urgency=low
+cubicweb (3.0.0-1) unstable; urgency=low
 
   * new upstream release
 
  -- Adrien Di Mascio <Adrien.DiMascio@logilab.fr>  Tue, 23 Dec 2008 18:42:43 +0100
 
-cubicweb (2.99.99-1) DISTRIBUTION; urgency=low
+cubicweb (2.99.99-1) unstable; urgency=low
 
   * new upstream release
 
  -- Sylvain Thénault <sylvain.thenault@logilab.fr>  Mon, 22 Dec 2008 17:34:45 +0100
 
-cubicweb (2.99.7-1) DISTRIBUTION; urgency=low
+cubicweb (2.99.7-1) unstable; urgency=low
 
   * remove buggy cubicweb-common.postinst
   * replace erudi|ginco by cubicweb where necessary in existing instance
@@ -170,43 +176,43 @@
 
  -- Sylvain Thénault <sylvain.thenault@logilab.fr>  Fri, 19 Dec 2008 17:11:00 +0100
 
-cubicweb (2.99.6-1) DISTRIBUTION; urgency=low
+cubicweb (2.99.6-1) unstable; urgency=low
 
   * new upstream release
 
  -- Sylvain Thénault <sylvain.thenault@logilab.fr>  Fri, 19 Dec 2008 15:16:37 +0100
 
-cubicweb (2.99.5-1) DISTRIBUTION; urgency=low
+cubicweb (2.99.5-1) unstable; urgency=low
 
   * new upstream release
 
  -- Sylvain Thénault <sylvain.thenault@logilab.fr>  Wed, 17 Dec 2008 14:14:26 +0100
 
-cubicweb (2.99.4-1) DISTRIBUTION; urgency=low
+cubicweb (2.99.4-1) unstable; urgency=low
 
   * new upstream release
 
  -- Adrien Di Mascio <Adrien.DiMascio@logilab.fr>  Fri, 12 Dec 2008 10:00:31 +0100
 
-cubicweb (2.99.3-1) DISTRIBUTION; urgency=low
+cubicweb (2.99.3-1) unstable; urgency=low
 
   * new upstream release
 
  -- Adrien Di Mascio <Adrien.DiMascio@logilab.fr>  Tue, 09 Dec 2008 07:42:16 +0100
 
-cubicweb (2.99.2-1) DISTRIBUTION; urgency=low
+cubicweb (2.99.2-1) unstable; urgency=low
 
   * new upstream release
 
  -- Adrien Di Mascio <adrien.dimascio@logilab.fr>  Mon, 17 Nov 2008 15:02:16 +0100
 
-cubicweb (2.99.1-1) DISTRIBUTION; urgency=low
+cubicweb (2.99.1-1) unstable; urgency=low
 
   * new upstream release
 
  -- Nicolas Chauvat <nicolas.chauvat@logilab.fr>  Thu, 13 Nov 2008 11:02:16 +0100
 
-cubicweb (2.99.0-1) DISTRIBUTION; urgency=low
+cubicweb (2.99.0-1) unstable; urgency=low
 
   * initial public release
 
--- a/goa/testlib.py	Fri Aug 14 15:53:12 2009 +0200
+++ b/goa/testlib.py	Sun Aug 16 20:27:28 2009 +0200
@@ -6,7 +6,11 @@
 """
 __docformat__ = "restructuredtext en"
 
-from logilab.common.testlib import TestCase
+from logilab.common.testlib import TestCase, TestSkipped
+try:
+    import google.appengine
+except ImportError:
+    raise TestSkipped('Can not import google.appengine. Skip this module')
 
 import os, os.path as osp
 import time
@@ -18,34 +22,17 @@
 rqlannotation.SQLGenAnnotator = goarqlannotation.SQLGenAnnotator
 rqlannotation.set_qdata = goarqlannotation.set_qdata
 
-try:
-    from google.appengine.api import apiproxy_stub_map
-    from google.appengine.api import datastore_file_stub
-    from google.appengine.ext import db as gdb
-    from cubicweb.goa import db, do_monkey_patch
-    import_appengine_failed = None
-except ImportError, exc:
-    # XXX necessary ?
-    class db:
-        class Model:
-            pass
-        class DummyProperty:
-            def __init__(self, *args, **kwargs):
-                pass
-        TextProperty = DummyProperty
-        StringProperty = DummyProperty
-        BlobProperty = DummyProperty
-        DateProperty = DummyProperty
-        ReferenceProperty = DummyProperty
-        SelfReferenceProperty = DummyProperty
-    import_appengine_failed = 'cannot import appengine: %s' % exc
-
+from google.appengine.api import apiproxy_stub_map
+from google.appengine.api import datastore_file_stub
+from google.appengine.ext import db as gdb
 
 from cubicweb.devtools.fake import FakeRequest
-from cubicweb.goa.goavreg import GAEVregistry
+
+from cubicweb.goa import db, do_monkey_patch
+from cubicweb.goa.goavreg import GAEVRegistry
 from cubicweb.goa.goaconfig import GAEConfiguration
 from cubicweb.goa.dbinit import (create_user, create_groups, fix_entities,
-                              init_persistent_schema, insert_versions)
+                                 init_persistent_schema, insert_versions)
 
 import logging
 logger = logging.getLogger()
@@ -82,8 +69,6 @@
         apiproxy_stub_map.apiproxy.RegisterStub('datastore_v3', stub)
 
     def setUp(self):
-        if import_appengine_failed:
-            self.skip(import_appengine_failed)
         # Ensure we're in UTC.
         os.environ['TZ'] = 'UTC'
         time.tzset()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/misc/migration/3.4.3_Any.py	Sun Aug 16 20:27:28 2009 +0200
@@ -0,0 +1,2 @@
+# sync and restart to make sure cwuri does not appear in forms
+sync_schema_props_perms()
--- a/server/migractions.py	Fri Aug 14 15:53:12 2009 +0200
+++ b/server/migractions.py	Sun Aug 16 20:27:28 2009 +0200
@@ -169,16 +169,15 @@
         bkup = tarfile.open(backupfile, 'r|gz')
         tmpdir = tempfile.mkdtemp()
         bkup.extractall(path=tmpdir)
-        if systemonly:
-            repo.system_source.restore(osp.join(tmpdir,'system'), drop=drop)
-        else:
-            for source in repo.sources:
-                try:
-                    source.restore(osp.join(tmpdir, source.uri), drop=drop)
-                except Exception, exc:
-                    print '-> error trying to restore [%s]' % exc
-                    if not self.confirm('Continue anyway?', default='n'):
-                        raise SystemExit(1)
+        for source in repo.sources:
+            if systemonly and source.uri != 'system':
+                continue
+            try:
+                source.restore(osp.join(tmpdir, source.uri), drop=drop)
+            except Exception, exc:
+                print '-> error trying to restore [%s]' % exc
+                if not self.confirm('Continue anyway?', default='n'):
+                    raise SystemExit(1)
         bkup.close()
         shutil.rmtree(tmpdir)
         # call hooks
--- a/server/serverctl.py	Fri Aug 14 15:53:12 2009 +0200
+++ b/server/serverctl.py	Sun Aug 16 20:27:28 2009 +0200
@@ -529,21 +529,20 @@
     status = instance_status(config, eversion, dbversions)
     # * database version > installed software
     if status == 'needsoftupgrade':
-        print "database is using some earlier version than installed software!"
-        print "please upgrade your software and then upgrade the instance"
-        print "using command 'cubicweb-ctl upgrade %s'" % config.appid
+        print "** The database of %s is more recent than the installed software!" % config.appid
+        print "** Upgrade your software, then migrate the database by running the command"
+        print "** 'cubicweb-ctl upgrade %s'" % config.appid
         return
     # * database version < installed software, an upgrade will be necessary
     #   anyway, just rewrite vc.conf and warn user he has to upgrade
-    if status == 'needapplupgrade':
-        print "database is using some older version than installed software."
-        print "You'll have to upgrade the instance using command"
-        print "'cubicweb-ctl upgrade %s'" % config.appid
+    elif status == 'needapplupgrade':
+        print "** The database of %s is older than the installed software." % config.appid
+        print "** Migrate the database by running the command"
+        print "** 'cubicweb-ctl upgrade %s'" % config.appid
         return
     # * database version = installed software, database version = instance fs version
     #   ok!
 
-
 def instance_status(config, cubicwebapplversion, vcconf):
     cubicwebversion = config.cubicweb_version()
     if cubicwebapplversion > cubicwebversion:
--- a/server/test/unittest_extlite.py	Fri Aug 14 15:53:12 2009 +0200
+++ b/server/test/unittest_extlite.py	Sun Aug 16 20:27:28 2009 +0200
@@ -5,7 +5,15 @@
 
 class SQLiteTC(TestCase):
     sqlite_file = '_extlite_test.sqlite'
+
+    def _cleanup(self):
+        try:
+            os.remove(self.sqlite_file)
+        except:
+            pass
+
     def setUp(self):
+        self._cleanup()
         cnx1 = get_connection('sqlite', database=self.sqlite_file)
         cu = cnx1.cursor()
         cu.execute('CREATE TABLE toto(name integer);')
@@ -13,10 +21,7 @@
         cnx1.close()
 
     def tearDown(self):
-        try:
-            os.remove(self.sqlite_file)
-        except:
-            pass
+        self._cleanup()
 
     def test(self):
         lock = threading.Lock()
--- a/web/application.py	Fri Aug 14 15:53:12 2009 +0200
+++ b/web/application.py	Sun Aug 16 20:27:28 2009 +0200
@@ -41,10 +41,6 @@
         if self.session_time:
             assert self.cleanup_session_time < self.session_time
             assert self.cleanup_anon_session_time < self.session_time
-        self.set_authmanager()
-        CW_EVENT_MANAGER.bind('after-registry-reload', self.set_authmanager)
-
-    def set_authmanager(self):
         self.authmanager = self.vreg['components'].select('authmanager')
 
     def clean_sessions(self):
--- a/web/data/cubicweb.edition.js	Fri Aug 14 15:53:12 2009 +0200
+++ b/web/data/cubicweb.edition.js	Sun Aug 16 20:27:28 2009 +0200
@@ -243,21 +243,22 @@
  * @param ttype : the target (inlined) entity type
  * @param rtype : the relation type between both entities
  */
-function addInlineCreationForm(peid, ttype, rtype, role) {
+function addInlineCreationForm(peid, ttype, rtype, role, insertBefore) {
+    insertBefore = insertBefore || getNode('add' + rtype + ':' + peid + 'link').parentNode;
     var d = asyncRemoteExec('inline_creation_form', peid, ttype, rtype, role);
     d.addCallback(function (response) {
-	var linknode = getNode('add' + rtype + ':' + peid + 'link');
         var dom = getDomFromResponse(response);
-	var form = jQuery(dom);
-	form.css('display', 'none');
-	form.insertBefore(linknode.parentNode).slideDown('fast');
-	updateInlinedEntitiesCounters(rtype);
-	reorderTabindex();
-	form.trigger('inlinedform-added');
+        preprocessAjaxLoad(null, dom);
+        var form = jQuery(dom);
+        form.css('display', 'none');
+        form.insertBefore(insertBefore).slideDown('fast');
+        updateInlinedEntitiesCounters(rtype);
+        reorderTabindex();
+        form.trigger('inlinedform-added');
         postAjaxLoad(dom);
     });
     d.addErrback(function (xxx) {
-	log('xxx =', xxx);
+        log('xxx =', xxx);
     });
 }
 
--- a/web/views/ajaxedit.py	Fri Aug 14 15:53:12 2009 +0200
+++ b/web/views/ajaxedit.py	Sun Aug 16 20:27:28 2009 +0200
@@ -40,14 +40,12 @@
                 etypes = rschema.subjects(entity.e_schema)
             if len(etypes) == 1:
                 self.etype = etypes[0]
-        fakebox = []
         self.w(u'<div id="%s">' % self.id)
         self.w(u'<h1>%s</h1>' % self.req._('relation %(relname)s of %(ent)s')
                % {'relname': rschema.display_name(self.req, role(self)),
                   'ent': entity.view('incontext')})
         self.w(u'<ul>')
-        self.w_unrelated(fakebox, entity)
-        for boxitem in fakebox:
+        for boxitem in self.unrelated_boxitems(entity):
             boxitem.render(self.w)
         self.w(u'</ul></div>')
 
--- a/web/views/basecontrollers.py	Fri Aug 14 15:53:12 2009 +0200
+++ b/web/views/basecontrollers.py	Sun Aug 16 20:27:28 2009 +0200
@@ -298,6 +298,31 @@
             return None
         return None
 
+    def _call_view(self, view, **kwargs):
+        req = self.req
+        divid = req.form.get('divid', 'pageContent')
+        # we need to call pagination before with the stream set
+        stream = view.set_stream()
+        if req.form.get('paginate'):
+            if divid == 'pageContent':
+                # mimick main template behaviour
+                stream.write(u'<div id="pageContent">')
+                vtitle = self.req.form.get('vtitle')
+                if vtitle:
+                    stream.write(u'<h1 class="vtitle">%s</h1>\n' % vtitle)
+            view.pagination(req, self.rset, view.w, not view.need_navigation)
+            if divid == 'pageContent':
+                stream.write(u'<div id="contentmain">')
+        view.render(**kwargs)
+        extresources = req.html_headers.getvalue(skiphead=True)
+        if extresources:
+            stream.write(u'<div class="ajaxHtmlHead">\n') # XXX use a widget ?
+            stream.write(extresources)
+            stream.write(u'</div>\n')
+        if req.form.get('paginate') and divid == 'pageContent':
+            stream.write(u'</div></div>')
+        return stream.getvalue()
+
     @xhtmlize
     def js_view(self):
         # XXX try to use the page-content template
@@ -313,28 +338,7 @@
         except NoSelectableObject:
             vid = req.form.get('fallbackvid', 'noresult')
             view = self.vreg['views'].select(vid, req, rset=rset)
-        divid = req.form.get('divid', 'pageContent')
-        # we need to call pagination before with the stream set
-        stream = view.set_stream()
-        if req.form.get('paginate'):
-            if divid == 'pageContent':
-                # mimick main template behaviour
-                stream.write(u'<div id="pageContent">')
-                vtitle = self.req.form.get('vtitle')
-                if vtitle:
-                    stream.write(u'<h1 class="vtitle">%s</h1>\n' % vtitle)
-            view.pagination(req, rset, view.w, not view.need_navigation)
-            if divid == 'pageContent':
-                stream.write(u'<div id="contentmain">')
-        view.render()
-        extresources = req.html_headers.getvalue(skiphead=True)
-        if extresources:
-            stream.write(u'<div class="ajaxHtmlHead">\n') # XXX use a widget ?
-            stream.write(extresources)
-            stream.write(u'</div>\n')
-        if req.form.get('paginate') and divid == 'pageContent':
-            stream.write(u'</div></div>')
-        return stream.getvalue()
+        return self._call_view(view)
 
     @xhtmlize
     def js_prop_widget(self, propkey, varname, tabindex=None):
@@ -370,7 +374,8 @@
         view = self.vreg['views'].select('inline-creation', self.req,
                                          etype=ttype, peid=peid, rtype=rtype,
                                          role=role)
-        return view.render(etype=ttype, peid=peid, rtype=rtype, role=role)
+        return self._call_view(view, etype=ttype, peid=peid,
+                               rtype=rtype, role=role)
 
     @jsonize
     def js_validate_form(self, action, names, values):