Ejemplo n.º 1
0
 def _default(self, pagename="FrontPage"):
     try:
         page = DBSession.query(Page).filter_by(pagename=pagename).one()
     except InvalidRequestError:
         raise redirect("notfound", pagename=pagename)
     page = DBSession.query(Page).filter_by(pagename=pagename).one()
     content = publish_parts(page.data, writer_name="html")["html_body"]
     root = tg.url('/')
     content = wikiwords.sub(r'<a href="%s\1">\1</a>' % root, content)
     return dict(content=content, wikipage=page)
Ejemplo n.º 2
0
 def default(self, pagename="FrontPage"):
     try:
         page = DBSession.query(Page).filter_by(pagename=pagename).one()
     except InvalidRequestError:
         raise tg.redirect("notfound", pagename = pagename)
     page = DBSession.query(Page).filter_by(pagename=pagename).one()
     content = publish_parts(page.data, writer_name="html")["html_body"]
     root = tg.url('/')
     content = wikiwords.sub(r'<a href="%s\1">\1</a>' % root, content)
     return dict(content=content, wikipage=page)
Ejemplo n.º 3
0
 def pagelist(self):
     print "pagelist"
     pages = [
         page.pagename
         for page in DBSession.query(Page).order_by(Page.pagename)
     ]
     print "pages", pages
     return dict(pages=pages)
Ejemplo n.º 4
0
 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
Ejemplo n.º 5
0
 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
Ejemplo n.º 6
0
 def save(self, pagename, data, submit):
     page = DBSession.query(Page).filter_by(pagename=pagename).one()
     page.data = data
     redirect("/" + pagename)
Ejemplo n.º 7
0
 def edit(self, pagename):
     page = DBSession.query(Page).filter_by(pagename=pagename).one()
     return dict(wikipage=page)
Ejemplo n.º 8
0
 def save(self, pagename, data, submit):
     page = DBSession.query(Page).filter_by(pagename=pagename).one()
     page.data = data
     DBSession.commit() # Tells database to commit changes permanently
     redirect("/" + pagename)
Ejemplo n.º 9
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()
Ejemplo n.º 10
0
 def notfound(self, pagename):
     page = Page(pagename=pagename, data="")
     DBSession.save(page)
     DBSession.commit()
     return dict(wikipage=page)
Ejemplo n.º 11
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()
Ejemplo n.º 12
0
 def _default(self, pagename="FrontPage"):
     page = DBSession.query(Page).filter_by(pagename=pagename).one()
     content = publish_parts(page.data, writer_name="html")["html_body"]
     root = url('/')
     content = wikiwords.sub(r'<a href="%s\1">\1</a>' % root, content)
     return dict(content=content, wikipage=page)
Ejemplo 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.iteritems():
         assert_equals(getattr(obj, key), value)
Ejemplo n.º 14
0
 def tearDown(self):
     """Finish model test fixture."""
     DBSession.rollback()
Ejemplo n.º 15
0
 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)
Ejemplo n.º 16
0
 def tearDown(self):
     """Finish model test fixture."""
     DBSession.rollback()
Ejemplo n.º 17
0
 def notfound(self, pagename):
     page = Page(pagename=pagename, data="")
     DBSession.add(page)
     return dict(wikipage=page)
Ejemplo n.º 18
0
 def _default(self, pagename="FrontPage"):
     page = DBSession.query(Page).filter_by(pagename=pagename).one()
     content = publish_parts(page.data, writer_name="html")["html_body"]
     root = url('/')
     content = wikiwords.sub(r'<a href="%s\1">\1</a>' % root, content)
     return dict(content=content, wikipage=page)
Ejemplo n.º 19
0
 def pagelist(self):
     pages = [page.pagename for page in DBSession.query(Page)]
     return dict(pages=pages)
Ejemplo n.º 20
0
 def notfound(self, pagename):
     page = Page(pagename=pagename, data="")
     DBSession.add(page)
     return dict(wikipage=page)
Ejemplo n.º 21
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()
Ejemplo n.º 22
0
 def index(self, pagename="FrontPage"):
     page = DBSession.query(Page).filter_by(pagename=pagename).one()
     return dict(wikipage=page)
Ejemplo n.º 23
0
 def save(self, pagename, data, submit):
     page = DBSession.query(Page).filter_by(pagename=pagename).one()
     page.data = data
     redirect("/" + pagename)
Ejemplo n.º 24
0
 def tearDown(self):
     """Tear down test fixture for each model test method."""
     DBSession.rollback()
Ejemplo n.º 25
0
 def pagelist(self):
     pages = [page.pagename for page in DBSession.query(Page)]
     return dict(pages=pages)
Ejemplo n.º 26
0
 def index(self, pagename="FrontPage"):
     page = DBSession.query(Page).filter_by(pagename=pagename).one()
     return dict(wikipage=page)
Ejemplo n.º 27
0
 def edit(self, pagename):
     page = DBSession.query(Page).filter_by(pagename=pagename).one()
     return dict(wikipage=page)
Ejemplo n.º 28
0
 def index(self, pagename="FrontPage"):
     """Handle the front-page."""
     page = DBSession.query(Page).filter_by(pagename=pagename).one()
     return dict(wikipage=page)
Ejemplo n.º 29
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()
Ejemplo n.º 30
0
from wiki20.model import DBSession, Page, metadata
from sqlalchemy import create_engine

# Prepare the database connection
engine = create_engine("sqlite:///devdata.db", echo=True)
DBSession.configure(bind=engine)

# Create the tables
metadata.drop_all(engine)
metadata.create_all(engine)

# Create a page object and set some data
page = Page("FrontPage", "initial data")

# Save the page object to the in memory DBSession
DBSession.save(page)

# Use commit() to write all in-memory changes to the database.
DBSession.commit()