kill most pre 3.2 bw compat code
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 05 Feb 2010 12:14:36 +0100
changeset 4475 37c413a07216
parent 4474 55fe19813bb7
child 4476 14429e8c7590
kill most pre 3.2 bw compat code
__init__.py
devtools/stresstester.py
misc/migration/2.99.0_Any.py
misc/migration/3.1.5_Any.py
misc/migration/3.2.0_Any.py
rset.py
server/schemaserial.py
--- a/__init__.py	Fri Feb 05 12:13:48 2010 +0100
+++ b/__init__.py	Fri Feb 05 12:14:36 2010 +0100
@@ -56,51 +56,12 @@
                "Binary objects must use raw strings, not %s" % data.__class__
         StringIO.write(self, data)
 
-# use this dictionary for renaming of entity types while keeping bw compat
-ETYPE_NAME_MAP = {# 3.2 migration
-                  'ECache': 'CWCache',
-                  'EUser': 'CWUser',
-                  'EGroup': 'CWGroup',
-                  'EProperty': 'CWProperty',
-                  'EFRDef': 'CWAttribute',
-                  'ENFRDef': 'CWRelation',
-                  'ERType': 'CWRType',
-                  'EEType': 'CWEType',
-                  'EConstraintType': 'CWConstraintType',
-                  'EConstraint': 'CWConstraint',
-                  'EPermission': 'CWPermission',
-                  }
-
+# use this dictionary to rename entity types while keeping bw compat
+ETYPE_NAME_MAP = {}
 
-# XXX cubic web cube migration map
-CW_MIGRATION_MAP = {'erudi': 'cubicweb',
-                    'eaddressbook': 'addressbook',
-                    'ebasket': 'basket',
-                    'eblog': 'blog',
-                    'ebook': 'book',
-                    'eclassschemes': 'keyword',
-                    'eclassfolders': 'folder',
-                    'eclasstags': 'tag',
-                    'ecomment': 'comment',
-                    'ecompany': 'company',
-                    'econference':  'conference',
-                    'eemail': 'email',
-                    'eevent': 'event',
-                    'eexpense': 'expense',
-                    'efile': 'file',
-                    'einvoice': 'invoice',
-                    'elink': 'link',
-                    'emailinglist': 'mailinglist',
-                    'eperson': 'person',
-                    'eshopcart': 'shopcart',
-                    'eskillmat': 'skillmat',
-                    'etask': 'task',
-                    'eworkcase': 'workcase',
-                    'eworkorder': 'workorder',
-                    'ezone': 'zone',
-                    'i18ncontent': 'i18ncontent',
-                    'svnfile': 'vcsfile',
-                    }
+# XXX cubic web cube migration map. See if it's worth keeping this mecanism
+#     to help in cube renaming
+CW_MIGRATION_MAP = {}
 
 def neg_role(role):
     if role == 'subject':
--- a/devtools/stresstester.py	Fri Feb 05 12:13:48 2010 +0100
+++ b/devtools/stresstester.py	Fri Feb 05 12:14:36 2010 +0100
@@ -26,8 +26,6 @@
 :license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses
 """
 
-__revision__ = "$Id: stresstester.py,v 1.3 2006-03-05 14:35:27 syt Exp $"
-
 import os
 import sys
 import threading
--- a/misc/migration/2.99.0_Any.py	Fri Feb 05 12:13:48 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,19 +0,0 @@
-"""
-
-:organization: Logilab
-:copyright: 2001-2010 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
-"""
-from cubicweb import CW_MIGRATION_MAP
-
-for pk, in rql('Any K WHERE X is CWProperty, X pkey IN (%s), X pkey K'
-               % ','.join("'system.version.%s'" % cube for cube in CW_MIGRATION_MAP),
-               ask_confirm=False):
-    cube = pk.split('.')[-1]
-    newk = pk.replace(cube, CW_MIGRATION_MAP[cube])
-    rql('SET X pkey %(newk)s WHERE X pkey %(oldk)s',
-        {'oldk': pk, 'newk': newk}, ask_confirm=False)
-    print 'renamed', pk, 'to', newk
-
-add_entity_type('CWCache')
--- a/misc/migration/3.1.5_Any.py	Fri Feb 05 12:13:48 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,8 +0,0 @@
-"""
-
-:organization: Logilab
-:copyright: 2001-2010 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('condition')
--- a/misc/migration/3.2.0_Any.py	Fri Feb 05 12:13:48 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,11 +0,0 @@
-"""
-
-:organization: Logilab
-:copyright: 2001-2010 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 "main-template" WHERE X is CWProperty, '
-    'X pkey "ui.main-template", X value "main"')
-checkpoint()
-
--- a/rset.py	Fri Feb 05 12:13:48 2010 +0100
+++ b/rset.py	Fri Feb 05 12:14:36 2010 +0100
@@ -373,7 +373,7 @@
         return entity
 
     @cached
-    def get_entity(self, row, col=None):
+    def get_entity(self, row, col):
         """special method for query retreiving a single entity, returns a
         partially initialized Entity instance.
 
@@ -387,11 +387,6 @@
 
         :return: the partially initialized `Entity` instance
         """
-        if col is None:
-            from warnings import warn
-            msg = '[3.2] col parameter will become mandatory in future version'
-            warn(msg, DeprecationWarning, stacklevel=3)
-            col = 0
         etype = self.description[row][col]
         try:
             eschema = self.vreg.schema.eschema(etype)
--- a/server/schemaserial.py	Fri Feb 05 12:13:48 2010 +0100
+++ b/server/schemaserial.py	Fri Feb 05 12:14:36 2010 +0100
@@ -52,39 +52,6 @@
                     continue
     return res
 
-def _set_sql_prefix(prefix):
-    """3.2.0 migration function: allow to unset/reset SQL_PREFIX"""
-    for module in ('checkintegrity', 'migractions', 'schemahooks',
-                   'sources.rql2sql', 'sources.native', 'sqlutils'):
-        try:
-            sys.modules['cubicweb.server.%s' % module].SQL_PREFIX = prefix
-            print 'changed SQL_PREFIX for %s' % module
-        except KeyError:
-            pass
-
-def _update_database(schema, sqlcu):
-    """3.2.0 migration function: update database schema by adding SQL_PREFIX to
-    entity type tables and columns
-    """
-    for etype in schema.entities():
-        if etype.final:
-            continue
-        try:
-            sql = 'ALTER TABLE %s RENAME TO cw_%s' % (
-                etype, ETYPE_NAME_MAP.get(etype, etype))
-            print sql
-            sqlcu.execute(sql)
-        except:
-            pass
-        for rschema in etype.subject_relations():
-            if rschema == 'has_text':
-                continue
-            if rschema.final or rschema.inlined:
-                sql = 'ALTER TABLE cw_%s RENAME %s TO cw_%s' % (
-                    etype, rschema, rschema)
-                print sql
-                sqlcu.execute(sql)
-
 # schema / perms deserialization ##############################################
 OLD_SCHEMA_TYPES = frozenset(('EFRDef', 'ENFRDef', 'ERType', 'EEType',
                               'EConstraintType', 'EConstraint', 'EGroup',
@@ -94,26 +61,10 @@
     """return a schema according to information stored in an rql database
     as CWRType and CWEType entities
     """
-    #
     repo = session.repo
-    sqlcu = session.pool['system']
-    _3_2_migration = False
     dbhelper = repo.system_source.dbhelper
-    tables = set(t.lower() for t in dbhelper.list_tables(sqlcu))
-    if 'eetype' in tables:
-        _3_2_migration = True
-        # 3.2 migration
-        _set_sql_prefix('')
-        # first rename entity types whose name changed in 3.2 without adding the
-        # cw_ prefix
-        for etype in OLD_SCHEMA_TYPES:
-            if etype.lower() in tables:
-                sql = 'ALTER TABLE %s RENAME TO %s' % (etype,
-                                                       ETYPE_NAME_MAP[etype])
-                print sql
-                sqlcu.execute(sql)
-        # other table renaming done once schema has been read
     # 3.6 migration
+    sqlcu = session.pool['system']
     sqlcu.execute("SELECT * FROM cw_CWRType WHERE cw_name='symetric'")
     if sqlcu.fetchall():
         sql = dbhelper.sql_rename_col('cw_CWRType', 'cw_symetric', 'cw_symmetric',
@@ -209,9 +160,6 @@
         if rdefs is not None:
             set_perms(rdefs, permsdict)
     schema.infer_specialization_rules()
-    if _3_2_migration:
-        _update_database(schema, sqlcu)
-        _set_sql_prefix('cw_')
     session.commit()
     schema.reading_from_database = False