merge 3.5
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 21 Aug 2009 15:06:24 +0200
branch3.5
changeset 2964 7c80f9631f8b
parent 2957 2daabf4c646e (diff)
parent 2953 e5bdf98be37f (current diff)
child 2965 75ad5cb00b88
merge
--- a/entities/test/unittest_wfobjs.py	Fri Aug 21 11:38:57 2009 +0200
+++ b/entities/test/unittest_wfobjs.py	Fri Aug 21 15:06:24 2009 +0200
@@ -198,6 +198,7 @@
         self.assertEquals(len(transitions), 1)
         self.assertEquals(transitions[0].name, 'tr1')
 
+
 class CustomWorkflowTC(EnvBasedTC):
 
     def setup_database(self):
--- a/entities/wfobjs.py	Fri Aug 21 11:38:57 2009 +0200
+++ b/entities/wfobjs.py	Fri Aug 21 15:06:24 2009 +0200
@@ -120,9 +120,14 @@
     provides a specific may_be_fired method to check if the relation may be
     fired by the logged user
     """
-    id = 'Transition'
+    id = 'BaseTransition'
     fetch_attrs, fetch_order = fetch_config(['name'])
 
+    def __init__(self, *args, **kwargs):
+        if self.id == 'BaseTransition':
+            raise Exception('should not be instantiated')
+        super(BaseTransition, self).__init__(*args, **kwargs)
+
     def may_be_fired(self, eid):
         """return true if the logged user may fire this transition
 
--- a/misc/migration/2.42.0_Any.py	Fri Aug 21 11:38:57 2009 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,9 +0,0 @@
-"""
-
-:organization: Logilab
-:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2.
-:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
-:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses
-"""
-synchronize_rschema('created_by')
-synchronize_rschema('owned_by')
--- a/misc/migration/2.42.1_Any.py	Fri Aug 21 11:38:57 2009 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,25 +0,0 @@
-"""
-
-:organization: Logilab
-:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2.
-:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
-:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses
-"""
-if confirm('remove deprecated database constraints?'):
-    execute = session.system_sql
-    session.set_pool()
-    dbhelper = session.pool.source('system').dbhelper
-    cu = session.pool['system']
-    for table in dbhelper.list_tables(cu):
-        if table.endswith('_relation'):
-            try:
-                execute('ALTER TABLE %s DROP CONSTRAINT %s_fkey1' % (table, table))
-                execute('ALTER TABLE %s DROP CONSTRAINT %s_fkey2' % (table, table))
-            except:
-                continue
-    checkpoint()
-
-if 'inline_view' in schema:
-    # inline_view attribute should have been deleted for a while now....
-    drop_attribute('CWRelation', 'inline_view')
-
--- a/misc/migration/2.43.0_Any.py	Fri Aug 21 11:38:57 2009 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,8 +0,0 @@
-"""
-
-:organization: Logilab
-:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2.
-:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
-:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses
-"""
-synchronize_permissions('EmailAddress')
--- a/misc/migration/2.44.0_Any.py	Fri Aug 21 11:38:57 2009 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,21 +0,0 @@
-"""
-
-:organization: Logilab
-:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2.
-:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
-:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses
-"""
-change_relation_props('CWAttribute', 'cardinality', 'String', internationalizable=True)
-change_relation_props('CWRelation', 'cardinality', 'String', internationalizable=True)
-
-drop_relation_definition('CWPermission', 'require_state', 'State')
-
-if confirm('cleanup require_permission relation'):
-    try:
-        newrschema = fsschema.rschema('require_permission')
-    except KeyError:
-        newrschema = None
-    for rsubj, robj in schema.rschema('require_permission').rdefs():
-        if newrschema is None or not newrschema.has_rdef(rsubj, robj):
-            print 'removing', rsubj, 'require_permission', robj
-            drop_relation_definition(rsubj, 'require_permission', robj, ask_confirm=False)
--- a/misc/migration/2.45.0_Any.py	Fri Aug 21 11:38:57 2009 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,25 +0,0 @@
-# following functions have been renamed, but keep old definition for bw compat
-"""
-
-:organization: Logilab
-:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2.
-:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
-:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses
-"""
-sql('''CREATE AGGREGATE group_concat (
-  basetype = anyelement,
-  sfunc = array_append,
-  stype = anyarray,
-  finalfunc = comma_join,
-  initcond = '{}'
-)''')
-
-sql('''CREATE FUNCTION text_limit_size (fulltext text, maxsize integer) RETURNS text AS $$
-BEGIN
-    RETURN limit_size(fulltext, 'text/plain', maxsize);
-END
-$$ LANGUAGE plpgsql;
-''')
-
-
-synchronize_rschema('bookmarked_by')
--- a/misc/migration/2.46.0_Any.py	Fri Aug 21 11:38:57 2009 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-"""
-
-:organization: Logilab
-:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2.
-:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
-:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses
-"""
-
-
-rql('SET X value "navtop" WHERE X pkey ~= "contentnavigation.%.context", X value "header"')
-rql('SET X value "navcontenttop" WHERE X pkey ~= "contentnavigation%.context", X value "incontext"')
-rql('SET X value "navcontentbottom" WHERE X pkey ~= "contentnavigation%.context", X value "footer"')
-checkpoint()
-
-if 'require_permission' in schema:
-    synchronize_rschema('require_permission')
--- a/misc/migration/2.47.0_Any.py	Fri Aug 21 11:38:57 2009 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,11 +0,0 @@
-"""
-
-:organization: Logilab
-:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2.
-:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
-:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses
-"""
-synchronize_permissions('primary_email')
-synchronize_rschema('wf_info_for')
-synchronize_rschema('use_email')
-
--- a/misc/migration/2.48.8_Any.py	Fri Aug 21 11:38:57 2009 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,9 +0,0 @@
-"""
-
-:organization: Logilab
-:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2.
-:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
-:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses
-"""
-for etype in ('CWRType', 'CWAttribute', 'CWRelation', 'CWConstraint', 'CWConstraintType'):
-    synchronize_permissions(etype)
--- a/misc/migration/2.49.3_Any.py	Fri Aug 21 11:38:57 2009 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,8 +0,0 @@
-"""
-
-:organization: Logilab
-:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2.
-:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
-:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses
-"""
-add_entity_type('Decimal')
--- a/misc/migration/2.50.0_Any.py	Fri Aug 21 11:38:57 2009 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,8 +0,0 @@
-"""
-
-:organization: Logilab
-:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2.
-:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
-:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses
-"""
-add_relation_type('specializes')
--- a/misc/migration/bootstrapmigration_repository.py	Fri Aug 21 11:38:57 2009 +0200
+++ b/misc/migration/bootstrapmigration_repository.py	Fri Aug 21 15:06:24 2009 +0200
@@ -41,37 +41,3 @@
 
 if applcubicwebversion < (3, 2, 0) and cubicwebversion >= (3, 2, 0):
     add_cube('card', update_database=False)
-
-if applcubicwebversion < (2, 47, 0) and cubicwebversion >= (2, 47, 0):
-     from cubicweb.server import schemaserial
-     schemaserial.HAS_FULLTEXT_CONTAINER = False
-     session.set_shared_data('do-not-insert-is_instance_of', True)
-     add_attribute('CWRType', 'fulltext_container')
-     schemaserial.HAS_FULLTEXT_CONTAINER = True
-
-
-
-if applcubicwebversion < (2, 50, 0) and cubicwebversion >= (2, 50, 0):
-     session.set_shared_data('do-not-insert-is_instance_of', True)
-     add_relation_type('is_instance_of')
-     # fill the relation using an efficient sql query instead of using rql
-     sql('INSERT INTO is_instance_of_relation '
-         '  SELECT * from is_relation')
-     checkpoint()
-     session.set_shared_data('do-not-insert-is_instance_of', False)
-
-if applcubicwebversion < (2, 42, 0) and cubicwebversion >= (2, 42, 0):
-     sql('ALTER TABLE entities ADD COLUMN mtime TIMESTAMP')
-     sql('UPDATE entities SET mtime=CURRENT_TIMESTAMP')
-     sql('CREATE INDEX entities_mtime_idx ON entities(mtime)')
-     sql('''CREATE TABLE deleted_entities (
-  eid INTEGER PRIMARY KEY NOT NULL,
-  type VARCHAR(64) NOT NULL,
-  source VARCHAR(64) NOT NULL,
-  dtime TIMESTAMP NOT NULL,
-  extid VARCHAR(256)
-)''')
-     sql('CREATE INDEX deleted_entities_type_idx ON deleted_entities(type)')
-     sql('CREATE INDEX deleted_entities_dtime_idx ON deleted_entities(dtime)')
-     sql('CREATE INDEX deleted_entities_extid_idx ON deleted_entities(extid)')
-     checkpoint()
--- a/schema.py	Fri Aug 21 11:38:57 2009 +0200
+++ b/schema.py	Fri Aug 21 15:06:24 2009 +0200
@@ -853,7 +853,7 @@
             make_workflowable(cls)
         return cls
 
-def make_workflowable(cls):
+def make_workflowable(cls, in_state_descr=None):
     existing_rels = set(rdef.name for rdef in cls.__relations__)
     # let relation types defined in cw.schemas.workflow carrying
     # cardinality, constraints and other relation definition properties
@@ -861,7 +861,7 @@
         rdef = ybo.SubjectRelation('Workflow')
         yams_add_relation(cls.__relations__, rdef, 'custom_workflow')
     if 'in_state' not in existing_rels:
-        rdef = ybo.SubjectRelation('State')
+        rdef = ybo.SubjectRelation('State', description=in_state_descr)
         yams_add_relation(cls.__relations__, rdef, 'in_state')
     if 'wf_info_for' not in existing_rels:
         rdef = ybo.ObjectRelation('TrInfo')
--- a/schemas/workflow.py	Fri Aug 21 11:38:57 2009 +0200
+++ b/schemas/workflow.py	Fri Aug 21 15:06:24 2009 +0200
@@ -133,7 +133,7 @@
     to_state = SubjectRelation('State', cardinality='1*')
     # make by_transition optional because we want to allow managers to set
     # entity into an arbitrary state without having to respect wf transition
-    by_transition = SubjectRelation('Transition', cardinality='?*')
+    by_transition = SubjectRelation('BaseTransition', cardinality='?*')
     comment = RichString(fulltextindexed=True)
     # get actor and date time using owned_by and creation_date
 
--- a/server/migractions.py	Fri Aug 21 11:38:57 2009 +0200
+++ b/server/migractions.py	Fri Aug 21 15:06:24 2009 +0200
@@ -918,14 +918,14 @@
         if not isinstance(wfof, (list, tuple)):
             wfof = (wfof,)
         for etype in wfof:
-            rset = self.rqlexec('SET X workflow_of ET '
-                                'WHERE X eid %(x)s, ET name %(et)s',
-                                {'x': wf.eid, 'et': etype}, 'x')
+            rset = self.rqlexec(
+                'SET X workflow_of ET WHERE X eid %(x)s, ET name %(et)s',
+                {'x': wf.eid, 'et': etype}, 'x', ask_confirm=False)
             assert rset, 'unexistant entity type %s' % etype
             if default:
-                rset = self.rqlexec('SET ET default_workflow X '
-                                    'WHERE X eid %(x)s, ET name %(et)s',
-                                    {'x': wf.eid, 'et': etype}, 'x')
+                self.rqlexec(
+                    'SET ET default_workflow X WHERE X eid %(x)s, ET name %(et)s',
+                    {'x': wf.eid, 'et': etype}, 'x', ask_confirm=False)
         if commit:
             self.commit()
         return wf
--- a/server/schemaserial.py	Fri Aug 21 11:38:57 2009 +0200
+++ b/server/schemaserial.py	Fri Aug 21 15:06:24 2009 +0200
@@ -110,7 +110,6 @@
                 print sql
                 sqlcu.execute(sql)
         # other table renaming done once schema has been read
-    # print 'reading schema from the database...'
     index = {}
     permsdict = deserialize_ertype_permissions(session)
     schema.reading_from_database = True
--- a/server/sources/native.py	Fri Aug 21 11:38:57 2009 +0200
+++ b/server/sources/native.py	Fri Aug 21 15:06:24 2009 +0200
@@ -94,8 +94,6 @@
     """adapter for source using the native cubicweb schema (see below)
     """
     sqlgen_class = SQLGenerator
-    # need default value on class since migration doesn't call init method
-    has_deleted_entitites_table = True
 
     passwd_rql = "Any P WHERE X is CWUser, X login %(login)s, X upassword P"
     auth_rql = "Any X WHERE X is CWUser, X login %(login)s, X upassword %(pwd)s"
@@ -224,15 +222,6 @@
 
     def init(self):
         self.init_creating()
-        pool = self.repo._get_pool()
-        pool.pool_set()
-        # XXX cubicweb < 2.42 compat
-        if 'deleted_entities' in self.dbhelper.list_tables(pool['system']):
-            self.has_deleted_entitites_table = True
-        else:
-            self.has_deleted_entitites_table = False
-        pool.pool_reset()
-        self.repo._free_pool(pool)
 
     def map_attribute(self, etype, attr, cb):
         self._rql_sqlgen.attr_map['%s.%s' % (etype, attr)] = cb
@@ -547,13 +536,12 @@
         """
         attrs = {'eid': eid}
         session.system_sql(self.sqlgen.delete('entities', attrs), attrs)
-        if self.has_deleted_entitites_table:
-            if extid is not None:
-                assert isinstance(extid, str), type(extid)
-                extid = b64encode(extid)
-            attrs = {'type': etype, 'eid': eid, 'extid': extid,
-                     'source': uri, 'dtime': datetime.now()}
-            session.system_sql(self.sqlgen.insert('deleted_entities', attrs), attrs)
+        if extid is not None:
+            assert isinstance(extid, str), type(extid)
+            extid = b64encode(extid)
+        attrs = {'type': etype, 'eid': eid, 'extid': extid,
+                 'source': uri, 'dtime': datetime.now()}
+        session.system_sql(self.sqlgen.insert('deleted_entities', attrs), attrs)
 
     def fti_unindex_entity(self, session, eid):
         """remove text content for entity with the given eid from the full text
--- a/web/uicfg.py	Fri Aug 21 11:38:57 2009 +0200
+++ b/web/uicfg.py	Fri Aug 21 15:06:24 2009 +0200
@@ -149,12 +149,14 @@
 # * 'application'
 # * 'system'
 # * 'schema'
+# * 'hidden'
 # * 'subobject' (not displayed by default)
 
 indexview_etype_section = {'EmailAddress': 'subobject',
                            'CWUser': 'system',
                            'CWGroup': 'system',
                            'CWPermission': 'system',
+                           'BaseTransition': 'hidden',
                            }