Pastebin

Paste #2563: sqlalch

< previous paste - next paste>

Pasted by chrivers

Download View as text

From the Group handler:

    def meta_add(self, parent_id, name):
        db = self.db
        parent = db.query(Group).get(parent_id)
        group = Group(name = name)
        db.add(group)
        parent.link_add(group)
        db.commit()
        return group.id

    def meta_edit(self, id, p):
        db = self.db
        g = db.query(Group).get(id)
        g.name = p['name']
        g.parent = p['parent']
        db.commit()
        return True



## From the Schedule handler:
    def meta_add(self, props):
        db = self.db
        q = Schedule(**props)
        db.add(q)
        db.commit()
        return q.id

    def meta_edit(self, id, props):
        db = self.db
        q = db.query(Schedule).filter(Schedule.id == id).one()
        for p in props:
            setattr(q, p, props[p])
        db.commit()
        return True

    def meta_del(self, id):
        db = self.db
        q = db.query(Schedule).filter(Schedule.id == id).one()
        db.delete(q)
        db.commit()
        return True

New Paste


Do not write anything in this field if you're a human.

Go to most recent paste.