Commit 60f0f3e9 authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

kill most pre 3.2 bw compat code

parent 55fe19813bb7
......@@ -56,51 +56,12 @@ class Binary(StringIO):
"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',
}
# 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',
}
# use this dictionary to rename entity types while keeping bw compat
ETYPE_NAME_MAP = {}
# 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':
......
......@@ -26,8 +26,6 @@ http://www.logilab.fr/ -- mailto:contact@logilab.fr
: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
......
"""
: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')
"""
: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')
"""
: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()
......@@ -373,7 +373,7 @@ class ResultSet(object):
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 @@ class ResultSet(object):
: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)
......
......@@ -52,39 +52,6 @@ def group_mapping(cursor, interactive=True):
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 @@ def deserialize_schema(schema, session):
"""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 @@ def deserialize_schema(schema, session):
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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment