mirror of
https://github.com/wassname/pyramid_formalchemy.git
synced 2026-08-03 13:11:26 +08:00
Adding a paster template
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
from tempita import paste_script_template_renderer
|
||||
from pyramid.paster import PyramidTemplate
|
||||
|
||||
class PyramidFormAlchemyTemplate(PyramidTemplate):
|
||||
_template_dir = ('pyramid_formalchemy', 'paster_templates/pyramid_fa')
|
||||
summary = "Pyramid application template to extend other templates with "
|
||||
"formalchemy"
|
||||
template_renderer = staticmethod(paste_script_template_renderer)
|
||||
@@ -0,0 +1,23 @@
|
||||
This script does not want to tell you how your app should be set up.
|
||||
As such, it does not set an app up for you.
|
||||
|
||||
Please use this template together with other templates, like akhet,
|
||||
pyramid_routesalchemy or pyramid_alchemy.
|
||||
|
||||
To finally include FormAlchemy, modify your main method were you
|
||||
create the wsgi application, and include {{package}}.fainit to the
|
||||
configuration, like that:
|
||||
|
||||
>>> config.include("{{package}}.fainit")
|
||||
|
||||
If you are using pyramid_routesalchemy or pyramid_alchemy,
|
||||
you must modify the models.py. For FormAlchemy to be able to use the
|
||||
Model, the Model must have a constructer that can be called without
|
||||
any argument.
|
||||
So open up models.py and either remove the constructor of MyModel,
|
||||
or add default values.
|
||||
|
||||
If you are using akhet, nothing special needs to be done.
|
||||
|
||||
After this modifications, you should find the FormAlchemy Admin
|
||||
Interface under /admin
|
||||
@@ -0,0 +1,21 @@
|
||||
from {{package}} import models, forms
|
||||
|
||||
def includeme(config):
|
||||
config.include('pyramid_formalchemy')
|
||||
# Adding the jquery libraries
|
||||
config.include('fa.jquery')
|
||||
# Adding the package specific routes
|
||||
config.include('{{package}}.faroutes')
|
||||
|
||||
try:
|
||||
# pyramid_alchemy
|
||||
session_factory = models.DBSession
|
||||
except AttributeError:
|
||||
# akhet
|
||||
session_factory = models.Session
|
||||
|
||||
config.formalchemy_admin("/admin",
|
||||
models=models,
|
||||
forms=forms,
|
||||
session_factory=session_factory,
|
||||
view="fa.jquery.pyramid.ModelView")
|
||||
@@ -0,0 +1,19 @@
|
||||
from {{package}} import models
|
||||
def includeme(config):
|
||||
try:
|
||||
# pyramid_alchemy
|
||||
session_factory = models.DBSession
|
||||
except AttributeError:
|
||||
# akhet
|
||||
session_factory = models.Session
|
||||
|
||||
try:
|
||||
# Example for pyramid_routesalchemy and akhet
|
||||
from {{package}}.models import MyModel
|
||||
config.formalchemy_model("/my_model", package='{{package}}',
|
||||
model='{{package}}.models.MyModel',
|
||||
session_factory=session_factory,
|
||||
view='fa.jquery.pyramid.ModelView')
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
from formalchemy import forms
|
||||
from formalchemy import tables
|
||||
|
||||
class FieldSet(forms.FieldSet):
|
||||
pass
|
||||
|
||||
class Grid(tables.Grid):
|
||||
pass
|
||||
Reference in New Issue
Block a user