Fork 0

use explicit unicode columns for client table (fixes #38)

* data/dbrepo/versions/002.py:
  - replace String with Unicode for appropriate columns
 * gnuviechadmin/backend/BackendTo.py:
  - only convert strings to unicode for Unicode columns
 * gnuviechadmin/backend/tables.py:
  - override table definition for client table's Unicode columns
Jan Dittberner 14 years ago
parent d4ba46a329
commit ccaa207d36

@ -10,13 +10,13 @@ meta = MetaData(migrate_engine)
client = Table(
'client', meta,
Column('clientid', Integer, primary_key=True),
Column('title', String(10)),
Column('firstname', String(64), nullable=False),
Column('lastname', String(64), nullable=False),
Column('address1', String(64), nullable=False),
Column('address2', String(64)),
Column('title', Unicode(10)),
Column('firstname', Unicode(64), nullable=False),
Column('lastname', Unicode(64), nullable=False),
Column('address1', Unicode(64), nullable=False),
Column('address2', Unicode(64)),
Column('zip', String(7), nullable=False),
Column('city', String(64), nullable=False),
Column('city', Unicode(64), nullable=False),
Column('country', String(5), nullable=False),
Column('phone', String(32), nullable=False),
Column('mobile', String(32)),

@ -20,16 +20,20 @@
# Version: $Id$
from sqlalchemy.orm import object_mapper
from sqlalchemy import Unicode
class BackendTo(object):
"""Backend transfer object class."""
def __init__(self, config, **kwargs):
cols = object_mapper(self).local_table.columns.keys()
cols = object_mapper(self).local_table.columns
for (key, value) in kwargs.items():
if key in cols and value is not None:
self.__setattr__(key, unicode(value, 'utf8'))
if key in cols.keys() and value is not None:
if isinstance(cols[key].type, Unicode):
self.__setattr__(key, value.decode('utf8'))
self.__setattr__(key, value)
def __repr__(self, **kwargs):
if 'verbose' in kwargs and kwargs['verbose']:

@ -73,13 +73,22 @@ Trying automatic versioning.""")
'organization', meta,
Column('name', Unicode(200)),
schema = dbschema, autoload = True)
client_table = Table(
'client', meta,
Column('title', Unicode(10)),
Column('firstname', Unicode(64)),
Column('lastname', Unicode(64)),
Column('address1', Unicode(64)),
Column('address2', Unicode(64)),
Column('city', Unicode(64)),
schema = dbschema, autoload = True)
(client_table, sysuser_table, domain_table, \
(sysuser_table, domain_table, \
record_table, supermaster_table, mailaccount_table, \
mailaddress_table, mailtarget_table) = \
[Table(tabname, meta, schema = dbschema,
autoload = True) for tabname in \
('client', 'sysuser', 'domain', 'record',
('sysuser', 'domain', 'record',
'supermaster', 'mailaccount', 'mailaddress', 'mailtarget')]
client_mapper = mapper(Client, client_table, {