diff options
| author | Chris McDonough <chrism@plope.com> | 2010-11-04 02:05:35 -0400 |
|---|---|---|
| committer | Chris McDonough <chrism@plope.com> | 2010-11-04 02:05:35 -0400 |
| commit | 1b1c9209c26578c96668bde8aa7fae2fda85003f (patch) | |
| tree | 6db5b96d14eea0a27472595f53107846319b96e8 | |
| parent | 45a63aef8277d78aad5b173329bea6a4a4bf0786 (diff) | |
| download | pyramid-1b1c9209c26578c96668bde8aa7fae2fda85003f.tar.gz pyramid-1b1c9209c26578c96668bde8aa7fae2fda85003f.tar.bz2 pyramid-1b1c9209c26578c96668bde8aa7fae2fda85003f.zip | |
punt back to ZCML for zodb template, it will allow me to do less work to the wiki tutorial
| -rw-r--r-- | docs/narr/project.rst | 7 | ||||
| -rw-r--r-- | pyramid/paster_templates/zodb/+package+/__init__.py_tmpl | 7 | ||||
| -rw-r--r-- | pyramid/paster_templates/zodb/+package+/configure.zcml | 17 |
3 files changed, 24 insertions, 7 deletions
diff --git a/docs/narr/project.rst b/docs/narr/project.rst index 08bc9e8ae..25e607174 100644 --- a/docs/narr/project.rst +++ b/docs/narr/project.rst @@ -32,7 +32,7 @@ Paster Templates Included with :mod:`pyramid` ------------------------------------------------ The convenience ``paster`` templates included with :mod:`pyramid` -differ from each other on two axes: +differ from each other on a number of axes: - the persistence mechanism they offer (no persistence mechanism, :term:`ZODB`, or :term:`SQLAlchemy`). @@ -40,6 +40,8 @@ differ from each other on two axes: - the mechanism they use to map URLs to code (:term:`traversal` or :term:`URL dispatch`). +- the type of configuration used (:term:`ZCML` vs. imperative configuration). + The included templates are these: ``pyramid_starter`` @@ -50,7 +52,8 @@ The included templates are these: :term:`ZCML` (declarative configuration). ``pyramid_zodb`` - URL mapping via :term:`traversal` and persistence via :term:`ZODB` + URL mapping via :term:`traversal` and persistence via :term:`ZODB`, using + :term:`ZCML` (declarative configuration). ``pyramid_routesalchemy`` URL mapping via :term:`URL dispatch` and persistence via diff --git a/pyramid/paster_templates/zodb/+package+/__init__.py_tmpl b/pyramid/paster_templates/zodb/+package+/__init__.py_tmpl index a87e61c7d..7b6188001 100644 --- a/pyramid/paster_templates/zodb/+package+/__init__.py_tmpl +++ b/pyramid/paster_templates/zodb/+package+/__init__.py_tmpl @@ -9,6 +9,7 @@ def app(global_config, **settings): ``paster serve``. """ zodb_uri = settings.get('zodb_uri') + zcml_file = settings.get('configure_zcml', 'configure.zcml') if zodb_uri is None: raise ValueError("No 'zodb_uri' in application configuration.") @@ -17,10 +18,6 @@ def app(global_config, **settings): return finder(request.environ) config = Configurator(root_factory=get_root, settings=settings) config.begin() - config.add_view('{{package}}.views.my_view', - context='{{package}}.models.MyModel', - renderer='{{package}}:templates/mytemplate.pt') - config.add_static_view('static', '{{package}}:templates/static') + config.load_zcml(zcml_file) config.end() return config.make_wsgi_app() - diff --git a/pyramid/paster_templates/zodb/+package+/configure.zcml b/pyramid/paster_templates/zodb/+package+/configure.zcml new file mode 100644 index 000000000..29d577d3e --- /dev/null +++ b/pyramid/paster_templates/zodb/+package+/configure.zcml @@ -0,0 +1,17 @@ +<configure xmlns="http://pylonshq.com/pyramid"> + + <!-- this must be included for the view declarations to work --> + <include package="pyramid.includes" /> + + <view + context=".models.MyModel" + view=".views.my_view" + renderer="templates/mytemplate.pt" + /> + + <static + name="static" + path="templates/static" + /> + +</configure> |
