def fget(self): "Query for scheduled item by type and ORM mapped primary key." domain_class = self.get_item_domain() if domain_class is None: return None schedule_item = alchemist.Session().query(domain_class).get(self.item_id) schedule_item.__parent__ = self return schedule_item
def get_changes(auditable, *actions): """Get changelog for auditable context, filtered for actions. """ for action in actions: assert_valid_change_action(action) # lazy loading - merge to avoid sqlalchemy.orm.exc.DetachedInstanceError auditable = alchemist.Session().merge(auditable) # !+ for some reason, on event creation (with minimal log for one workflow # and one add change) the following does not pick up the one workflow change: return [c for c in auditable.changes if c.action in actions]
def active_membership(self, user_id): session = alchemist.Session() query = session.query(GroupMembership).filter( sql.and_(GroupMembership.group_id == self.group_id, GroupMembership.user_id == user_id, GroupMembership.active_p == True)) if query.count() == 0: return False else: return True