Esempio n. 1
0
def list_products(group, subgroup):
    rows = db().view("product/group", reduce=False, include_docs=True)[[group,subgroup,""]:[group,subgroup,u"\ufff0"]]
    for row in rows:
        doc = row.doc
        id = doc.id
        title = doc["title"]
        yield id, title
Esempio n. 2
0
def list_subgroups(group):
    return (x.key[1] for x in list(db().view("product/group", group=True, group_level=2)[[group,""]:[group,u"\ufff0"]]))
Esempio n. 3
0
def list_groups():
    return (x.key[0] for x in db().view("product/group", group=True, group_level=1))
Esempio n. 4
0
def get_product(id):
    doc = db()[id]
    title = doc["title"]
    price = doc["price"]
    date = doc["date"]
    return title, price, date
Esempio n. 5
0
 def save(self):
     if not self.changed:
         return
     db()[self.id] = self.doc
Esempio n. 6
0
 def new_session(self):
     self.doc = {"type": "session", "data":{}}
     db().create(self.doc)
Esempio n. 7
0
 def load_session(self):
     from pprint import pformat        
     try:
         self.doc = list(db().view("session/by_id", key=self.id, include_docs=True))[0].doc
     except IndexError:
         raise InvalidCookieException()