def get_datadict_type_by_slug(dbm,slug): assert isinstance(dbm, DatabaseManager) assert is_string(slug) rows = dbm.load_all_rows_in_view('by_datadict_type', key=slug,include_docs='true') if not len(rows): raise DataObjectNotFound("DataDictType","slug",slug) assert len(rows) == 1, "More than one item found for slug %s" % (slug,) # include_docs = 'true' returns the doc as a dict, which has to be wrapped into a DataDictDocument, and then into a DataDictType _doc = DataDictDocument.wrap(rows[0].doc) return DataDictType.new_from_doc(dbm,_doc)
def get_datadict_type_by_slug(dbm, slug): assert isinstance(dbm, DatabaseManager) assert is_string(slug) rows = dbm.load_all_rows_in_view('by_datadict_type', key=slug, include_docs='true') if not len(rows): raise DataObjectNotFound("DataDictType", "slug", slug) assert len(rows) == 1, "More than one item found for slug %s" % (slug, ) # include_docs = 'true' returns the doc as a dict, which has to be wrapped into a DataDictDocument, and then into a DataDictType _doc = DataDictDocument.wrap(rows[0].doc) return DataDictType.new_from_doc(dbm, _doc)
def create_from_json(cls, json, dbm): doc = DataDictDocument.wrap(json) return DataDictType.new_from_doc(dbm, doc)
def create_from_json(cls, json,dbm): doc = DataDictDocument.wrap(json) return DataDictType.new_from_doc(dbm,doc)