Exemple #1
0
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)
Exemple #2
0
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)
Exemple #3
0
 def create_from_json(cls, json, dbm):
     doc = DataDictDocument.wrap(json)
     return DataDictType.new_from_doc(dbm, doc)
Exemple #4
0
 def create_from_json(cls, json,dbm):
     doc = DataDictDocument.wrap(json)
     return DataDictType.new_from_doc(dbm,doc)