def _d(self, proj_id, confirmed = False): if (confirmed == True): proj = DBSession.query(Project).get(proj_id) label = proj.label proj.delete() DBSession.flush() flash(u'Deleted Project: "$s"' % label, 'warning') redirect(url('/project/list'))
def _c(self, confirmed = False, **kw): if confirmed: project = Project() try: DBSession.add(project) DBSession.flush() except: flash(u'Could not add Project: "%s"' % (project.label), 'error') flash(u'Added Project: "%s"' % (project.label)) redirect(url('/project/' + project.id)) redirect(url('/project/'))
def get_by_label(self, label): try: page = DBSession.query(Page).filter_by(label = unicode(label)).one() except NoResultFound: flash(u'Page "%s" not found' % (label)) redirect(url('/page/new/' + label)) render = bodyMarkup return dict(page = page, render = render)
def setUp(self): """Prepare model test fixture.""" try: new_attrs = {} new_attrs.update(self.attrs) new_attrs.update(self.do_get_dependencies()) self.obj = self.klass(**new_attrs) DBSession.add(self.obj) DBSession.flush() return self.obj except: DBSession.rollback() raise
def _r(self, page_id): page = DBSession.query(Page).get(page_id) render = bodyMarkup return dict(page = page, render = render)
def search(self, **kw): pages = DBSession.query(Page).filter_by(kw) return dict(pages = pages)
def list_by_updated(self): pages = DBSession.query(Page) #pages = DBSession.query(Page).order_by(Page.updated) return dict(pages = pages)
def list_by_label(self): pages = DBSession.query(Page).order_by(Page.label) return dict(pages = pages)
def _my_update_params(self, d, nullable=False): resources = DBSession.query(Resource).all() options = [(resource.id, "%s (%s)" % (resource.label, resource.rtype)) for resource in resources] d["options"] = options return d
def by_email_address(cls, email): """Return the user object whose email address is ``email``.""" return DBSession.query(cls).filter_by(email_address=email).first()
def get(self, label): img = DBSession.query(Image).filter_by(label = unicode(label)).one() response.content_type = 'image/' + img.encoding #response.headerlist.append(('Content-Disposition', 'attachment;filename=' + image.image.filename)) return img.data
def _r(self, proj_id): project = DBSession.query(Project).get(proj_id) return dict(project = project)
def search(self, **kw): projects = DBSession.query(Project).filter_by(kw) return dict(projects = projects)
def list_by_id(self): projects = DBSession.query(Project).order_by(Project.id) return dict(projects = projects)
def tearDown(self): """Finish model test fixture.""" DBSession.rollback()
def test_query_obj(self): """Model objects can be queried""" obj = DBSession.query(self.klass).one() for key, value in self.attrs.iteritems(): assert_equals(getattr(obj, key), value)
def by_user_name(cls, username): """Return the user object whose user name is ``username``.""" return DBSession.query(cls).filter_by(user_name=username).first()
def _my_update_params(self, d, nullable=False): collections = DBSession.query(Collection).all() options = [(collection.id, "%s (%s)" % (collection.label, collection.rtype)) for collection in collections] d["options"] = options return d
def _u(self, proj_id, confirmed = False, **kw): if (confirmed == True): project = DBSession.query(Project).get(proj_id) DBSession.flush() redirect(url('/project/' + project.id))