scaffold tweaks

This commit is contained in:
Lance Edgar 2012-06-11 00:55:36 -05:00
parent 6fc0a4db9a
commit 8ae8ebaa1e
5 changed files with 79 additions and 2 deletions

View file

@ -0,0 +1,13 @@
#!/usr/bin/env python
# This might be needed if running in a "baselined" virtualenv under mod_wsgi:
# (http://code.google.com/p/modwsgi/wiki/VirtualEnvironments)
# import site
# site.addsitedir('/envs/{{package}}/lib/python2.6/site-packages')
# This might be needed if running as restricted user:
# import os
# os.environ['PYTHON_EGG_CACHE'] = '/envs/{{package}}/egg-cache'
from paste.deploy import loadapp
application = loadapp('config:/envs/{{package}}/production.ini')

View file

@ -1,7 +1,16 @@
#!/usr/bin/env python
"""
``{{package}}`` -- {{project}} application
``{{package}}`` -- Package Root
"""
from edbob.db.extensions import Extension
from {{package}}._version import __version__
from {{package}}.model import *
from {{package}}.model import __all__
class {{package}}_extension(Extension):
name = '{{package}}'

View file

@ -54,7 +54,7 @@ class InitCommand(commands.Subcommand):
# Activate extensions.
activate_extension('auth')
# activate_extension('shrubbery')
activate_extension('{{package}}')
# Okay, on to bootstrapping...
session = Session()

View file

@ -0,0 +1,51 @@
#!/usr/bin/env python
"""
``{{package}}.model`` -- Schema Definition
"""
from sqlalchemy import Column, Integer, String, ForeignKey
from sqlalchemy.orm import relationship
import edbob
from edbob.db.model import Base, uuid_column
__all__ = ['Foo', 'Bar']
class Foo(Base):
"""
Represents a "foo" object.
"""
__tablename__ = 'foos'
uuid = uuid_column()
bar_uuid = Column(String(32), ForeignKey('bars.uuid'))
description = Column(String(255))
def __repr__(self):
return "<Foo: %s>" % self.description
def __str__(self):
return str(self.description or '')
class Bar(Base):
"""
Represents a "bar" object.
"""
__tablename__ = 'bars'
uuid = uuid_column()
description = Column(String(255))
foos = relationship(Foo, backref='bar')
def __repr__(self):
return "<Bar: %s>" % self.description
def __str__(self):
return str(self.description or '')

View file

@ -40,6 +40,7 @@ requires = [
# package # low high
'edbob[db,pyramid]', # 0.1a1.dev
'psycopg2', # 2.4.4
]
@ -77,6 +78,9 @@ setup(
[console_scripts]
{{package}} = {{package}}.commands:main
[edbob.db.extensions]
{{package}} = {{package}}:{{package}}_extension
[{{package}}.commands]
initialize = {{package}}.commands:InitCommand