Exemplo n.º 1
0
 def query(self, *largs, **kargs):
     db = lookup(kargs, "db", default = None, destroy = True)
     join = lookup(kargs, "join", default = None, destroy = True)
     by = lookup(kargs, "by", default = None, destroy = True)
     if db is None:
         db = self.getdb()
     t = Table(self.cl._spec["name"])
     if join is not None:
         t = t.join(join, by = by)
     if self.cl._parent is None:
         cur = lookup(kargs, "cur", default = None, destroy = True)
         orderby = lookup(kargs, "orderby", default = [], destroy = True)
         limit = lookup(kargs, "limit", default = None, destroy = True)
         offset = lookup(kargs, "offset", default = None, destroy = True)
         return db.query(columns = [All()], table = t,
                         cond = And(*largs, **kargs), orderby = orderby,
                         limit = limit,  offset = offset, cur = cur)
     else:
         return ZooInfo(self.cl._parent).query(db = db, join = t,
                                     by = {self.cl._spec["primary_key"]},
                                     *largs, **kargs)
Exemplo n.º 2
0
 def count(self, *largs, **kargs):
     db = lookup(kargs, "db", default = None, destroy = True)
     join = lookup(kargs, "join", default = None, destroy = True)
     by = lookup(kargs, "by", default = None, destroy = True)
     if db is None:
         db = self.getdb()
     t = Table(self.cl._spec["name"])
     if join is not None:
         t = t.join(join, by = by)
     if self.cl._parent is None:
         groupby = lookup(kargs, "groupby", default = [], destroy = True)
         if type(groupby) == set:
             groupby = list(groupby)
         elif type(groupby) != list:
             groupby = [groupby]
         cur = db.query(columns = [Count(All())] + groupby, table = t,
                        cond = And(*largs, **kargs), groupby = groupby)
         n = cur.fetchall()
         cur.close()
         return tomultidict(n, groupby)
     else:
         return ZooInfo(self.cl._parent).count(db = db, join = t,
                                     by = {self.cl._spec["primary_key"]},
                                     *largs, **kargs)
Exemplo n.º 3
0
 def crosswalk(self):
     return Table(self.api, 't/crosswalk')
Exemplo n.º 4
0
 def monetize(self):
     return Table(self.api, 'places/monetize')
Exemplo n.º 5
0
 def table(self, table):
     return Table(self.api, 't/' + table)