Created
November 21, 2010 09:44
-
-
Save reedobrien/708607 to your computer and use it in GitHub Desktop.
This file contains 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
## models | |
from persistent import Persistent | |
from persistent.mapping import PersistentMapping | |
class NDMWD(PersistentMapping): | |
__parent__ = None | |
__name__ = None | |
class Articles(PersistentMapping): | |
__name__ = None | |
__parent__ = None | |
class Article(Persistent): | |
def __init__(self, data): | |
self.data = data | |
def appmaker(zodb_root): | |
if not 'app_root' in zodb_root: | |
app_root = NDMWD() | |
app_root['articles'] = Articles() | |
app_root['articles'].__name__ = 'Articles' | |
app_root['articles'].__parent__ = app_root | |
frontpage = Article('This is the front page') | |
app_root['articles']['FrontPage'] = frontpage | |
frontpage = app_root['articles']['FrontPage'] | |
frontpage.__name__ = 'FrontPage' | |
frontpage.__parent__ = app_root['articles'] | |
zodb_root['app_root'] = app_root | |
import transaction | |
transaction.commit() | |
return zodb_root['app_root'] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment