def __init__(self, table_name=None, **kwargs): super(RDBTable, self).__init__(**kwargs) if table_name: self.table_name = camel_case_to_name(table_name.split('.')[0]) else: self.table_name = camel_case_to_name(self.filename.split('.')[0]) self.is_created = False
def migrate_storage(from_storage: str, to_storage: str) -> None: log = logging.getLogger(__name__) old_default = DepotManager._default_depot DepotManager._default_depot = to_storage for klass, props in _SQLAMutationTracker.mapped_entities.items(): log.info("Migrating %r", klass) mapper = klass._sa_class_manager.mapper # use type column to avoid polymorphism issues, getting the same # Node item multiple times. type_ = camel_case_to_name(klass.__name__) for instance in DBSession.query(klass).filter_by(type=type_): for prop in props: uf = getattr(instance, prop) if not uf: continue pk = mapper.primary_key_from_instance(instance) log.info("Migrating %s for %r with pk %r", prop, klass, pk) filename = uf["filename"] content_type = uf["content_type"] data = _to_fieldstorage( fp=uf.file, filename=filename, mimetype=content_type, size=uf.file.content_length, ) setattr(instance, prop, data) DepotManager._default_depot = old_default
def migrate_storage(from_storage, to_storage): log = logging.getLogger(__name__) old_default = DepotManager._default_depot DepotManager._default_depot = to_storage for klass, props in _SQLAMutationTracker.mapped_entities.items(): log.info("Migrating %r", klass) mapper = klass._sa_class_manager.mapper # use type column to avoid polymorphism issues, getting the same # Node item multiple times. type_ = camel_case_to_name(klass.__name__) for instance in DBSession.query(klass).filter_by(type=type_): for prop in props: uf = getattr(instance, prop) if not uf: continue pk = mapper.primary_key_from_instance(instance) log.info("Migrating %s for %r with pk %r", prop, klass, pk) filename = uf['filename'] content_type = uf['content_type'] data = _to_fieldstorage(fp=uf.file, filename=filename, mimetype=content_type, size=uf.file.content_length) setattr(instance, prop, data) DepotManager._default_depot = old_default
def __mapper_args__(cls): return dict(polymorphic_identity=camel_case_to_name(cls.__name__))
def __tablename__(cls): from kotti.util import camel_case_to_name # prevent circ import return '{0}s'.format(camel_case_to_name(cls.__name__))
def __tablename__(cls): return '{0}s'.format(camel_case_to_name(cls.__name__))