Пример #1
0
Файл: orm.py Проект: hzx/wender
  def selectFrom(self, coll, where, parent, limit=None):
    names = self.collToNames(coll)
    if not names:
      return None

    dotcoll = '.'.join(names)

    # load reflink
    if dotcoll in self.meta.refToColl:
      src = self.meta.refToColl[dotcoll]
      return self.selectFromRefLink(src, names, where, parent)
    elif dotcoll in self.meta.linkToColl:
      src = self.meta.linkToColl[dotcoll]
      return self.selectFromRefLink(src, names, where, parent)
    # load array
    elif dotcoll in self.meta.colls:
      return dbutil.cursorToList(mongodb.selectFrom(dotcoll, where, limit))

    raise Exception('unknown collection type "%s"' % dotcoll)
Пример #2
0
Файл: orm.py Проект: hzx/wender
  def load(self, useraccess):
    """
    Load database for userKind
    """
    db = {}

    accessre = self.accessToRe[useraccess]
    accessReadRe = accessre['read']
    # accessWriteRe = accessre['write']

    for docname, params in self.meta.docs.items():
      access = params.get('access', '----')
      if not accessReadRe.match(access):
        continue

      if params['isArray']:
        if self.isArrayLazy(params):
          continue
        db[docname] = dbutil.cursorToList(mongodb.selectFrom(docname, {}))
      else:
        db[docname] = mongodb.selectOne(docname, {})
    return db