Created
February 18, 2010 10:39
-
-
Save amcgregor/307559 to your computer and use it in GitHub Desktop.
The data model for the basic WebCore Wiki example.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
"""Web application data model.""" | |
import web.core | |
import textile | |
from paste.registry import StackedObjectProxy | |
from sqlalchemy.ext.declarative import declarative_base | |
from sqlalchemy import Column, Unicode, UnicodeText, DateTime | |
__all__ = ['Base', 'prepare', 'Article'] | |
Base = declarative_base() | |
metadata = Base.metadata | |
session = StackedObjectProxy() | |
def prepare(): | |
metadata.create_all() | |
class Article(Base): | |
__tablename__ = 'articles' | |
name = Column(Unicode(250), primary_key=True) | |
content = Column(UnicodeText) | |
modified = Column(DateTime) | |
@property | |
def rendered(self): | |
@web.core.cache.cache('wiki', expires=3600) | |
def cache(name, date): | |
return textile.textile(self.content) | |
if not self.content: | |
return "<i>This article does not exist yet.</i>" | |
return cache(self.name, self.modified) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment