Esempio n. 1
0
 	def getPage(self, pagename):
 		from sqlalchemy.exc import InvalidRequestError
 		try:
 			page = DBSession.query(Page).filter_by(pagename=pagename).one()
 			return page
 		except InvalidRequestError:
 			raise redirect("notfound", pagename=pagename)
Esempio n. 2
0
 	def save(self, pagename, title, data, author, tags):
 		page = Page()
 		page.pagename = pagename
 		page.title = title
 		page.data = data
 		page.date = time.strftime("%c")
 		page.author = DBSession.query(User).filter_by(user_name=author).first().user_id
 		page.tags = tags
 		return page
Esempio n. 3
0
 def setUp(self):
     """Setup test fixture for each model test method."""
     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
Esempio n. 4
0
	def getAuthor(self):
		username = str(DBSession.query(User).filter_by(user_id=self.author).one().display_name)
		return username
Esempio n. 5
0
 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()
Esempio n. 6
0
 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()
Esempio n. 7
0
 	def searchPages(self, tag):
 		pages = DBSession.query(Page).filter(Page.tags.contains(tag)).order_by(asc(Page.date))
 		return pages
Esempio n. 8
0
 	def getAllPages(self):
 		pages = DBSession.query(Page).order_by(desc(Page.date))
 		return pages
Esempio n. 9
0
 	def getAllNamePages(self):
 		pages = [page.pagename for page in DBSession.query(Page).order_by(asc(Page.date))]
 		return pages
Esempio n. 10
0
 def notfound(self, pagename):
     page = Page(pagename=pagename, data="")
     DBSession.add(page)
     return dict(wikipage=page)
Esempio n. 11
0
 def save(self, pagename, data, title, submit):
     page = DBSession.query(Page).filter_by(pagename=pagename).one()
     page.data = data
     page.title = title
     page.date = time.strftime("%c")
     redirect("/page/" + pagename)
Esempio n. 12
0
 def save_new(self, pagename, title, data, tags,submit):
     author =  request.identity['repoze.who.userid']
     pagename = title.replace(' ','')
     page = pageController.save(pagename, title, data, author, tags)
     DBSession.add(page)
     redirect("/page/" + pagename)
Esempio n. 13
0
 def test_query_obj(self):
     """Model objects can be queried"""
     obj = DBSession.query(self.klass).one()
     for key, value in self.attrs.items():
         eq_(getattr(obj, key), value)
Esempio n. 14
0
 def tearDown(self):
     """Tear down test fixture for each model test method."""
     DBSession.rollback()