def init(self, event): conn = self.get_connection(event) for table_name, columns in self.table_defs.items(): table_schema = RowSequenceSchema() for args in columns: table_schema.add(*args) table = conn.define_table(table_name, table_schema) if not conn.exists(table_name, 'table'): table.create() elif event.clear_all: table.delete_rows()
def get_schema_for_class(self, module_name, class_name): """Returns the class-defined property schema. This Zope2-ism should be made pluggable later on. """ d = {} m = __import__(module_name, d, d, ('__doc__', )) klass = getattr(m, class_name) schema = RowSequenceSchema() props = getattr(klass, '_properties', ()) if not props: return None for p in props: if not safe_property_types.has_key(p['type']): # Don't store this property in its own column. # It is of a type that's hard to convert faithfully. continue prop_name = p['id'] if prop_name == 'oid': name = '_oid' else: name = prop_name schema.add(name, p['type'], 0) return schema
def get_schema_for_class(self, module_name, class_name): """Returns the class-defined property schema. This Zope2-ism should be made pluggable later on. """ d = {} m = __import__(module_name, d, d, ('__doc__',)) klass = getattr(m, class_name) schema = RowSequenceSchema() props = getattr(klass, '_properties', ()) if not props: return None for p in props: if not safe_property_types.has_key(p['type']): # Don't store this property in its own column. # It is of a type that's hard to convert faithfully. continue prop_name = p['id'] if prop_name == 'oid': name = '_oid' else: name = prop_name schema.add(name, p['type'], 0) return schema