From 1b1c9209c26578c96668bde8aa7fae2fda85003f Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Thu, 4 Nov 2010 02:05:35 -0400 Subject: punt back to ZCML for zodb template, it will allow me to do less work to the wiki tutorial --- docs/narr/project.rst | 7 +++++-- .../paster_templates/zodb/+package+/__init__.py_tmpl | 7 ++----- pyramid/paster_templates/zodb/+package+/configure.zcml | 17 +++++++++++++++++ 3 files changed, 24 insertions(+), 7 deletions(-) create mode 100644 pyramid/paster_templates/zodb/+package+/configure.zcml 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 @@ + + + + + + + + + + -- cgit v1.2.3