def __getitem__(self, key): if key not in self.schemas: schemas = self.original_schemas schema = schemas[key] block_schema = create_schema(schema.__name__, {}, parents=(self.base_schema, schema), proxy=True) #set typed_key incase if base schema overwrote it block_schema._meta.typed_key = schema._meta.typed_key block_schema._meta.typed_field = self.base_schema._meta.typed_field block_schema._meta.collection = self.base_schema._meta.collection self.schemas[key] = block_schema return self.schemas[key]
def get_schema(self): fields = self.get_fields() if self.inherit_from: parent = self._meta.fields['inherit_from'].get_schema(self.inherit_from) if parent: parents = (parent, ) schema = create_schema('temp_schema', fields, module='schemamaker.models', parents=parents) else: schema = create_schema('temp_schema', fields, module='schemamaker.models') else: schema = create_schema('temp_schema', fields, module='schemamaker.models') def __unicode__(instance): if not self.object_label: return repr(instance) try: return self.object_label % instance except (KeyError, TypeError): return repr(instance) schema.__unicode__ = __unicode__ return schema
def get_schema(self): fields = self.get_fields() name = self.get_schema_name() schema = create_schema(name, fields, module='dockitcms.models') def __unicode__(instance): if not self.object_label: return repr(instance) try: return self.object_label % instance except (KeyError, TypeError): return repr(instance) schema.__unicode__ = __unicode__ return schema
def register_widget(self): #presumably this would be called on save or site load params = { 'module': 'dockitcms.widgetblock.models.virtual', 'virtual': False, 'verbose_name': self.title, #'collection': self.get_collection_name(), 'parents': (ConfiguredWidget,), 'name': self.get_schema_name(), 'attrs': SortedDict(), 'fields': self.get_fields(), 'typed_key': 'configured.%s' % self.get_schema_name(), } params['attrs']['_configurable_widget'] = self return create_schema(**params)
def get_schema(self, **kwargs): params = self.get_schema_kwargs(**kwargs) return create_schema(**params)