From cad4e3c917017d43c382df213a1c045523e247b8 Mon Sep 17 00:00:00 2001 From: Gael Pasgrimaud Date: Wed, 12 Jan 2011 19:07:14 +0100 Subject: add Configurator.extend feature --- pyramid/config.py | 27 ++++++++++++++++++++ pyramid/tests/__init__.py | 4 ++- pyramid/tests/test_config.py | 59 +++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 88 insertions(+), 2 deletions(-) diff --git a/pyramid/config.py b/pyramid/config.py index 9604833f3..60197a4c6 100644 --- a/pyramid/config.py +++ b/pyramid/config.py @@ -558,6 +558,33 @@ class Configurator(object): config = self.__class__.with_context(context) c(config) + def extend(self, *callables): + _context = self._ctx + if _context is None: + _context = self._ctx = self._make_context(self.autocommit) + + klass = self.__class__ + + for c in callables: + c = self.maybe_dotted(c) + name = c.__name__ + sourcefile = inspect.getsourcefile(c) + module = inspect.getmodule(c) + spec = module.__name__ + ':' + name + if _context.processSpec(spec): + if hasattr(klass, name): + raise ConfigurationError( + "Configurator already have a method named %s" % name) + context = GroupingContextDecorator(_context) + context.basepath = os.path.dirname(sourcefile) + context.includepath = _context.includepath + (spec,) + context.package = package_of(module) + config = klass.with_context(context) + def extend_wrapper(*args, **kwargs): + c(config, *args, **kwargs) + extend_wrapper.__name__ = name + setattr(klass, name, staticmethod(extend_wrapper)) + @classmethod def with_context(cls, context): """A classmethod used by ZCML directives, diff --git a/pyramid/tests/__init__.py b/pyramid/tests/__init__.py index 5bb534f79..a62c29f47 100644 --- a/pyramid/tests/__init__.py +++ b/pyramid/tests/__init__.py @@ -1 +1,3 @@ -# package + +def dummy_extend(*args): + """used to test Configurator.extend""" diff --git a/pyramid/tests/test_config.py b/pyramid/tests/test_config.py index ac459d7e3..a16323313 100644 --- a/pyramid/tests/test_config.py +++ b/pyramid/tests/test_config.py @@ -3216,6 +3216,60 @@ class ConfiguratorTests(unittest.TestCase): for confinst in conflict: yield confinst[2] +class TestConfiguratorExtender(unittest.TestCase): + + def setUp(self): + from pyramid.config import Configurator + class Config(Configurator): pass + self.config = Config() + + def test_extend_with_dotted_name(self): + from pyramid import tests + config = self.config + context_before = config._make_context() + config._ctx = context_before + config.extend('pyramid.tests.test_config.dummy_extend') + self.assert_(hasattr(config, 'dummy_extend')) + config.dummy_extend('discrim') + context_after = config._ctx + actions = context_after.actions + self.assertEqual(len(actions), 1) + self.assertEqual( + context_after.actions[0][:3], + ('discrim', None, tests), + ) + self.assertEqual(context_after.basepath, None) + self.assertEqual(context_after.includepath, ()) + self.failUnless(context_after is context_before) + + def test_extend_with_python_callable(self): + from pyramid import tests + config = self.config + context_before = config._make_context() + config._ctx = context_before + config.extend(dummy_extend) + self.assert_(hasattr(config, 'dummy_extend')) + config.dummy_extend('discrim') + context_after = config._ctx + actions = context_after.actions + self.assertEqual(len(actions), 1) + self.assertEqual( + context_after.actions[0][:3], + ('discrim', None, tests), + ) + self.assertEqual(context_after.basepath, None) + self.assertEqual(context_after.includepath, ()) + self.failUnless(context_after is context_before) + + def test_extend_conflict(self): + from pyramid import tests + from pyramid.exceptions import ConfigurationError + config = self.config + context_before = config._make_context() + config._ctx = context_before + config.extend(dummy_extend) + self.assertRaises(ConfigurationError, config.extend, 'pyramid.tests.dummy_extend') + class TestViewDeriver(unittest.TestCase): def setUp(self): self.config = testing.setUp() @@ -4943,4 +4997,7 @@ class DummyHandler(object): # pragma: no cover def dummy_include(config): config.action('discrim', None, config.package) - + +def dummy_extend(config, discrim): + config.action(discrim, None, config.package) + -- cgit v1.2.3 From 2422ceae0750c65cc1e4ea097143f4c71fbba348 Mon Sep 17 00:00:00 2001 From: Gael Pasgrimaud Date: Wed, 12 Jan 2011 21:38:06 +0100 Subject: store extends in context and add attributes to instance --- pyramid/config.py | 19 +++++++++++++------ pyramid/tests/test_config.py | 16 +++++++++++++--- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/pyramid/config.py b/pyramid/config.py index 60197a4c6..8e709b607 100644 --- a/pyramid/config.py +++ b/pyramid/config.py @@ -275,6 +275,7 @@ class Configurator(object): default_permission=None, session_factory=None, default_view_mapper=None, + extends = None, autocommit=False, ): if package is None: @@ -302,6 +303,8 @@ class Configurator(object): session_factory=session_factory, default_view_mapper=default_view_mapper, ) + if extends: + self.extend(*extends) def _set_settings(self, mapping): settings = Settings(mapping or {}) @@ -425,6 +428,7 @@ class Configurator(object): context = PyramidConfigurationMachine() registerCommonDirectives(context) context.registry = self.registry + context.extends = [] context.autocommit = autocommit return context @@ -572,7 +576,7 @@ class Configurator(object): module = inspect.getmodule(c) spec = module.__name__ + ':' + name if _context.processSpec(spec): - if hasattr(klass, name): + if hasattr(self, name): raise ConfigurationError( "Configurator already have a method named %s" % name) context = GroupingContextDecorator(_context) @@ -580,10 +584,13 @@ class Configurator(object): context.includepath = _context.includepath + (spec,) context.package = package_of(module) config = klass.with_context(context) - def extend_wrapper(*args, **kwargs): - c(config, *args, **kwargs) - extend_wrapper.__name__ = name - setattr(klass, name, staticmethod(extend_wrapper)) + wrapped = action_method(c) + def wrapper(*args, **kwargs): + return wrapped(config, *args, **kwargs) + wrapper.__name__ = name + wrapper.__doc__ = c.__doc__ + self.__dict__[name] = wrapper + context.extends.append(c) @classmethod def with_context(cls, context): @@ -592,7 +599,7 @@ class Configurator(object): :meth:`pyramid.config.Configurator.include` to obtain a configurator with 'the right' context. Returns a new Configurator instance.""" configurator = cls(registry=context.registry, package=context.package, - autocommit=context.autocommit) + extends=context.extends, autocommit=context.autocommit) configurator._ctx = context return configurator diff --git a/pyramid/tests/test_config.py b/pyramid/tests/test_config.py index a16323313..6b5bfbf94 100644 --- a/pyramid/tests/test_config.py +++ b/pyramid/tests/test_config.py @@ -3220,8 +3220,7 @@ class TestConfiguratorExtender(unittest.TestCase): def setUp(self): from pyramid.config import Configurator - class Config(Configurator): pass - self.config = Config() + self.config = Configurator() def test_extend_with_dotted_name(self): from pyramid import tests @@ -3241,6 +3240,8 @@ class TestConfiguratorExtender(unittest.TestCase): self.assertEqual(context_after.basepath, None) self.assertEqual(context_after.includepath, ()) self.failUnless(context_after is context_before) + self.assertEqual(len(context_before.extends), 1) + self.assertEqual(context_before.extends, context_after.extends) def test_extend_with_python_callable(self): from pyramid import tests @@ -3260,9 +3261,10 @@ class TestConfiguratorExtender(unittest.TestCase): self.assertEqual(context_after.basepath, None) self.assertEqual(context_after.includepath, ()) self.failUnless(context_after is context_before) + self.assertEqual(len(context_before.extends), 1) + self.assertEqual(context_before.extends, context_after.extends) def test_extend_conflict(self): - from pyramid import tests from pyramid.exceptions import ConfigurationError config = self.config context_before = config._make_context() @@ -3270,6 +3272,14 @@ class TestConfiguratorExtender(unittest.TestCase): config.extend(dummy_extend) self.assertRaises(ConfigurationError, config.extend, 'pyramid.tests.dummy_extend') + def test_extend_no_conflict_with_two_instance(self): + from pyramid.config import Configurator + config = self.config + config.extend(dummy_extend) + config2 = Configurator() + config2.extend('pyramid.tests.dummy_extend') + self.failUnless(config._ctx.extends != config2._ctx.extends) + class TestViewDeriver(unittest.TestCase): def setUp(self): self.config = testing.setUp() -- cgit v1.2.3 From 035d033169f48d8250afafedd0a078d3e4f62922 Mon Sep 17 00:00:00 2001 From: Gael Pasgrimaud Date: Wed, 12 Jan 2011 22:01:16 +0100 Subject: improve code lines --- pyramid/config.py | 4 +--- pyramid/tests/test_config.py | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/pyramid/config.py b/pyramid/config.py index 8e709b607..468618c92 100644 --- a/pyramid/config.py +++ b/pyramid/config.py @@ -567,8 +567,6 @@ class Configurator(object): if _context is None: _context = self._ctx = self._make_context(self.autocommit) - klass = self.__class__ - for c in callables: c = self.maybe_dotted(c) name = c.__name__ @@ -583,7 +581,7 @@ class Configurator(object): context.basepath = os.path.dirname(sourcefile) context.includepath = _context.includepath + (spec,) context.package = package_of(module) - config = klass.with_context(context) + config = self.__class__.with_context(context) wrapped = action_method(c) def wrapper(*args, **kwargs): return wrapped(config, *args, **kwargs) diff --git a/pyramid/tests/test_config.py b/pyramid/tests/test_config.py index 6b5bfbf94..3fa9b954c 100644 --- a/pyramid/tests/test_config.py +++ b/pyramid/tests/test_config.py @@ -3277,8 +3277,19 @@ class TestConfiguratorExtender(unittest.TestCase): config = self.config config.extend(dummy_extend) config2 = Configurator() - config2.extend('pyramid.tests.dummy_extend') - self.failUnless(config._ctx.extends != config2._ctx.extends) + config2.extend(dummy_extend) + self.assertEqual(config._ctx.extends, config2._ctx.extends) + + def test_extend_after_with_package(self): + from pyramid import tests + config = self.config + context_before = config._make_context() + config._ctx = context_before + config.extend(dummy_extend) + config2 = config.with_package('pyramid.tests') + self.assert_(hasattr(config2, 'dummy_extend')) + self.assertEqual(len(config._ctx.extends), 1) + self.assertEqual(config._ctx.extends, config2._ctx.extends) class TestViewDeriver(unittest.TestCase): def setUp(self): -- cgit v1.2.3 From da358e42a1dda347f04d9331bb1e43f065546133 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Sun, 16 Jan 2011 01:32:29 -0500 Subject: simplify slightly --- docs/api/config.rst | 2 ++ pyramid/config.py | 60 +++++++++++++++----------------- pyramid/tests/test_config.py | 81 +++++++++++++++++++++++--------------------- 3 files changed, 73 insertions(+), 70 deletions(-) diff --git a/docs/api/config.rst b/docs/api/config.rst index 3f37e739c..51666f53f 100644 --- a/docs/api/config.rst +++ b/docs/api/config.rst @@ -76,6 +76,8 @@ .. automethod:: set_renderer_globals_factory + .. automethod:: add_directive + .. automethod:: testing_securitypolicy .. automethod:: testing_resources diff --git a/pyramid/config.py b/pyramid/config.py index 468618c92..b144b8fe3 100644 --- a/pyramid/config.py +++ b/pyramid/config.py @@ -2,6 +2,7 @@ import inspect import os import re import sys +import types import threading import traceback @@ -275,7 +276,6 @@ class Configurator(object): default_permission=None, session_factory=None, default_view_mapper=None, - extends = None, autocommit=False, ): if package is None: @@ -303,8 +303,9 @@ class Configurator(object): session_factory=session_factory, default_view_mapper=default_view_mapper, ) - if extends: - self.extend(*extends) + if hasattr(registry, '_directives'): + for name, directive in registry._directives.items(): + self.add_directive(name, directive) def _set_settings(self, mapping): settings = Settings(mapping or {}) @@ -428,7 +429,6 @@ class Configurator(object): context = PyramidConfigurationMachine() registerCommonDirectives(context) context.registry = self.registry - context.extends = [] context.autocommit = autocommit return context @@ -562,33 +562,29 @@ class Configurator(object): config = self.__class__.with_context(context) c(config) - def extend(self, *callables): - _context = self._ctx - if _context is None: - _context = self._ctx = self._make_context(self.autocommit) - - for c in callables: - c = self.maybe_dotted(c) - name = c.__name__ - sourcefile = inspect.getsourcefile(c) - module = inspect.getmodule(c) - spec = module.__name__ + ':' + name - if _context.processSpec(spec): - if hasattr(self, name): - raise ConfigurationError( - "Configurator already have a method named %s" % name) - context = GroupingContextDecorator(_context) - context.basepath = os.path.dirname(sourcefile) - context.includepath = _context.includepath + (spec,) - context.package = package_of(module) - config = self.__class__.with_context(context) - wrapped = action_method(c) - def wrapper(*args, **kwargs): - return wrapped(config, *args, **kwargs) - wrapper.__name__ = name - wrapper.__doc__ = c.__doc__ - self.__dict__[name] = wrapper - context.extends.append(c) + def add_directive(self, name, directive): + """ + Add a directive method to the configurator. + + Framework extenders can add directive methods to a configurator by + instructing their users to call ``config.add_directive('somename', + 'some.callable')``. This will make ``some.callable`` accessible as + ``config.somename``. ``some.callable`` should be a function which + accepts ``config`` as a first argument, and arbitrary positional and + keyword arguments following. It should use config.action as + necessary to perform actions. Directive methods can then be invoked + like 'built-in' directives such as ``add_view``, ``add_route``, etc. + + ``add_directive`` does not participate in conflict detection, and + later calls to ``add_directive`` will override earlier calls. + """ + c = self.maybe_dotted(directive) + if not hasattr(self.registry, '_directives'): + self.registry._directives = {} + self.registry._directives[name] = c + c = action_method(c) + m = types.MethodType(c, self, self.__class__) + setattr(self, name, m) @classmethod def with_context(cls, context): @@ -597,7 +593,7 @@ class Configurator(object): :meth:`pyramid.config.Configurator.include` to obtain a configurator with 'the right' context. Returns a new Configurator instance.""" configurator = cls(registry=context.registry, package=context.package, - extends=context.extends, autocommit=context.autocommit) + autocommit=context.autocommit) configurator._ctx = context return configurator diff --git a/pyramid/tests/test_config.py b/pyramid/tests/test_config.py index 3fa9b954c..61a665f5a 100644 --- a/pyramid/tests/test_config.py +++ b/pyramid/tests/test_config.py @@ -3216,7 +3216,7 @@ class ConfiguratorTests(unittest.TestCase): for confinst in conflict: yield confinst[2] -class TestConfiguratorExtender(unittest.TestCase): +class TestConfigurator_add_directive(unittest.TestCase): def setUp(self): from pyramid.config import Configurator @@ -3225,9 +3225,8 @@ class TestConfiguratorExtender(unittest.TestCase): def test_extend_with_dotted_name(self): from pyramid import tests config = self.config - context_before = config._make_context() - config._ctx = context_before - config.extend('pyramid.tests.test_config.dummy_extend') + config.add_directive( + 'dummy_extend', 'pyramid.tests.test_config.dummy_extend') self.assert_(hasattr(config, 'dummy_extend')) config.dummy_extend('discrim') context_after = config._ctx @@ -3237,18 +3236,12 @@ class TestConfiguratorExtender(unittest.TestCase): context_after.actions[0][:3], ('discrim', None, tests), ) - self.assertEqual(context_after.basepath, None) - self.assertEqual(context_after.includepath, ()) - self.failUnless(context_after is context_before) - self.assertEqual(len(context_before.extends), 1) - self.assertEqual(context_before.extends, context_after.extends) def test_extend_with_python_callable(self): from pyramid import tests config = self.config - context_before = config._make_context() - config._ctx = context_before - config.extend(dummy_extend) + config.add_directive( + 'dummy_extend', dummy_extend) self.assert_(hasattr(config, 'dummy_extend')) config.dummy_extend('discrim') context_after = config._ctx @@ -3258,38 +3251,47 @@ class TestConfiguratorExtender(unittest.TestCase): context_after.actions[0][:3], ('discrim', None, tests), ) - self.assertEqual(context_after.basepath, None) - self.assertEqual(context_after.includepath, ()) - self.failUnless(context_after is context_before) - self.assertEqual(len(context_before.extends), 1) - self.assertEqual(context_before.extends, context_after.extends) - def test_extend_conflict(self): - from pyramid.exceptions import ConfigurationError + def test_extend_same_name_doesnt_conflict(self): config = self.config - context_before = config._make_context() - config._ctx = context_before - config.extend(dummy_extend) - self.assertRaises(ConfigurationError, config.extend, 'pyramid.tests.dummy_extend') + config.add_directive( + 'dummy_extend', dummy_extend) + config.add_directive( + 'dummy_extend', dummy_extend2) + self.assert_(hasattr(config, 'dummy_extend')) + config.dummy_extend('discrim') + context_after = config._ctx + actions = context_after.actions + self.assertEqual(len(actions), 1) + self.assertEqual( + context_after.actions[0][:3], + ('discrim', None, config.registry), + ) - def test_extend_no_conflict_with_two_instance(self): - from pyramid.config import Configurator + def test_extend_action_method_successful(self): + from zope.configuration.config import ConfigurationConflictError config = self.config - config.extend(dummy_extend) - config2 = Configurator() - config2.extend(dummy_extend) - self.assertEqual(config._ctx.extends, config2._ctx.extends) + config.add_directive( + 'dummy_extend', dummy_extend) + config.dummy_extend('discrim') + config.dummy_extend('discrim') + self.assertRaises(ConfigurationConflictError, config.commit) - def test_extend_after_with_package(self): - from pyramid import tests + def test_directive_persists_across_configurator_creations(self): + from zope.configuration.config import GroupingContextDecorator config = self.config - context_before = config._make_context() - config._ctx = context_before - config.extend(dummy_extend) - config2 = config.with_package('pyramid.tests') - self.assert_(hasattr(config2, 'dummy_extend')) - self.assertEqual(len(config._ctx.extends), 1) - self.assertEqual(config._ctx.extends, config2._ctx.extends) + config.add_directive('dummy_extend', dummy_extend) + context = config._make_context(autocommit=False) + context = GroupingContextDecorator(context) + config2 = config.with_context(context) + config2.dummy_extend('discrim') + context_after = config2._ctx + actions = context_after.actions + self.assertEqual(len(actions), 1) + self.assertEqual( + context_after.actions[0][:3], + ('discrim', None, config2.package), + ) class TestViewDeriver(unittest.TestCase): def setUp(self): @@ -5022,3 +5024,6 @@ def dummy_include(config): def dummy_extend(config, discrim): config.action(discrim, None, config.package) +def dummy_extend2(config, discrim): + config.action(discrim, None, config.registry) + -- cgit v1.2.3 From d93ea2929c516a5bf1f2d2ad5177cf42a1fef7c0 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Sun, 16 Jan 2011 01:33:31 -0500 Subject: - Add ``add_directive`` method to configurator, which allows framework extenders to add methods to the configurator (ala ZCML directives). --- CHANGES.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.txt b/CHANGES.txt index fc1a53dd7..e00c59a1f 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -19,6 +19,9 @@ Features - Add ``charset`` attribute to ``pyramid.testing.DummyRequest`` (unconditionally ``UTF-8``). +- Add ``add_directive`` method to configurator, which allows framework + extenders to add methods to the configurator (ala ZCML directives). + Paster Templates ---------------- -- cgit v1.2.3 From 7138ca2bb09f254bce832248d6cc844edc51ed5a Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Sun, 16 Jan 2011 16:24:08 -0500 Subject: use correct rendering --- docs/glossary.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/glossary.rst b/docs/glossary.rst index a7e3a7884..93d6253cc 100644 --- a/docs/glossary.rst +++ b/docs/glossary.rst @@ -285,7 +285,7 @@ Glossary WSGI `Web Server Gateway Interface `_. This is a Python standard for connecting web applications to web servers, - similar to the concept of Java Servlets. ``pyramid`` requires + similar to the concept of Java Servlets. :app:`Pyramid` requires that your application be served as a WSGI application. middleware -- cgit v1.2.3 From 8c3c02a98f800bacb32eb205fd242ffc406a13c5 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Sun, 16 Jan 2011 16:24:13 -0500 Subject: garden --- TODO.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/TODO.txt b/TODO.txt index d055a8bd8..0455d673e 100644 --- a/TODO.txt +++ b/TODO.txt @@ -62,6 +62,9 @@ Must-Have (before 1.0) zope.configuration.config.ConfigurationExecutionError: : object of type 'NoneType' has no len() in: ('reversed.py', 14, '', "c.add_view(aview, renderer='__main__:foo.pt')") +- Fix misleading conflict error reports for static views ala + http://cluebin.appspot.com/pasted/7242843 + Should-Have ----------- -- cgit v1.2.3 From 08170aac53e6185ec68709c477e2e33436f8e38c Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Sun, 16 Jan 2011 16:33:17 -0500 Subject: - When ``Configurator.include`` is passed a *module* as an argument, it defaults to attempting to find and use a callable named ``includeme`` within that module. This makes it possible to use ``config.include('some.module')`` rather than ``config.include('some.module.somefunc')`` as long as the include function within ``some.module`` is named ``includeme``. --- CHANGES.txt | 7 +++++++ pyramid/config.py | 27 ++++++++++++++++++++++----- pyramid/tests/test_config.py | 19 +++++++++++++++++++ 3 files changed, 48 insertions(+), 5 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index e00c59a1f..27a723fb4 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -22,6 +22,13 @@ Features - Add ``add_directive`` method to configurator, which allows framework extenders to add methods to the configurator (ala ZCML directives). +- When ``Configurator.include`` is passed a *module* as an argument, it + defaults to attempting to find and use a callable named ``includeme`` + within that module. This makes it possible to use + ``config.include('some.module')`` rather than + ``config.include('some.module.somefunc')`` as long as the include function + within ``some.module`` is named ``includeme``. + Paster Templates ---------------- diff --git a/pyramid/config.py b/pyramid/config.py index b144b8fe3..9b8a7c191 100644 --- a/pyramid/config.py +++ b/pyramid/config.py @@ -511,9 +511,12 @@ class Configurator(object): Values allowed to be presented via the ``*callables`` argument to this method: any callable Python object or any :term:`dotted Python - name` which resolves to a callable Python object. + name` which resolves to a callable Python object. It may also be a + Python :term:`module`, in which case, the module will be searched for + a callable named ``includeme``, which will be treated as the + configuration callable. - For example, if the ``configure`` function below lives in a module + For example, if the ``includeme`` function below lives in a module named ``myapp.myconfig``: .. code-block:: python @@ -525,7 +528,7 @@ class Configurator(object): from pyramid.response import Response return Response('OK') - def configure(config): + def includeme(config): config.add_view(my_view) You might cause it be included within your Pyramid application like @@ -538,7 +541,19 @@ class Configurator(object): def main(global_config, **settings): config = Configurator() - config.include('myapp.myconfig.configure') + config.include('myapp.myconfig.includeme') + + Because the function is named ``includeme``, the function name can + also be omitted from the dotted name reference: + + .. code-block:: python + :linenos: + + from pyramid.config import Configurator + + def main(global_config, **settings): + config = Configurator() + config.include('myapp.myconfig') Included configuration statements will be overridden by local configuration statements if an included callable causes a @@ -551,9 +566,11 @@ class Configurator(object): for c in callables: c = self.maybe_dotted(c) - sourcefile = inspect.getsourcefile(c) module = inspect.getmodule(c) + if module is c: + c = getattr(module, 'includeme') spec = module.__name__ + ':' + c.__name__ + sourcefile = inspect.getsourcefile(c) if _context.processSpec(spec): context = GroupingContextDecorator(_context) context.basepath = os.path.dirname(sourcefile) diff --git a/pyramid/tests/test_config.py b/pyramid/tests/test_config.py index 61a665f5a..dde839aea 100644 --- a/pyramid/tests/test_config.py +++ b/pyramid/tests/test_config.py @@ -658,6 +658,23 @@ class ConfiguratorTests(unittest.TestCase): self.assertEqual(context_after.includepath, ()) self.failUnless(context_after is context_before) + def test_include_with_module_defaults_to_includeme(self): + from pyramid import tests + config = self._makeOne() + context_before = config._make_context() + config._ctx = context_before + config.include('pyramid.tests.test_config') + context_after = config._ctx + actions = context_after.actions + self.assertEqual(len(actions), 1) + self.assertEqual( + actions[0][:3], + ('discrim', None, tests), + ) + self.assertEqual(context_after.basepath, None) + self.assertEqual(context_after.includepath, ()) + self.failUnless(context_after is context_before) + def test_with_context(self): config = self._makeOne() ctx = config._make_context() @@ -5021,6 +5038,8 @@ class DummyHandler(object): # pragma: no cover def dummy_include(config): config.action('discrim', None, config.package) +includeme = dummy_include + def dummy_extend(config, discrim): config.action(discrim, None, config.package) -- cgit v1.2.3 From 1386dbaeb27765ba4838b26cd8ad6f3e4104f7de Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Sun, 16 Jan 2011 16:39:44 -0500 Subject: garden --- TODO.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/TODO.txt b/TODO.txt index 0455d673e..7a2c1d365 100644 --- a/TODO.txt +++ b/TODO.txt @@ -65,6 +65,8 @@ Must-Have (before 1.0) - Fix misleading conflict error reports for static views ala http://cluebin.appspot.com/pasted/7242843 +- Document ``add_directive``. + Should-Have ----------- -- cgit v1.2.3 From 314283a5bec3159d5a0c7e4d7028a0feecd47fa0 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Sun, 16 Jan 2011 16:39:54 -0500 Subject: document 'includeme' --- docs/narr/advconfig.rst | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/docs/narr/advconfig.rst b/docs/narr/advconfig.rst index f8b3ee191..c983bbb57 100644 --- a/docs/narr/advconfig.rst +++ b/docs/narr/advconfig.rst @@ -338,6 +338,23 @@ Instead, use :meth:`pyramid.config.Configuration.include`: Using ``include`` rather than calling the function directly will allow :ref:`automatic_conflict_resolution` to work. +:meth:`pyramid.config.Configuration.include` can also accept a :term:`module` +as an argument: + +.. code-block:: python + :linenos: + + import myapp + + config.include(myapp) + +For this to work properly, the ``myapp`` module must contain a callable with +the special name ``includeme``, which should perform configuration (like the +``add_routes`` callable we showed above as an example). + +:meth:`pyramid.config.Configuration.include` can also accept a :term:`dotted +Python name` to a function or a module. + .. note: See :ref:`the_include_tag` for a declarative alternative to :meth:`pyramid.config.Configurator.include`. -- cgit v1.2.3 From e333c2c2236cbfd11809ee393aa71be1b4846d88 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Sun, 16 Jan 2011 17:25:34 -0500 Subject: Remove configurator.add_handler, handler-related functions and methods from pyramid.view, handler ZCML directive. This functionality is to be moved to a "pyramid_handlers" package. Fix add_directive to properly persist directives across configurator creations. --- CHANGES.txt | 18 +++ docs/api/config.rst | 2 - docs/zcml.rst | 1 - pyramid/config.py | 166 +------------------ pyramid/includes/meta.zcml | 6 - pyramid/tests/test_config.py | 369 +++---------------------------------------- pyramid/tests/test_view.py | 22 --- pyramid/tests/test_zcml.py | 80 ---------- pyramid/view.py | 11 -- pyramid/zcml.py | 68 -------- 10 files changed, 44 insertions(+), 699 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 27a723fb4..6d613fa3f 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -7,6 +7,24 @@ Bug Fixes - URL Dispatch properly handles a '.*' or '*' appearing in a regex match when used inside brackets. Resolve Issue #90. +Backwards Incompatibilities +--------------------------- + +- The ``add_handler`` method of a Configurator has been removed from the + Pyramid core. Handlers are now a feature of the ``pyramid_handlers`` + package, which can be downloaded from PyPI. Documentation for the package + should be available via http://pylonsproject.org, which describes how to + get this method back after depending upon ``pyramid_handlers`` as an + ``install_requires`` dependency. + +- The ``pyramid.view.action`` decorator has been removed from the Pyramid + core. Handlers are now a feature of the ``pyramid_handlers`` package. It + should now be imported from ``pyramid_handlers`` e.g. ``from + pyramid_handlers import action``. + +- The ``handler`` ZCML directive has been removed. It is now a feature of + the ``pyramid_handlers`` package. + Features -------- diff --git a/docs/api/config.rst b/docs/api/config.rst index 51666f53f..b4f85c248 100644 --- a/docs/api/config.rst +++ b/docs/api/config.rst @@ -48,8 +48,6 @@ .. automethod:: add_translation_dirs - .. automethod:: add_handler - .. automethod:: add_view .. automethod:: derive_view diff --git a/docs/zcml.rst b/docs/zcml.rst index e5bbe5d4b..caced5c16 100644 --- a/docs/zcml.rst +++ b/docs/zcml.rst @@ -17,7 +17,6 @@ documentation is organized alphabetically by directive name. zcml/configure zcml/default_permission zcml/forbidden - zcml/handler zcml/include zcml/localenegotiator zcml/notfound diff --git a/pyramid/config.py b/pyramid/config.py index 9b8a7c191..f3323ae5d 100644 --- a/pyramid/config.py +++ b/pyramid/config.py @@ -303,9 +303,6 @@ class Configurator(object): session_factory=session_factory, default_view_mapper=default_view_mapper, ) - if hasattr(registry, '_directives'): - for name, directive in registry._directives.items(): - self.add_directive(name, directive) def _set_settings(self, mapping): settings = Settings(mapping or {}) @@ -599,9 +596,16 @@ class Configurator(object): if not hasattr(self.registry, '_directives'): self.registry._directives = {} self.registry._directives[name] = c + + def __getattr__(self, name): + # allow directive extension names to work + directives = getattr(self.registry, '_directives', {}) + c = directives.get(name) + if c is None: + raise AttributeError(name) c = action_method(c) m = types.MethodType(c, self, self.__class__) - setattr(self, name, m) + return m @classmethod def with_context(cls, context): @@ -956,136 +960,6 @@ class Configurator(object): self.manager.pop() return registry - @action_method - def add_handler(self, route_name, pattern, handler, action=None, **kw): - - """ Add a Pylons-style view handler. This function adds a - route and some number of views based on a handler object - (usually a class). - - ``route_name`` is the name of the route (to be used later in - URL generation). - - ``pattern`` is the matching pattern, - e.g. ``'/blog/{action}'``. ``pattern`` may be ``None``, in - which case the pattern of an existing route named the same as - ``route_name`` is used. If ``pattern`` is ``None`` and no - route named ``route_name`` exists, a ``ConfigurationError`` is - raised. - - ``handler`` is a dotted name of (or direct reference to) a - Python handler class, - e.g. ``'my.package.handlers.MyHandler'``. - - If ``{action}`` or ``:action`` is in - the pattern, the exposed methods of the handler will be used - as views. - - If ``action`` is passed, it will be considered the method name - of the handler to use as a view. - - Passing both ``action`` and having an ``{action}`` in the - route pattern is disallowed. - - Any extra keyword arguments are passed along to ``add_route``. - - See :ref:`views_chapter` for more explanatory documentation. - - This method returns the result of add_route.""" - handler = self.maybe_dotted(handler) - - if pattern is not None: - route = self.add_route(route_name, pattern, **kw) - else: - mapper = self.get_routes_mapper() - route = mapper.get_route(route_name) - if route is None: - raise ConfigurationError( - 'The "pattern" parameter may only be "None" when a route ' - 'with the route_name argument was previously registered. ' - 'No such route named %r exists' % route_name) - - pattern = route.pattern - - action_decorator = getattr(handler, '__action_decorator__', None) - if action_decorator is not None: - if hasattr(action_decorator, 'im_self'): - # instance methods have an im_self == None - # classmethods have an im_self == cls - # staticmethods have no im_self - # instances have no im_self - if action_decorator.im_self is not handler: - raise ConfigurationError( - 'The "__action_decorator__" attribute of a handler ' - 'must not be an instance method (must be a ' - 'staticmethod, classmethod, function, or an instance ' - 'which is a callable') - - path_has_action = ':action' in pattern or '{action}' in pattern - - if action and path_has_action: - raise ConfigurationError( - 'action= (%r) disallowed when an action is in the route ' - 'path %r' % (action, pattern)) - - if path_has_action: - autoexpose = getattr(handler, '__autoexpose__', r'[A-Za-z]+') - if autoexpose: - try: - autoexpose = re.compile(autoexpose).match - except (re.error, TypeError), why: - raise ConfigurationError(why[0]) - for method_name, method in inspect.getmembers( - handler, inspect.ismethod): - configs = getattr(method, '__exposed__', []) - if autoexpose and not configs: - if autoexpose(method_name): - configs = [{}] - for expose_config in configs: - # we don't want to mutate any dict in __exposed__, - # so we copy each - view_args = expose_config.copy() - action = view_args.pop('name', method_name) - preds = list(view_args.pop('custom_predicates', [])) - preds.append(ActionPredicate(action)) - view_args['custom_predicates'] = preds - self.add_view(view=handler, attr=method_name, - route_name=route_name, - decorator=action_decorator, **view_args) - else: - method_name = action - if method_name is None: - method_name = '__call__' - - # Scan the controller for any other methods with this action name - for meth_name, method in inspect.getmembers( - handler, inspect.ismethod): - configs = getattr(method, '__exposed__', [{}]) - for expose_config in configs: - # Don't re-register the same view if this method name is - # the action name - if meth_name == action: - continue - # We only reg a view if the name matches the action - if expose_config.get('name') != method_name: - continue - # we don't want to mutate any dict in __exposed__, - # so we copy each - view_args = expose_config.copy() - del view_args['name'] - self.add_view(view=handler, attr=meth_name, - route_name=route_name, - decorator=action_decorator, **view_args) - - # Now register the method itself - method = getattr(handler, method_name, None) - configs = getattr(method, '__exposed__', [{}]) - for expose_config in configs: - self.add_view(view=handler, attr=action, route_name=route_name, - decorator=action_decorator, **expose_config) - - return route - @action_method def add_view(self, view=None, name="", for_=None, permission=None, request_type=None, route_name=None, request_method=None, @@ -3118,30 +2992,6 @@ def requestonly(view, attr=None): return False - -class ActionPredicate(object): - action_name = 'action' - def __init__(self, action): - self.action = action - try: - self.action_re = re.compile(action + '$') - except (re.error, TypeError), why: - raise ConfigurationError(why[0]) - - def __call__(self, context, request): - matchdict = request.matchdict - if matchdict is None: - return False - action = matchdict.get(self.action_name) - if action is None: - return False - return bool(self.action_re.match(action)) - - def __hash__(self): - # allow this predicate's phash to be compared as equal to - # others that share the same action name - return hash(self.action) - class PyramidConfigurationMachine(ConfigurationMachine): autocommit = False diff --git a/pyramid/includes/meta.zcml b/pyramid/includes/meta.zcml index 9f3726cc9..e0a113ca3 100644 --- a/pyramid/includes/meta.zcml +++ b/pyramid/includes/meta.zcml @@ -34,12 +34,6 @@ handler="pyramid.zcml.route" /> - - Date: Sun, 16 Jan 2011 17:41:10 -0500 Subject: - The ``pylons_minimal``, ``pylons_basic`` and ``pylons_sqla`` paster templates were removed. Use ``pyramid_sqla`` (available from PyPI) as a generic replacement for Pylons-esque development. - All references to ``add_handler`` and the ``handler`` ZCML directive have been removed from the docs, and stubs which point to ``pylons_handlers`` package have replaced them. --- CHANGES.txt | 4 + docs/narr/advconfig.rst | 6 +- docs/narr/assets.rst | 2 +- docs/narr/declarative.rst | 40 --- docs/narr/extending.rst | 6 +- docs/narr/hooks.rst | 2 + docs/narr/project.rst | 25 +- docs/narr/viewconfig.rst | 286 +-------------------- docs/narr/views.rst | 6 +- docs/zcml/handler.rst | 158 ------------ .../pylons_basic/+package+/__init__.py_tmpl | 17 -- .../pylons_basic/+package+/handlers/__init__.py | 1 - .../pylons_basic/+package+/handlers/hello.py_tmpl | 9 - .../pylons_basic/+package+/lib/__init__.py | 1 - .../pylons_basic/+package+/lib/helpers.py | 7 - .../pylons_basic/+package+/lib/subscribers.py_tmpl | 27 -- .../pylons_basic/+package+/static/favicon.ico | Bin 1406 -> 0 bytes .../pylons_basic/+package+/static/footerbg.png | Bin 333 -> 0 bytes .../pylons_basic/+package+/static/headerbg.png | Bin 203 -> 0 bytes .../pylons_basic/+package+/static/ie6.css | 8 - .../pylons_basic/+package+/static/middlebg.png | Bin 2797 -> 0 bytes .../pylons_basic/+package+/static/pylons.css | 65 ----- .../+package+/static/pyramid-small.png | Bin 7044 -> 0 bytes .../pylons_basic/+package+/static/pyramid.png | Bin 33055 -> 0 bytes .../pylons_basic/+package+/static/transparent.gif | Bin 49 -> 0 bytes .../+package+/templates/mytemplate.mako_tmpl | 75 ------ .../pylons_basic/+package+/tests.py_tmpl | 23 -- .../paster_templates/pylons_basic/CHANGES.txt_tmpl | 4 - .../paster_templates/pylons_basic/README.txt_tmpl | 4 - .../pylons_basic/development.ini_tmpl | 50 ---- .../paster_templates/pylons_basic/setup.cfg_tmpl | 27 -- .../paster_templates/pylons_basic/setup.py_tmpl | 37 --- .../pylons_minimal/+package+/__init__.py_tmpl | 17 -- .../pylons_minimal/+package+/handlers.py_tmpl | 9 - .../pylons_minimal/+package+/static/favicon.ico | Bin 1406 -> 0 bytes .../pylons_minimal/+package+/static/footerbg.png | Bin 333 -> 0 bytes .../pylons_minimal/+package+/static/headerbg.png | Bin 203 -> 0 bytes .../pylons_minimal/+package+/static/ie6.css | 8 - .../pylons_minimal/+package+/static/middlebg.png | Bin 2797 -> 0 bytes .../pylons_minimal/+package+/static/pylons.css | 65 ----- .../+package+/static/pyramid-small.png | Bin 7044 -> 0 bytes .../pylons_minimal/+package+/static/pyramid.png | Bin 33055 -> 0 bytes .../+package+/static/transparent.gif | Bin 49 -> 0 bytes .../pylons_minimal/+package+/subscribers.py_tmpl | 24 -- .../+package+/templates/mytemplate.mako_tmpl | 75 ------ .../pylons_minimal/+package+/tests.py_tmpl | 23 -- .../pylons_minimal/CHANGES.txt_tmpl | 4 - .../pylons_minimal/README.txt_tmpl | 4 - .../pylons_minimal/development.ini_tmpl | 49 ---- .../paster_templates/pylons_minimal/setup.cfg_tmpl | 27 -- .../paster_templates/pylons_minimal/setup.py_tmpl | 37 --- .../pylons_sqla/+package+/__init__.py_tmpl | 23 -- .../pylons_sqla/+package+/handlers.py_tmpl | 12 - .../pylons_sqla/+package+/models.py | 46 ---- .../pylons_sqla/+package+/static/favicon.ico | Bin 1406 -> 0 bytes .../pylons_sqla/+package+/static/footerbg.png | Bin 333 -> 0 bytes .../pylons_sqla/+package+/static/headerbg.png | Bin 203 -> 0 bytes .../pylons_sqla/+package+/static/ie6.css | 8 - .../pylons_sqla/+package+/static/middlebg.png | Bin 2797 -> 0 bytes .../pylons_sqla/+package+/static/pylons.css | 65 ----- .../pylons_sqla/+package+/static/pyramid-small.png | Bin 7044 -> 0 bytes .../pylons_sqla/+package+/static/pyramid.png | Bin 33055 -> 0 bytes .../pylons_sqla/+package+/static/transparent.gif | Bin 49 -> 0 bytes .../pylons_sqla/+package+/subscribers.py_tmpl | 26 -- .../+package+/templates/mytemplate.mako_tmpl | 77 ------ .../pylons_sqla/+package+/tests.py_tmpl | 27 -- .../paster_templates/pylons_sqla/CHANGES.txt_tmpl | 4 - .../paster_templates/pylons_sqla/README.txt_tmpl | 4 - .../pylons_sqla/development.ini_tmpl | 60 ----- .../paster_templates/pylons_sqla/setup.cfg_tmpl | 27 -- pyramid/paster_templates/pylons_sqla/setup.py_tmpl | 49 ---- 71 files changed, 27 insertions(+), 1633 deletions(-) delete mode 100644 docs/zcml/handler.rst delete mode 100644 pyramid/paster_templates/pylons_basic/+package+/__init__.py_tmpl delete mode 100644 pyramid/paster_templates/pylons_basic/+package+/handlers/__init__.py delete mode 100644 pyramid/paster_templates/pylons_basic/+package+/handlers/hello.py_tmpl delete mode 100644 pyramid/paster_templates/pylons_basic/+package+/lib/__init__.py delete mode 100644 pyramid/paster_templates/pylons_basic/+package+/lib/helpers.py delete mode 100644 pyramid/paster_templates/pylons_basic/+package+/lib/subscribers.py_tmpl delete mode 100644 pyramid/paster_templates/pylons_basic/+package+/static/favicon.ico delete mode 100644 pyramid/paster_templates/pylons_basic/+package+/static/footerbg.png delete mode 100644 pyramid/paster_templates/pylons_basic/+package+/static/headerbg.png delete mode 100644 pyramid/paster_templates/pylons_basic/+package+/static/ie6.css delete mode 100644 pyramid/paster_templates/pylons_basic/+package+/static/middlebg.png delete mode 100644 pyramid/paster_templates/pylons_basic/+package+/static/pylons.css delete mode 100644 pyramid/paster_templates/pylons_basic/+package+/static/pyramid-small.png delete mode 100644 pyramid/paster_templates/pylons_basic/+package+/static/pyramid.png delete mode 100644 pyramid/paster_templates/pylons_basic/+package+/static/transparent.gif delete mode 100644 pyramid/paster_templates/pylons_basic/+package+/templates/mytemplate.mako_tmpl delete mode 100644 pyramid/paster_templates/pylons_basic/+package+/tests.py_tmpl delete mode 100644 pyramid/paster_templates/pylons_basic/CHANGES.txt_tmpl delete mode 100644 pyramid/paster_templates/pylons_basic/README.txt_tmpl delete mode 100644 pyramid/paster_templates/pylons_basic/development.ini_tmpl delete mode 100644 pyramid/paster_templates/pylons_basic/setup.cfg_tmpl delete mode 100644 pyramid/paster_templates/pylons_basic/setup.py_tmpl delete mode 100644 pyramid/paster_templates/pylons_minimal/+package+/__init__.py_tmpl delete mode 100644 pyramid/paster_templates/pylons_minimal/+package+/handlers.py_tmpl delete mode 100644 pyramid/paster_templates/pylons_minimal/+package+/static/favicon.ico delete mode 100644 pyramid/paster_templates/pylons_minimal/+package+/static/footerbg.png delete mode 100644 pyramid/paster_templates/pylons_minimal/+package+/static/headerbg.png delete mode 100644 pyramid/paster_templates/pylons_minimal/+package+/static/ie6.css delete mode 100644 pyramid/paster_templates/pylons_minimal/+package+/static/middlebg.png delete mode 100644 pyramid/paster_templates/pylons_minimal/+package+/static/pylons.css delete mode 100644 pyramid/paster_templates/pylons_minimal/+package+/static/pyramid-small.png delete mode 100644 pyramid/paster_templates/pylons_minimal/+package+/static/pyramid.png delete mode 100644 pyramid/paster_templates/pylons_minimal/+package+/static/transparent.gif delete mode 100644 pyramid/paster_templates/pylons_minimal/+package+/subscribers.py_tmpl delete mode 100644 pyramid/paster_templates/pylons_minimal/+package+/templates/mytemplate.mako_tmpl delete mode 100644 pyramid/paster_templates/pylons_minimal/+package+/tests.py_tmpl delete mode 100644 pyramid/paster_templates/pylons_minimal/CHANGES.txt_tmpl delete mode 100644 pyramid/paster_templates/pylons_minimal/README.txt_tmpl delete mode 100644 pyramid/paster_templates/pylons_minimal/development.ini_tmpl delete mode 100644 pyramid/paster_templates/pylons_minimal/setup.cfg_tmpl delete mode 100644 pyramid/paster_templates/pylons_minimal/setup.py_tmpl delete mode 100644 pyramid/paster_templates/pylons_sqla/+package+/__init__.py_tmpl delete mode 100644 pyramid/paster_templates/pylons_sqla/+package+/handlers.py_tmpl delete mode 100644 pyramid/paster_templates/pylons_sqla/+package+/models.py delete mode 100644 pyramid/paster_templates/pylons_sqla/+package+/static/favicon.ico delete mode 100644 pyramid/paster_templates/pylons_sqla/+package+/static/footerbg.png delete mode 100644 pyramid/paster_templates/pylons_sqla/+package+/static/headerbg.png delete mode 100644 pyramid/paster_templates/pylons_sqla/+package+/static/ie6.css delete mode 100644 pyramid/paster_templates/pylons_sqla/+package+/static/middlebg.png delete mode 100644 pyramid/paster_templates/pylons_sqla/+package+/static/pylons.css delete mode 100644 pyramid/paster_templates/pylons_sqla/+package+/static/pyramid-small.png delete mode 100644 pyramid/paster_templates/pylons_sqla/+package+/static/pyramid.png delete mode 100644 pyramid/paster_templates/pylons_sqla/+package+/static/transparent.gif delete mode 100644 pyramid/paster_templates/pylons_sqla/+package+/subscribers.py_tmpl delete mode 100644 pyramid/paster_templates/pylons_sqla/+package+/templates/mytemplate.mako_tmpl delete mode 100644 pyramid/paster_templates/pylons_sqla/+package+/tests.py_tmpl delete mode 100644 pyramid/paster_templates/pylons_sqla/CHANGES.txt_tmpl delete mode 100644 pyramid/paster_templates/pylons_sqla/README.txt_tmpl delete mode 100644 pyramid/paster_templates/pylons_sqla/development.ini_tmpl delete mode 100644 pyramid/paster_templates/pylons_sqla/setup.cfg_tmpl delete mode 100644 pyramid/paster_templates/pylons_sqla/setup.py_tmpl diff --git a/CHANGES.txt b/CHANGES.txt index 6d613fa3f..67562fbd6 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -25,6 +25,10 @@ Backwards Incompatibilities - The ``handler`` ZCML directive has been removed. It is now a feature of the ``pyramid_handlers`` package. +- The ``pylons_minimal``, ``pylons_basic`` and ``pylons_sqla`` paster + templates were removed. Use ``pyramid_sqla`` (available from PyPI) as a + generic replacement for Pylons-esque development. + Features -------- diff --git a/docs/narr/advconfig.rst b/docs/narr/advconfig.rst index c983bbb57..eb9b70b12 100644 --- a/docs/narr/advconfig.rst +++ b/docs/narr/advconfig.rst @@ -301,9 +301,6 @@ These are the methods of the configurator which provide conflict detection: Some other methods of the configurator also indirectly provide conflict detection, because they're implemented in terms of conflict-aware methods: -- :meth:`~pyramid.config.Configurator.add_handler`, a frontend for - ``add_route`` and ``add_view``. - - :meth:`~pyramid.config.Configurator.add_route` does a second type of conflict detection when a ``view`` parameter is passed (it calls ``add_view``). @@ -404,8 +401,7 @@ used, two-phase configuration is disabled, and configuration statements must be ordered in dependency order. Some configuration methods, such as -:meth:`pyramid.config.Configurator.add_route` and -:meth:`pyramid.config.Configurator.add_handler` have internal ordering +:meth:`pyramid.config.Configurator.add_route` have internal ordering constraints: they routes they imply require relative ordering. Such ordering constraints are not absolved by two-phase configuration. Routes are still added in configuration execution order. diff --git a/docs/narr/assets.rst b/docs/narr/assets.rst index f73ff231a..b1c1c419c 100644 --- a/docs/narr/assets.rst +++ b/docs/narr/assets.rst @@ -345,7 +345,7 @@ application's startup code. .. code-block:: python :linenos: - # .. every other add_route and/or add_handler declaration should come + # .. every other add_route declaration should come # before this one, as it will, by default, catch all requests config.add_route('catchall_static', '/*subpath', 'myapp.static.static_view') diff --git a/docs/narr/declarative.rst b/docs/narr/declarative.rst index 5c731ab06..5c01ff491 100644 --- a/docs/narr/declarative.rst +++ b/docs/narr/declarative.rst @@ -704,46 +704,6 @@ is the order that they appear relative to each other in the ZCML file. See :ref:`route_directive` for full ``route`` ZCML directive documentation. -.. _zcml_handler_configuration: - -Configuring a Handler via ZCML ------------------------------- - -Instead of using the imperative -:meth:`pyramid.config.Configurator.add_handler` method to add a new -route, you can alternately use :term:`ZCML`. :ref:`handler_directive` -statements in a :term:`ZCML` file used by your application is a sign that -you're using :term:`URL dispatch`. For example, the following :term:`ZCML -declaration` causes a route to be added to the application. - -.. code-block:: xml - :linenos: - - - -.. note:: - - Values prefixed with a period (``.``) within the values of ZCML attributes - such as the ``handler`` attribute of a ``handler`` directive mean - "relative to the Python package directory in which this :term:`ZCML` file - is stored". So if the above ``handler`` declaration was made inside a - ``configure.zcml`` file that lived in the ``hello`` package, you could - replace the relative ``.views.MyHandler`` with the absolute - ``hello.views.MyHandler`` Either the relative or absolute form is - functionally equivalent. It's often useful to use the relative form, in - case your package's name changes. It's also shorter to type. - -The order that the routes attached to handlers are evaluated when declarative -configuration is used is the order that they appear relative to each other in -the ZCML file. - -See :ref:`handler_directive` for full ``handler`` ZCML directive -documentation. - .. index:: triple: view; zcml; static resource diff --git a/docs/narr/extending.rst b/docs/narr/extending.rst index 524dcb2ac..eb7f0b24e 100644 --- a/docs/narr/extending.rst +++ b/docs/narr/extending.rst @@ -121,9 +121,9 @@ ZCML ```` directive). Views are declarations made using the directive). Assets are files that are accessed by :app:`Pyramid` using the :term:`pkg_resources` API such as static files and templates via a :term:`asset specification`. Other directives and configurator methods also -deal in routes, views, and assets. For example, -:meth:`pyramid.config.Configurator.add_handler` adds a single route, and some -number of views. +deal in routes, views, and assets. For example, ``add_handler`` directive of +the ``pyramid_handlers`` package adds a single route, and some number of +views. .. index:: single: extending an existing application diff --git a/docs/narr/hooks.rst b/docs/narr/hooks.rst index c12a5abb4..96515c195 100644 --- a/docs/narr/hooks.rst +++ b/docs/narr/hooks.rst @@ -611,6 +611,7 @@ A user might make use of these framework components like so: from webob import Response from pyramid.config import Configurator + import pyramid_handlers from paste.httpserver import serve class MyController(BaseController): @@ -619,6 +620,7 @@ A user might make use of these framework components like so: if __name__ == '__main__': config = Configurator() + config.include(pyramid_handlers) config.add_handler('one', '/{id}', MyController, action='index') config.add_handler('two', '/{action}/{id}', MyController) serve(config.make_wsgi_app()) diff --git a/docs/narr/project.rst b/docs/narr/project.rst index 46de560c2..a76a8ce51 100644 --- a/docs/narr/project.rst +++ b/docs/narr/project.rst @@ -30,9 +30,6 @@ and so therefore they are often referred to as "paster templates". single: pyramid_zodb paster template single: pyramid_alchemy paster template single: pyramid_routesalchemy paster template - single: pylons_minimal paster template - single: pylons_basic paster template - single: pylons_sqla paster template .. _additional_paster_templates: @@ -74,20 +71,6 @@ The included templates are these: URL mapping via :term:`traversal` and persistence via :term:`SQLAlchemy` -``pylons_minimal`` - URL mapping via :term:`URL dispatch` and Pylons-style view handlers, - minimal setup, uses ``pyramid_beaker`` as a sessioning implementation. - -``pylons_basic`` - URL mapping via :term:`URL dispatch` and Pylons-style view handlers, and - some extra functionality, uses ``pyramid_beaker`` as a sessioning - implementation. - -``pylons_sqla`` - URL mapping via :term:`URL dispatch` and Pylons-style view handlers, some - extra functionality, and SQLAlchemy set up, uses ``pyramid_beaker`` as a - sessioning implementation. - .. index:: single: creating a project single: project @@ -965,10 +948,10 @@ To this: renderer='myproject:templates/mytemplate.pt') You can then continue to add files to the ``views`` directory, and refer to -views or handler classes/functions within those files via the dotted name -passed as the first argument to ``add_view``. For example, if you added a -file named ``anothermodule.py`` to the ``views`` subdirectory, and added a -view callable named ``my_view`` to it: +view classes or functions within those files via the dotted name passed as +the first argument to ``add_view``. For example, if you added a file named +``anothermodule.py`` to the ``views`` subdirectory, and added a view callable +named ``my_view`` to it: .. code-block:: python :linenos: diff --git a/docs/narr/viewconfig.rst b/docs/narr/viewconfig.rst index c11fc1697..9b2074a70 100644 --- a/docs/narr/viewconfig.rst +++ b/docs/narr/viewconfig.rst @@ -63,14 +63,15 @@ View configuration is performed in one of these ways: :meth:`pyramid.config.Configurator.add_route` method, passing a ``view`` argument specifying a view callable. -- by using the :meth:`pyramid.config.Configurator.add_handler` against a - :term:`view handler` class (useful only for :term:`URL dispatch` - applications). +.. note:: You can also add view configuration by adding a ```` or + ```` declaration to :term:`ZCML` used by your application as per + :ref:`mapping_views_using_zcml_section`, :ref:`view_directive` or + :ref:`route_directive`. -.. note:: You can also add view configuration by adding a ````, - ```` or ```` declaration to :term:`ZCML` used by your - application as per :ref:`mapping_views_using_zcml_section`, - :ref:`view_directive`, :ref:`route_directive` or :ref:`handler_directive`. +.. note:: A package named ``pyramid_handlers`` (available from PyPI) provides + an analogue of :term:`Pylons` -style "controllers", which are a special + kind of view class which provides more automation when your application + uses :term:`URL dispatch` solely. .. _view_configuration_parameters: @@ -599,277 +600,6 @@ which is the view itself or a :term:`dotted Python name` to such an object. All other arguments are optional. See :meth:`pyramid.config.Configurator.add_view` for more information. -.. _using_add_handler: - -Handler Registration Using :meth:`~pyramid.config.Configurator.add_handler` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -:app:`Pyramid` provides the special concept of a :term:`view handler`. View -handlers are view classes that implement a number of methods, each of which -is a :term:`view callable` as a convenience for :term:`URL dispatch` users. - -.. note:: - - View handlers are *not* useful when using :term:`traversal`, only when using - :term:`url dispatch`. - -Using a view handler instead of a plain function or class :term:`view -callable` makes it unnecessary to call -:meth:`pyramid.config.Configurator.add_route` (and/or -:meth:`pyramid.config.Configurator.add_view`) "by hand" multiple times, -making it more pleasant to register a collection of views as a single class -when using :term:`url dispatch`. The view handler machinery also introduces -the concept of an ``action``, which is used as a :term:`view predicate` to -control which method of the handler is called. The method name is the -default *action name* of a handler view callable. - -The concept of a view handler is analogous to a "controller" in Pylons 1.0. - -The view handler class is initialized by :app:`Pyramid` in the same manner as -a "plain" view class. Its ``__init__`` is called with a request object (see -:ref:`class_as_view`). It implements methods, each of which is a :term:`view -callable`. When a request enters the system which corresponds with an -*action* related to one of its view callable methods, this method is called, -and it is expected to return a response. - -Here's an example view handler class: - -.. code-block:: python - :linenos: - - from pyramid.response import Response - - from pyramid.view import action - - class Hello(object): - def __init__(self, request): - self.request = request - - def index(self): - return Response('Hello world!') - - @action(renderer="mytemplate.mak") - def bye(self): - return {} - -The :class:`pyramid.view.action` decorator is used to fine-tune the view -parameters for each potential view callable which is a method of the handler. - -Handlers are added to application configuration via the -:meth:`pyramid.config.Configurator.add_handler` API. The -:meth:`~pyramid.config.Configurator.add_handler` method will scan a -:term:`view handler` class and automatically set up view configurations for -its methods that represent "auto-exposed" view callable, or those that were -decorated explicitly with the :class:`~pyramid.view.action` decorator. This -decorator is used to setup additional view configuration information for -individual methods of the class, and can be used repeatedly for a single view -method to register multiple view configurations for it. - -.. code-block:: python - :linenos: - - from myapp.handlers import Hello - config.add_handler('hello', '/hello/{action}', handler=Hello) - -This example will result in a route being added for the pattern -``/hello/{action}``, and each method of the ``Hello`` class will then be -examined to see if it should be registered as a potential view callable when -the ``/hello/{action}`` pattern matches. The value of ``{action}`` in the -route pattern will be used to determine which view should be called, and each -view in the class will be setup with a view predicate that requires a -specific ``action`` name. By default, the action name for a method of a -handler is the method name. - -If the URL was ``/hello/index``, the above example pattern would match, and, -by default, the ``index`` method of the ``Hello`` class would be called. - -Alternatively, the action can be declared specifically for a URL to be -registered for a *specific* ``action`` name: - -.. code-block:: python - :linenos: - - from myapp.handlers import Hello - config.add_handler('hello_index', '/hello/index', - handler=Hello, action='index') - -This will result one of the methods that are configured for the ``action`` of -'index' in the ``Hello`` handler class to be called. In this case the name of -the method is the same as the action name: ``index``. However, this need not -be the case, as we will see below. - -When calling :meth:`~pyramid.config.Configurator.add_handler`, an ``action`` -is required in either the route pattern or as a keyword argument, but -**cannot appear in both places**. A ``handler`` argument must also be -supplied, which can be either a :term:`asset specification` or a Python -reference to the handler class. Additional keyword arguments are passed -directly through to :meth:`pyramid.config.Configurator.add_route`. - -For example: - -.. code-block:: python - :linenos: - - config.add_handler('hello', '/hello/{action}', - handler='mypackage.handlers.MyHandler') - -Multiple :meth:`~pyramid.config.Configurator.add_handler` calls can specify -the same handler, to register specific route names for different -handler/action combinations. For example: - -.. code-block:: python - :linenos: - - config.add_handler('hello_index', '/hello/index', - handler=Hello, action='index') - config.add_handler('bye_index', '/hello/bye', - handler=Hello, action='bye') - -.. note:: - - Handler configuration may also be added to the system via :term:`ZCML` (see - :ref:`zcml_handler_configuration`). - -View Setup in the Handler Class -+++++++++++++++++++++++++++++++ - -A handler class can have a single class level attribute called -``__autoexpose__`` which should be a regular expression or the value -``None``. It's used to determine which method names will result in additional -view configurations being registered. - -When :meth:`~pyramid.config.Configurator.add_handler` runs, every method in -the handler class will be searched and a view registered if the method name -matches the ``__autoexpose__`` regular expression, or if the method was -decorated with :class:`~pyramid.view.action`. - -Every method in the handler class that has a name meeting the -``__autoexpose__`` regular expression will have a view registered for an -``action`` name corresponding to the method name. This functionality can be -disabled by setting the ``__autoexpose__`` attribute to ``None``: - -.. code-block:: python - :linenos: - - from pyramid.view import action - - class Hello(object): - __autoexpose__ = None - - def __init__(self, request): - self.request = request - - @action() - def index(self): - return Response('Hello world!') - - @action(renderer="mytemplate.mak") - def bye(self): - return {} - -With auto-expose effectively disabled, no views will be registered for a -method unless it is specifically decorated with -:class:`~pyramid.view.action`. - -Action Decorators in a Handler -++++++++++++++++++++++++++++++ - -The :class:`~pyramid.view.action` decorator registers view configuration -information on the handler method, which is used by -:meth:`~pyramid.config.Configurator.add_handler` to setup the view -configuration. - -All keyword arguments are recorded, and passed to -:meth:`~pyramid.config.Configurator.add_view`. Any valid keyword arguments -for :meth:`~pyramid.config.Configurator.add_view` can thus be used with the -:class:`~pyramid.view.action` decorator to further restrict when the view -will be called. - -One important difference is that a handler method can respond to an -``action`` name that is different from the method name by passing in a -``name`` argument. - -Example: - -.. code-block:: python - :linenos: - - from pyramid.view import action - - class Hello(object): - def __init__(self, request): - self.request = request - - @action(name='index', renderer='created.mak', request_method='POST') - def create(self): - return {} - - @action(renderer="view_all.mak", request_method='GET') - def index(self): - return {} - -This will register two views that require the ``action`` to be ``index``, -with the additional view predicate requiring a specific request method. - -It can be useful to decorate a single method multiple times with -:class:`~pyramid.view.action`. Each action decorator will register a new view -for the method. By specifying different names and renderers for each action, -the same view logic can be exposed and rendered differently on multiple URLs. - -Example: - -.. code-block:: python - :linenos: - - from pyramid.view import action - - class Hello(object): - def __init__(self, request): - self.request = request - - @action(name='home', renderer='home.mak') - @action(name='about', renderer='about.mak') - def show_template(self): - # prep some template vars - return {} - - # in the config - config.add_handler('hello', '/hello/{action}', handler=Hello) - -With this configuration, the url ``/hello/home`` will find a view -configuration that results in calling the ``show_template`` method, then -rendering the template with ``home.mak``, and the url ``/hello/about`` will -call the same method and render the ``about.mak`` template. - -Handler ``__action_decorator__`` Attribute -++++++++++++++++++++++++++++++++++++++++++ - -If a handler class has an ``__action_decorator__`` attribute, then the -value of the class attribute will be passed in as the ``decorator`` -argument every time a handler action is registered as a view callable. -This means that, like anything passed to ``add_view()`` as the -``decorator`` argument, ``__action_decorator__`` must be a callable -accepting a single argument. This argument will itself be a callable -accepting ``(context, request)`` arguments, and -``__action_decorator__`` must return a replacement callable with the -same call signature. - -Note that, since handler actions are registered as views against the -handler class and not a handler instance, any ``__action_decorator__`` -attribute must *not* be a regular instance method. Defining an -``__action_decorator__`` instance method on a handler class will -result in a :exc:`ConfigurationError`. Instead, ``__action_decorator__`` -can be any other type of callable: a staticmethod, classmethod, function, -or some sort of callable instance. - -.. note:: - - In a Pylons 1.0 controller, it was possible to override the ``__call__()`` - method, which allowed a developer to "wrap" the entire action invocation, - with a try/except or any other arbitrary code. In :app:`Pyramid`, this - can be emulated with the use of an ``__action_decorator__`` classmethod - on your handler class. - .. index:: single: resource interfaces diff --git a/docs/narr/views.rst b/docs/narr/views.rst index e8cf2f83c..6ab8e9e45 100644 --- a/docs/narr/views.rst +++ b/docs/narr/views.rst @@ -130,8 +130,10 @@ method expected to return a response, you can either: values, each pointing at a different method of the class if you'd like the class to represent a collection of related view callables. -- treat the class as a :term:`view handler` by using it as the ``handler=`` - argument of a call to :meth:`pyramid.config.Configurator.add_handler`. +.. note:: A package named ``pyramid_handlers`` (available from PyPI) provides + an analogue of :term:`Pylons` -style "controllers", which are a special + kind of view class which provides more automation when your application + uses :term:`URL dispatch` solely. .. index:: single: view calling convention diff --git a/docs/zcml/handler.rst b/docs/zcml/handler.rst deleted file mode 100644 index 64aac7e78..000000000 --- a/docs/zcml/handler.rst +++ /dev/null @@ -1,158 +0,0 @@ -.. _handler_directive: - -``handler`` ------------ - -The ``handler`` directive adds the configuration of a :term:`view handler` to -the :term:`application registry`. - -Attributes -~~~~~~~~~~ - -``route_name`` - The name of the route, e.g. ``myroute``. This attribute is required. It - must be unique among all defined handler and route names in a given - configuration. - -``pattern`` - The pattern of the route e.g. ``ideas/{idea}``. This attribute is - required. See :ref:`route_pattern_syntax` for information about the syntax - of route patterns. The name ``{action}`` is treated specially in handler - patterns. See :ref:`using_add_handler` for a discussion of how - ``{action}`` in handler patterns is treated. - -``action`` - If the action name is not specified in the ``pattern``, use this name as the - handler action (method name). - -``factory`` - The :term:`dotted Python name` to a function that will generate a - :app:`Pyramid` context object when the associated route matches. - e.g. ``mypackage.resources.MyResource``. If this argument is not - specified, a default root factory will be used. - -``xhr`` - This value should be either ``True`` or ``False``. If this value is - specified and is ``True``, the :term:`request` must possess an - ``HTTP_X_REQUESTED_WITH`` (aka ``X-Requested-With``) header for this - route to match. This is useful for detecting AJAX requests issued - from jQuery, Prototype and other Javascript libraries. If this - predicate returns false, route matching continues. - -``traverse`` - If you would like to cause the :term:`context` to be something other - than the :term:`root` object when this route matches, you can spell - a traversal pattern as the ``traverse`` argument. This traversal - pattern will be used as the traversal path: traversal will begin at - the root object implied by this route (either the global root, or - the object returned by the ``factory`` associated with this route). - - The syntax of the ``traverse`` argument is the same as it is for - ``pattern``. For example, if the ``pattern`` provided to the - ``route`` directive is ``articles/{article}/edit``, and the - ``traverse`` argument provided to the ``route`` directive is - ``/{article}``, when a request comes in that causes the route to - match in such a way that the ``article`` match value is '1' (when - the request URI is ``/articles/1/edit``), the traversal path will be - generated as ``/1``. This means that the root object's - ``__getitem__`` will be called with the name ``1`` during the - traversal phase. If the ``1`` object exists, it will become the - :term:`context` of the request. :ref:`traversal_chapter` has more - information about traversal. - - If the traversal path contains segment marker names which are not - present in the ``pattern`` argument, a runtime error will occur. - The ``traverse`` pattern should not contain segment markers that do - not exist in the ``pattern``. - - A similar combining of routing and traversal is available when a - route is matched which contains a ``*traverse`` remainder marker in - its ``pattern`` (see :ref:`using_traverse_in_a_route_pattern`). The - ``traverse`` argument to the ``route`` directive allows you to - associate route patterns with an arbitrary traversal path without - using a a ``*traverse`` remainder marker; instead you can use other - match information. - - Note that the ``traverse`` argument to the ``handler`` directive is - ignored when attached to a route that has a ``*traverse`` remainder - marker in its pattern. - -``request_method`` - A string representing an HTTP method name, e.g. ``GET``, ``POST``, - ``HEAD``, ``DELETE``, ``PUT``. If this argument is not specified, - this route will match if the request has *any* request method. If - this predicate returns false, route matching continues. - -``path_info`` - The value of this attribute represents a regular expression pattern - that will be tested against the ``PATH_INFO`` WSGI environment - variable. If the regex matches, this predicate will be true. If - this predicate returns false, route matching continues. - -``request_param`` - This value can be any string. A view declaration with this - attribute ensures that the associated route will only match when the - request has a key in the ``request.params`` dictionary (an HTTP - ``GET`` or ``POST`` variable) that has a name which matches the - supplied value. If the value supplied to the attribute has a ``=`` - sign in it, e.g. ``request_params="foo=123"``, then the key - (``foo``) must both exist in the ``request.params`` dictionary, and - the value must match the right hand side of the expression (``123``) - for the route to "match" the current request. If this predicate - returns false, route matching continues. - -``header`` - The value of this attribute represents an HTTP header name or a - header name/value pair. If the value contains a ``:`` (colon), it - will be considered a name/value pair (e.g. ``User-Agent:Mozilla/.*`` - or ``Host:localhost``). The *value* of an attribute that represent - a name/value pair should be a regular expression. If the value does - not contain a colon, the entire value will be considered to be the - header name (e.g. ``If-Modified-Since``). If the value evaluates to - a header name only without a value, the header specified by the name - must be present in the request for this predicate to be true. If - the value evaluates to a header name/value pair, the header - specified by the name must be present in the request *and* the - regular expression specified as the value must match the header - value. Whether or not the value represents a header name or a - header name/value pair, the case of the header name is not - significant. If this predicate returns false, route matching - continues. - -``accept`` - The value of this attribute represents a match query for one or more - mimetypes in the ``Accept`` HTTP request header. If this value is - specified, it must be in one of the following forms: a mimetype - match token in the form ``text/plain``, a wildcard mimetype match - token in the form ``text/*`` or a match-all wildcard mimetype match - token in the form ``*/*``. If any of the forms matches the - ``Accept`` header of the request, this predicate will be true. If - this predicate returns false, route matching continues. - -``custom_predicates`` - This value should be a sequence of references to custom predicate - callables. Use custom predicates when no set of predefined - predicates does what you need. Custom predicates can be combined - with predefined predicates as necessary. Each custom predicate - callable should accept two arguments: ``info`` and ``request`` - and should return either ``True`` or ``False`` after doing arbitrary - evaluation of the info and/or the request. If all custom and - non-custom predicate callables return ``True`` the associated route - will be considered viable for a given request. If any predicate - callable returns ``False``, route matching continues. Note that the - value ``info`` passed to a custom route predicate is a dictionary - containing matching information; see :ref:`custom_route_predicates` - for more information about ``info``. - - -Alternatives -~~~~~~~~~~~~ - -You can also add a :term:`route configuration` via: - -- Using the :meth:`pyramid.config.Configurator.add_handler` method. - -See Also -~~~~~~~~ - -See also :ref:`views_chapter`. diff --git a/pyramid/paster_templates/pylons_basic/+package+/__init__.py_tmpl b/pyramid/paster_templates/pylons_basic/+package+/__init__.py_tmpl deleted file mode 100644 index c85cc7518..000000000 --- a/pyramid/paster_templates/pylons_basic/+package+/__init__.py_tmpl +++ /dev/null @@ -1,17 +0,0 @@ -from pyramid_beaker import session_factory_from_settings -from pyramid.config import Configurator - -def main(global_config, **settings): - """ This function returns a Pyramid WSGI application. - """ - config = Configurator(settings=settings) - session_factory = session_factory_from_settings(settings) - config.set_session_factory(session_factory) - config.add_static_view('static', '{{package}}:static/') - config.add_handler('action', '/{action}', - '{{package}}.handlers.hello:HelloHandler') - config.add_handler('home', '/', '{{package}}.handlers.hello:HelloHandler', - action='index') - config.add_subscriber('{{package}}.lib.subscribers.add_renderer_globals', - 'pyramid.events.BeforeRender') - return config.make_wsgi_app() diff --git a/pyramid/paster_templates/pylons_basic/+package+/handlers/__init__.py b/pyramid/paster_templates/pylons_basic/+package+/handlers/__init__.py deleted file mode 100644 index 5bb534f79..000000000 --- a/pyramid/paster_templates/pylons_basic/+package+/handlers/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# package diff --git a/pyramid/paster_templates/pylons_basic/+package+/handlers/hello.py_tmpl b/pyramid/paster_templates/pylons_basic/+package+/handlers/hello.py_tmpl deleted file mode 100644 index 98308b384..000000000 --- a/pyramid/paster_templates/pylons_basic/+package+/handlers/hello.py_tmpl +++ /dev/null @@ -1,9 +0,0 @@ -from pyramid.view import action - -class HelloHandler(object): - def __init__(self, request): - self.request = request - - @action(renderer='mytemplate.mako') - def index(self): - return {'project':'{{project}}'} diff --git a/pyramid/paster_templates/pylons_basic/+package+/lib/__init__.py b/pyramid/paster_templates/pylons_basic/+package+/lib/__init__.py deleted file mode 100644 index 4287ca861..000000000 --- a/pyramid/paster_templates/pylons_basic/+package+/lib/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# \ No newline at end of file diff --git a/pyramid/paster_templates/pylons_basic/+package+/lib/helpers.py b/pyramid/paster_templates/pylons_basic/+package+/lib/helpers.py deleted file mode 100644 index 878b8882f..000000000 --- a/pyramid/paster_templates/pylons_basic/+package+/lib/helpers.py +++ /dev/null @@ -1,7 +0,0 @@ -"""Helper functions - -Consists of functions to typically be used within templates, but also -available to Controllers. This module is available to templates as 'h'. -""" -# Import helpers as desired, or define your own, ie: -#from webhelpers.html.tags import checkbox, password diff --git a/pyramid/paster_templates/pylons_basic/+package+/lib/subscribers.py_tmpl b/pyramid/paster_templates/pylons_basic/+package+/lib/subscribers.py_tmpl deleted file mode 100644 index 2fe053711..000000000 --- a/pyramid/paster_templates/pylons_basic/+package+/lib/subscribers.py_tmpl +++ /dev/null @@ -1,27 +0,0 @@ -from pyramid.threadlocal import get_current_request -from pyramid.exceptions import ConfigurationError -from pyramid.url import route_url -from {{package}}.lib import helpers - -def add_renderer_globals(event): - """ A subscriber to the ``pyramid.events.BeforeRender`` events. Updates - the :term:`renderer globals` with values that are familiar to Pylons - users.""" - request = event.get('request') - if request is None: - request = get_current_request() - globs = { - 'url': route_url, - 'h':helpers, - } - if request is not None: - tmpl_context = request.tmpl_context - globs['c'] = tmpl_context - globs['tmpl_context'] = tmpl_context - try: - globs['session'] = request.session - except ConfigurationError: - pass - event.update(globs) - - diff --git a/pyramid/paster_templates/pylons_basic/+package+/static/favicon.ico b/pyramid/paster_templates/pylons_basic/+package+/static/favicon.ico deleted file mode 100644 index 71f837c9e..000000000 Binary files a/pyramid/paster_templates/pylons_basic/+package+/static/favicon.ico and /dev/null differ diff --git a/pyramid/paster_templates/pylons_basic/+package+/static/footerbg.png b/pyramid/paster_templates/pylons_basic/+package+/static/footerbg.png deleted file mode 100644 index 1fbc873da..000000000 Binary files a/pyramid/paster_templates/pylons_basic/+package+/static/footerbg.png and /dev/null differ diff --git a/pyramid/paster_templates/pylons_basic/+package+/static/headerbg.png b/pyramid/paster_templates/pylons_basic/+package+/static/headerbg.png deleted file mode 100644 index 0596f2020..000000000 Binary files a/pyramid/paster_templates/pylons_basic/+package+/static/headerbg.png and /dev/null differ diff --git a/pyramid/paster_templates/pylons_basic/+package+/static/ie6.css b/pyramid/paster_templates/pylons_basic/+package+/static/ie6.css deleted file mode 100644 index b7c8493d8..000000000 --- a/pyramid/paster_templates/pylons_basic/+package+/static/ie6.css +++ /dev/null @@ -1,8 +0,0 @@ -* html img, -* html .png{position:relative;behavior:expression((this.runtimeStyle.behavior="none")&&(this.pngSet?this.pngSet=true:(this.nodeName == "IMG" && this.src.toLowerCase().indexOf('.png')>-1?(this.runtimeStyle.backgroundImage = "none", -this.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.src + "',sizingMethod='image')", -this.src = "static/transparent.gif"):(this.origBg = this.origBg? this.origBg :this.currentStyle.backgroundImage.toString().replace('url("','').replace('")',''), -this.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.origBg + "',sizingMethod='crop')", -this.runtimeStyle.backgroundImage = "none")),this.pngSet=true) -);} -#wrap{display:table;height:100%} diff --git a/pyramid/paster_templates/pylons_basic/+package+/static/middlebg.png b/pyramid/paster_templates/pylons_basic/+package+/static/middlebg.png deleted file mode 100644 index 2369cfb7d..000000000 Binary files a/pyramid/paster_templates/pylons_basic/+package+/static/middlebg.png and /dev/null differ diff --git a/pyramid/paster_templates/pylons_basic/+package+/static/pylons.css b/pyramid/paster_templates/pylons_basic/+package+/static/pylons.css deleted file mode 100644 index fd1914d8d..000000000 --- a/pyramid/paster_templates/pylons_basic/+package+/static/pylons.css +++ /dev/null @@ -1,65 +0,0 @@ -html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,font,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td{margin:0;padding:0;border:0;outline:0;font-size:100%;/* 16px */ -vertical-align:baseline;background:transparent;} -body{line-height:1;} -ol,ul{list-style:none;} -blockquote,q{quotes:none;} -blockquote:before,blockquote:after,q:before,q:after{content:'';content:none;} -:focus{outline:0;} -ins{text-decoration:none;} -del{text-decoration:line-through;} -table{border-collapse:collapse;border-spacing:0;} -sub{vertical-align:sub;font-size:smaller;line-height:normal;} -sup{vertical-align:super;font-size:smaller;line-height:normal;} -ul,menu,dir{display:block;list-style-type:disc;margin:1em 0;padding-left:40px;} -ol{display:block;list-style-type:decimal-leading-zero;margin:1em 0;padding-left:40px;} -li{display:list-item;} -ul ul,ul ol,ul dir,ul menu,ul dl,ol ul,ol ol,ol dir,ol menu,ol dl,dir ul,dir ol,dir dir,dir menu,dir dl,menu ul,menu ol,menu dir,menu menu,menu dl,dl ul,dl ol,dl dir,dl menu,dl dl{margin-top:0;margin-bottom:0;} -ol ul,ul ul,menu ul,dir ul,ol menu,ul menu,menu menu,dir menu,ol dir,ul dir,menu dir,dir dir{list-style-type:circle;} -ol ol ul,ol ul ul,ol menu ul,ol dir ul,ol ol menu,ol ul menu,ol menu menu,ol dir menu,ol ol dir,ol ul dir,ol menu dir,ol dir dir,ul ol ul,ul ul ul,ul menu ul,ul dir ul,ul ol menu,ul ul menu,ul menu menu,ul dir menu,ul ol dir,ul ul dir,ul menu dir,ul dir dir,menu ol ul,menu ul ul,menu menu ul,menu dir ul,menu ol menu,menu ul menu,menu menu menu,menu dir menu,menu ol dir,menu ul dir,menu menu dir,menu dir dir,dir ol ul,dir ul ul,dir menu ul,dir dir ul,dir ol menu,dir ul menu,dir menu menu,dir dir menu,dir ol dir,dir ul dir,dir menu dir,dir dir dir{list-style-type:square;} -.hidden{display:none;} -p{line-height:1.5em;} -h1{font-size:1.75em;line-height:1.7em;font-family:helvetica,verdana;} -h2{font-size:1.5em;line-height:1.7em;font-family:helvetica,verdana;} -h3{font-size:1.25em;line-height:1.7em;font-family:helvetica,verdana;} -h4{font-size:1em;line-height:1.7em;font-family:helvetica,verdana;} -html,body{width:100%;height:100%;} -body{margin:0;padding:0;background-color:#ffffff;position:relative;font:16px/24px "Nobile","Lucida Grande",Lucida,Verdana,sans-serif;} -a{color:#1b61d6;text-decoration:none;} -a:hover{color:#e88f00;text-decoration:underline;} -body h1, -body h2, -body h3, -body h4, -body h5, -body h6{font-family:"Neuton","Lucida Grande",Lucida,Verdana,sans-serif;font-weight:normal;color:#373839;font-style:normal;} -#wrap{min-height:100%;} -#header,#footer{width:100%;color:#ffffff;height:40px;position:absolute;text-align:center;line-height:40px;overflow:hidden;font-size:12px;vertical-align:middle;} -#header{background:#000000;top:0;font-size:14px;} -#footer{bottom:0;background:#000000 url(footerbg.png) repeat-x 0 top;position:relative;margin-top:-40px;clear:both;} -.header,.footer{width:750px;margin-right:auto;margin-left:auto;} -.wrapper{width:100%} -#top,#top-small,#bottom{width:100%;} -#top{color:#000000;height:230px;background:#ffffff url(headerbg.png) repeat-x 0 top;position:relative;} -#top-small{color:#000000;height:60px;background:#ffffff url(headerbg.png) repeat-x 0 top;position:relative;} -#bottom{color:#222;background-color:#ffffff;} -.top,.top-small,.middle,.bottom{width:750px;margin-right:auto;margin-left:auto;} -.top{padding-top:40px;} -.top-small{padding-top:10px;} -#middle{width:100%;height:100px;background:url(middlebg.png) repeat-x;border-top:2px solid #ffffff;border-bottom:2px solid #b2b2b2;} -.app-welcome{margin-top:25px;} -.app-name{color:#000000;font-weight:bold;} -.bottom{padding-top:50px;} -#left{width:350px;float:left;padding-right:25px;} -#right{width:350px;float:right;padding-left:25px;} -.align-left{text-align:left;} -.align-right{text-align:right;} -.align-center{text-align:center;} -ul.links{margin:0;padding:0;} -ul.links li{list-style-type:none;font-size:14px;} -form{border-style:none;} -fieldset{border-style:none;} -input{color:#222;border:1px solid #ccc;font-family:sans-serif;font-size:12px;line-height:16px;} -input[type=text],input[type=password]{width:205px;} -input[type=submit]{background-color:#ddd;font-weight:bold;} -/*Opera Fix*/ -body:before{content:"";height:100%;float:left;width:0;margin-top:-32767px;} diff --git a/pyramid/paster_templates/pylons_basic/+package+/static/pyramid-small.png b/pyramid/paster_templates/pylons_basic/+package+/static/pyramid-small.png deleted file mode 100644 index a5bc0ade7..000000000 Binary files a/pyramid/paster_templates/pylons_basic/+package+/static/pyramid-small.png and /dev/null differ diff --git a/pyramid/paster_templates/pylons_basic/+package+/static/pyramid.png b/pyramid/paster_templates/pylons_basic/+package+/static/pyramid.png deleted file mode 100644 index 347e05549..000000000 Binary files a/pyramid/paster_templates/pylons_basic/+package+/static/pyramid.png and /dev/null differ diff --git a/pyramid/paster_templates/pylons_basic/+package+/static/transparent.gif b/pyramid/paster_templates/pylons_basic/+package+/static/transparent.gif deleted file mode 100644 index 0341802e5..000000000 Binary files a/pyramid/paster_templates/pylons_basic/+package+/static/transparent.gif and /dev/null differ diff --git a/pyramid/paster_templates/pylons_basic/+package+/templates/mytemplate.mako_tmpl b/pyramid/paster_templates/pylons_basic/+package+/templates/mytemplate.mako_tmpl deleted file mode 100644 index e3fa39f28..000000000 --- a/pyramid/paster_templates/pylons_basic/+package+/templates/mytemplate.mako_tmpl +++ /dev/null @@ -1,75 +0,0 @@ - - - - The Pyramid Web Application Development Framework - - - - - - - - - -
-
-
-
pyramid
-
-
-
-
-

- Welcome to ${project}, an application generated by
- the Pyramid web application development framework. -

-
-
-
-
-
-

Search documentation

-
- - -
-
- -
-
-
- - - \ No newline at end of file diff --git a/pyramid/paster_templates/pylons_basic/+package+/tests.py_tmpl b/pyramid/paster_templates/pylons_basic/+package+/tests.py_tmpl deleted file mode 100644 index 7fd0404f0..000000000 --- a/pyramid/paster_templates/pylons_basic/+package+/tests.py_tmpl +++ /dev/null @@ -1,23 +0,0 @@ -import unittest - -from pyramid import testing - -class HelloHandlerTests(unittest.TestCase): - def setUp(self): - self.config = testing.setUp() - - def tearDown(self): - testing.tearDown() - - def _makeOne(self, request): - from {{package}}.handlers.hello import HelloHandler - return HelloHandler(request) - - def test_index(self): - request = DummyRequest() - controller = self._makeOne(request) - info = controller.index() - self.assertEqual(info['project'], '{{project}}') - -class DummyRequest(object): - pass diff --git a/pyramid/paster_templates/pylons_basic/CHANGES.txt_tmpl b/pyramid/paster_templates/pylons_basic/CHANGES.txt_tmpl deleted file mode 100644 index 35a34f332..000000000 --- a/pyramid/paster_templates/pylons_basic/CHANGES.txt_tmpl +++ /dev/null @@ -1,4 +0,0 @@ -0.0 ---- - -- Initial version diff --git a/pyramid/paster_templates/pylons_basic/README.txt_tmpl b/pyramid/paster_templates/pylons_basic/README.txt_tmpl deleted file mode 100644 index 0ddebfc3e..000000000 --- a/pyramid/paster_templates/pylons_basic/README.txt_tmpl +++ /dev/null @@ -1,4 +0,0 @@ -{{project}} README - - - diff --git a/pyramid/paster_templates/pylons_basic/development.ini_tmpl b/pyramid/paster_templates/pylons_basic/development.ini_tmpl deleted file mode 100644 index 186c78862..000000000 --- a/pyramid/paster_templates/pylons_basic/development.ini_tmpl +++ /dev/null @@ -1,50 +0,0 @@ -[app:{{project}}] -use = egg:{{project}} -reload_templates = true -mako.directories = {{package}}:templates -debug_authorization = false -debug_notfound = false -debug_routematch = false -debug_templates = true -default_locale_name = en -session.type = file -session.data_dir = %(here)s/data/sessions/data -session.lock_dir = %(here)s/data/sessions/lock -session.key = {{project}} -session.secret = {{random_string}} - -[pipeline:main] -pipeline = - egg:WebError#evalerror - {{project}} - -[server:main] -use = egg:Paste#http -host = 0.0.0.0 -port = 6543 - -# Begin logging configuration - -[loggers] -keys = root - -[handlers] -keys = console - -[formatters] -keys = generic - -[logger_root] -level = INFO -handlers = console - -[handler_console] -class = StreamHandler -args = (sys.stderr,) -level = NOTSET -formatter = generic - -[formatter_generic] -format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s - -# End logging configuration diff --git a/pyramid/paster_templates/pylons_basic/setup.cfg_tmpl b/pyramid/paster_templates/pylons_basic/setup.cfg_tmpl deleted file mode 100644 index 5bec29823..000000000 --- a/pyramid/paster_templates/pylons_basic/setup.cfg_tmpl +++ /dev/null @@ -1,27 +0,0 @@ -[nosetests] -match=^test -nocapture=1 -cover-package={{package}} -with-coverage=1 -cover-erase=1 - -[compile_catalog] -directory = {{package}}/locale -domain = {{project}} -statistics = true - -[extract_messages] -add_comments = TRANSLATORS: -output_file = {{package}}/locale/{{project}}.pot -width = 80 - -[init_catalog] -domain = {{project}} -input_file = {{package}}/locale/{{project}}.pot -output_dir = {{package}}/locale - -[update_catalog] -domain = {{project}} -input_file = {{package}}/locale/{{project}}.pot -output_dir = {{package}}/locale -previous = true diff --git a/pyramid/paster_templates/pylons_basic/setup.py_tmpl b/pyramid/paster_templates/pylons_basic/setup.py_tmpl deleted file mode 100644 index 2ca5de696..000000000 --- a/pyramid/paster_templates/pylons_basic/setup.py_tmpl +++ /dev/null @@ -1,37 +0,0 @@ -import os - -from setuptools import setup, find_packages - -here = os.path.abspath(os.path.dirname(__file__)) -README = open(os.path.join(here, 'README.txt')).read() -CHANGES = open(os.path.join(here, 'CHANGES.txt')).read() - -requires = ['pyramid', 'pyramid_beaker', 'WebError'] - -setup(name='{{project}}', - version='0.0', - description='{{project}}', - long_description=README + '\n\n' + CHANGES, - classifiers=[ - "Programming Language :: Python", - "Framework :: Pylons", - "Topic :: Internet :: WWW/HTTP", - "Topic :: Internet :: WWW/HTTP :: WSGI :: Application", - ], - author='', - author_email='', - url='', - keywords='web pylons', - packages=find_packages(), - include_package_data=True, - zip_safe=False, - install_requires=requires, - tests_require=requires, - test_suite="{{package}}", - entry_points = """\ - [paste.app_factory] - main = {{package}}:main - """, - paster_plugins=['pyramid'], - ) - diff --git a/pyramid/paster_templates/pylons_minimal/+package+/__init__.py_tmpl b/pyramid/paster_templates/pylons_minimal/+package+/__init__.py_tmpl deleted file mode 100644 index 21512a897..000000000 --- a/pyramid/paster_templates/pylons_minimal/+package+/__init__.py_tmpl +++ /dev/null @@ -1,17 +0,0 @@ -from pyramid_beaker import session_factory_from_settings -from pyramid.config import Configurator - -def main(global_config, **settings): - """ This function returns a Pyramid WSGI application. - """ - config = Configurator(settings=settings) - session_factory = session_factory_from_settings(settings) - config.set_session_factory(session_factory) - config.add_static_view('static', '{{package}}:static/') - config.add_handler('action', '/{action}', '{{package}}.handlers:MyHandler') - config.add_handler('home', '/', '{{package}}.handlers:MyHandler', - action='index') - config.add_subscriber('{{package}}.subscribers.add_renderer_globals', - 'pyramid.events.BeforeRender') - return config.make_wsgi_app() - diff --git a/pyramid/paster_templates/pylons_minimal/+package+/handlers.py_tmpl b/pyramid/paster_templates/pylons_minimal/+package+/handlers.py_tmpl deleted file mode 100644 index 0a97a3348..000000000 --- a/pyramid/paster_templates/pylons_minimal/+package+/handlers.py_tmpl +++ /dev/null @@ -1,9 +0,0 @@ -from pyramid.view import action - -class MyHandler(object): - def __init__(self, request): - self.request = request - - @action(renderer='mytemplate.mako') - def index(self): - return {'project':'{{project}}'} diff --git a/pyramid/paster_templates/pylons_minimal/+package+/static/favicon.ico b/pyramid/paster_templates/pylons_minimal/+package+/static/favicon.ico deleted file mode 100644 index 71f837c9e..000000000 Binary files a/pyramid/paster_templates/pylons_minimal/+package+/static/favicon.ico and /dev/null differ diff --git a/pyramid/paster_templates/pylons_minimal/+package+/static/footerbg.png b/pyramid/paster_templates/pylons_minimal/+package+/static/footerbg.png deleted file mode 100644 index 1fbc873da..000000000 Binary files a/pyramid/paster_templates/pylons_minimal/+package+/static/footerbg.png and /dev/null differ diff --git a/pyramid/paster_templates/pylons_minimal/+package+/static/headerbg.png b/pyramid/paster_templates/pylons_minimal/+package+/static/headerbg.png deleted file mode 100644 index 0596f2020..000000000 Binary files a/pyramid/paster_templates/pylons_minimal/+package+/static/headerbg.png and /dev/null differ diff --git a/pyramid/paster_templates/pylons_minimal/+package+/static/ie6.css b/pyramid/paster_templates/pylons_minimal/+package+/static/ie6.css deleted file mode 100644 index b7c8493d8..000000000 --- a/pyramid/paster_templates/pylons_minimal/+package+/static/ie6.css +++ /dev/null @@ -1,8 +0,0 @@ -* html img, -* html .png{position:relative;behavior:expression((this.runtimeStyle.behavior="none")&&(this.pngSet?this.pngSet=true:(this.nodeName == "IMG" && this.src.toLowerCase().indexOf('.png')>-1?(this.runtimeStyle.backgroundImage = "none", -this.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.src + "',sizingMethod='image')", -this.src = "static/transparent.gif"):(this.origBg = this.origBg? this.origBg :this.currentStyle.backgroundImage.toString().replace('url("','').replace('")',''), -this.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.origBg + "',sizingMethod='crop')", -this.runtimeStyle.backgroundImage = "none")),this.pngSet=true) -);} -#wrap{display:table;height:100%} diff --git a/pyramid/paster_templates/pylons_minimal/+package+/static/middlebg.png b/pyramid/paster_templates/pylons_minimal/+package+/static/middlebg.png deleted file mode 100644 index 2369cfb7d..000000000 Binary files a/pyramid/paster_templates/pylons_minimal/+package+/static/middlebg.png and /dev/null differ diff --git a/pyramid/paster_templates/pylons_minimal/+package+/static/pylons.css b/pyramid/paster_templates/pylons_minimal/+package+/static/pylons.css deleted file mode 100644 index fd1914d8d..000000000 --- a/pyramid/paster_templates/pylons_minimal/+package+/static/pylons.css +++ /dev/null @@ -1,65 +0,0 @@ -html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,font,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td{margin:0;padding:0;border:0;outline:0;font-size:100%;/* 16px */ -vertical-align:baseline;background:transparent;} -body{line-height:1;} -ol,ul{list-style:none;} -blockquote,q{quotes:none;} -blockquote:before,blockquote:after,q:before,q:after{content:'';content:none;} -:focus{outline:0;} -ins{text-decoration:none;} -del{text-decoration:line-through;} -table{border-collapse:collapse;border-spacing:0;} -sub{vertical-align:sub;font-size:smaller;line-height:normal;} -sup{vertical-align:super;font-size:smaller;line-height:normal;} -ul,menu,dir{display:block;list-style-type:disc;margin:1em 0;padding-left:40px;} -ol{display:block;list-style-type:decimal-leading-zero;margin:1em 0;padding-left:40px;} -li{display:list-item;} -ul ul,ul ol,ul dir,ul menu,ul dl,ol ul,ol ol,ol dir,ol menu,ol dl,dir ul,dir ol,dir dir,dir menu,dir dl,menu ul,menu ol,menu dir,menu menu,menu dl,dl ul,dl ol,dl dir,dl menu,dl dl{margin-top:0;margin-bottom:0;} -ol ul,ul ul,menu ul,dir ul,ol menu,ul menu,menu menu,dir menu,ol dir,ul dir,menu dir,dir dir{list-style-type:circle;} -ol ol ul,ol ul ul,ol menu ul,ol dir ul,ol ol menu,ol ul menu,ol menu menu,ol dir menu,ol ol dir,ol ul dir,ol menu dir,ol dir dir,ul ol ul,ul ul ul,ul menu ul,ul dir ul,ul ol menu,ul ul menu,ul menu menu,ul dir menu,ul ol dir,ul ul dir,ul menu dir,ul dir dir,menu ol ul,menu ul ul,menu menu ul,menu dir ul,menu ol menu,menu ul menu,menu menu menu,menu dir menu,menu ol dir,menu ul dir,menu menu dir,menu dir dir,dir ol ul,dir ul ul,dir menu ul,dir dir ul,dir ol menu,dir ul menu,dir menu menu,dir dir menu,dir ol dir,dir ul dir,dir menu dir,dir dir dir{list-style-type:square;} -.hidden{display:none;} -p{line-height:1.5em;} -h1{font-size:1.75em;line-height:1.7em;font-family:helvetica,verdana;} -h2{font-size:1.5em;line-height:1.7em;font-family:helvetica,verdana;} -h3{font-size:1.25em;line-height:1.7em;font-family:helvetica,verdana;} -h4{font-size:1em;line-height:1.7em;font-family:helvetica,verdana;} -html,body{width:100%;height:100%;} -body{margin:0;padding:0;background-color:#ffffff;position:relative;font:16px/24px "Nobile","Lucida Grande",Lucida,Verdana,sans-serif;} -a{color:#1b61d6;text-decoration:none;} -a:hover{color:#e88f00;text-decoration:underline;} -body h1, -body h2, -body h3, -body h4, -body h5, -body h6{font-family:"Neuton","Lucida Grande",Lucida,Verdana,sans-serif;font-weight:normal;color:#373839;font-style:normal;} -#wrap{min-height:100%;} -#header,#footer{width:100%;color:#ffffff;height:40px;position:absolute;text-align:center;line-height:40px;overflow:hidden;font-size:12px;vertical-align:middle;} -#header{background:#000000;top:0;font-size:14px;} -#footer{bottom:0;background:#000000 url(footerbg.png) repeat-x 0 top;position:relative;margin-top:-40px;clear:both;} -.header,.footer{width:750px;margin-right:auto;margin-left:auto;} -.wrapper{width:100%} -#top,#top-small,#bottom{width:100%;} -#top{color:#000000;height:230px;background:#ffffff url(headerbg.png) repeat-x 0 top;position:relative;} -#top-small{color:#000000;height:60px;background:#ffffff url(headerbg.png) repeat-x 0 top;position:relative;} -#bottom{color:#222;background-color:#ffffff;} -.top,.top-small,.middle,.bottom{width:750px;margin-right:auto;margin-left:auto;} -.top{padding-top:40px;} -.top-small{padding-top:10px;} -#middle{width:100%;height:100px;background:url(middlebg.png) repeat-x;border-top:2px solid #ffffff;border-bottom:2px solid #b2b2b2;} -.app-welcome{margin-top:25px;} -.app-name{color:#000000;font-weight:bold;} -.bottom{padding-top:50px;} -#left{width:350px;float:left;padding-right:25px;} -#right{width:350px;float:right;padding-left:25px;} -.align-left{text-align:left;} -.align-right{text-align:right;} -.align-center{text-align:center;} -ul.links{margin:0;padding:0;} -ul.links li{list-style-type:none;font-size:14px;} -form{border-style:none;} -fieldset{border-style:none;} -input{color:#222;border:1px solid #ccc;font-family:sans-serif;font-size:12px;line-height:16px;} -input[type=text],input[type=password]{width:205px;} -input[type=submit]{background-color:#ddd;font-weight:bold;} -/*Opera Fix*/ -body:before{content:"";height:100%;float:left;width:0;margin-top:-32767px;} diff --git a/pyramid/paster_templates/pylons_minimal/+package+/static/pyramid-small.png b/pyramid/paster_templates/pylons_minimal/+package+/static/pyramid-small.png deleted file mode 100644 index a5bc0ade7..000000000 Binary files a/pyramid/paster_templates/pylons_minimal/+package+/static/pyramid-small.png and /dev/null differ diff --git a/pyramid/paster_templates/pylons_minimal/+package+/static/pyramid.png b/pyramid/paster_templates/pylons_minimal/+package+/static/pyramid.png deleted file mode 100644 index 347e05549..000000000 Binary files a/pyramid/paster_templates/pylons_minimal/+package+/static/pyramid.png and /dev/null differ diff --git a/pyramid/paster_templates/pylons_minimal/+package+/static/transparent.gif b/pyramid/paster_templates/pylons_minimal/+package+/static/transparent.gif deleted file mode 100644 index 0341802e5..000000000 Binary files a/pyramid/paster_templates/pylons_minimal/+package+/static/transparent.gif and /dev/null differ diff --git a/pyramid/paster_templates/pylons_minimal/+package+/subscribers.py_tmpl b/pyramid/paster_templates/pylons_minimal/+package+/subscribers.py_tmpl deleted file mode 100644 index ace5df3de..000000000 --- a/pyramid/paster_templates/pylons_minimal/+package+/subscribers.py_tmpl +++ /dev/null @@ -1,24 +0,0 @@ -from pyramid.threadlocal import get_current_request -from pyramid.exceptions import ConfigurationError -from pyramid.url import route_url - -def add_renderer_globals(event): - """ A subscriber to the ``pyramid.events.BeforeRender`` events. Updates - the :term:`renderer globals` with values that are familiar to Pylons - users.""" - request = event.get('request') - if request is None: - request = get_current_request() - globs = { - 'url': route_url, - 'h':None, - } - if request is not None: - tmpl_context = request.tmpl_context - globs['c'] = tmpl_context - globs['tmpl_context'] = tmpl_context - try: - globs['session'] = request.session - except ConfigurationError: - pass - event.update(globs) diff --git a/pyramid/paster_templates/pylons_minimal/+package+/templates/mytemplate.mako_tmpl b/pyramid/paster_templates/pylons_minimal/+package+/templates/mytemplate.mako_tmpl deleted file mode 100644 index e3fa39f28..000000000 --- a/pyramid/paster_templates/pylons_minimal/+package+/templates/mytemplate.mako_tmpl +++ /dev/null @@ -1,75 +0,0 @@ - - - - The Pyramid Web Application Development Framework - - - - - - - - - -
-
-
-
pyramid
-
-
-
-
-

- Welcome to ${project}, an application generated by
- the Pyramid web application development framework. -

-
-
-
-
-
-

Search documentation

-
- - -
-
- -
-
-
- - - \ No newline at end of file diff --git a/pyramid/paster_templates/pylons_minimal/+package+/tests.py_tmpl b/pyramid/paster_templates/pylons_minimal/+package+/tests.py_tmpl deleted file mode 100644 index d29d32772..000000000 --- a/pyramid/paster_templates/pylons_minimal/+package+/tests.py_tmpl +++ /dev/null @@ -1,23 +0,0 @@ -import unittest - -from pyramid import testing - -class MyControllerTests(unittest.TestCase): - def setUp(self): - self.config = testing.setUp() - - def tearDown(self): - testing.tearDown() - - def _makeOne(self, request): - from {{package}}.handlers import MyHandler - return MyHandler(request) - - def test_index(self): - request = DummyRequest() - controller = self._makeOne(request) - info = controller.index() - self.assertEqual(info['project'], '{{project}}') - -class DummyRequest(object): - pass diff --git a/pyramid/paster_templates/pylons_minimal/CHANGES.txt_tmpl b/pyramid/paster_templates/pylons_minimal/CHANGES.txt_tmpl deleted file mode 100644 index 35a34f332..000000000 --- a/pyramid/paster_templates/pylons_minimal/CHANGES.txt_tmpl +++ /dev/null @@ -1,4 +0,0 @@ -0.0 ---- - -- Initial version diff --git a/pyramid/paster_templates/pylons_minimal/README.txt_tmpl b/pyramid/paster_templates/pylons_minimal/README.txt_tmpl deleted file mode 100644 index 0ddebfc3e..000000000 --- a/pyramid/paster_templates/pylons_minimal/README.txt_tmpl +++ /dev/null @@ -1,4 +0,0 @@ -{{project}} README - - - diff --git a/pyramid/paster_templates/pylons_minimal/development.ini_tmpl b/pyramid/paster_templates/pylons_minimal/development.ini_tmpl deleted file mode 100644 index b8844b2fc..000000000 --- a/pyramid/paster_templates/pylons_minimal/development.ini_tmpl +++ /dev/null @@ -1,49 +0,0 @@ -[app:{{project}}] -use = egg:{{project}} -reload_templates = true -mako.directories = {{package}}:templates -debug_authorization = false -debug_notfound = false -debug_routematch = false -debug_templates = true -default_locale_name = en -session.type = file -session.data_dir = %(here)s/data/sessions/data -session.lock_dir = %(here)s/data/sessions/lock -session.key = {{project}} -session.secret = {{random_string}} - -[pipeline:main] -pipeline = egg:WebError#evalerror - {{project}} - -[server:main] -use = egg:Paste#http -host = 0.0.0.0 -port = 6543 - -# Begin logging configuration - -[loggers] -keys = root - -[handlers] -keys = console - -[formatters] -keys = generic - -[logger_root] -level = INFO -handlers = console - -[handler_console] -class = StreamHandler -args = (sys.stderr,) -level = NOTSET -formatter = generic - -[formatter_generic] -format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s - -# End logging configuration diff --git a/pyramid/paster_templates/pylons_minimal/setup.cfg_tmpl b/pyramid/paster_templates/pylons_minimal/setup.cfg_tmpl deleted file mode 100644 index 5bec29823..000000000 --- a/pyramid/paster_templates/pylons_minimal/setup.cfg_tmpl +++ /dev/null @@ -1,27 +0,0 @@ -[nosetests] -match=^test -nocapture=1 -cover-package={{package}} -with-coverage=1 -cover-erase=1 - -[compile_catalog] -directory = {{package}}/locale -domain = {{project}} -statistics = true - -[extract_messages] -add_comments = TRANSLATORS: -output_file = {{package}}/locale/{{project}}.pot -width = 80 - -[init_catalog] -domain = {{project}} -input_file = {{package}}/locale/{{project}}.pot -output_dir = {{package}}/locale - -[update_catalog] -domain = {{project}} -input_file = {{package}}/locale/{{project}}.pot -output_dir = {{package}}/locale -previous = true diff --git a/pyramid/paster_templates/pylons_minimal/setup.py_tmpl b/pyramid/paster_templates/pylons_minimal/setup.py_tmpl deleted file mode 100644 index 2ca5de696..000000000 --- a/pyramid/paster_templates/pylons_minimal/setup.py_tmpl +++ /dev/null @@ -1,37 +0,0 @@ -import os - -from setuptools import setup, find_packages - -here = os.path.abspath(os.path.dirname(__file__)) -README = open(os.path.join(here, 'README.txt')).read() -CHANGES = open(os.path.join(here, 'CHANGES.txt')).read() - -requires = ['pyramid', 'pyramid_beaker', 'WebError'] - -setup(name='{{project}}', - version='0.0', - description='{{project}}', - long_description=README + '\n\n' + CHANGES, - classifiers=[ - "Programming Language :: Python", - "Framework :: Pylons", - "Topic :: Internet :: WWW/HTTP", - "Topic :: Internet :: WWW/HTTP :: WSGI :: Application", - ], - author='', - author_email='', - url='', - keywords='web pylons', - packages=find_packages(), - include_package_data=True, - zip_safe=False, - install_requires=requires, - tests_require=requires, - test_suite="{{package}}", - entry_points = """\ - [paste.app_factory] - main = {{package}}:main - """, - paster_plugins=['pyramid'], - ) - diff --git a/pyramid/paster_templates/pylons_sqla/+package+/__init__.py_tmpl b/pyramid/paster_templates/pylons_sqla/+package+/__init__.py_tmpl deleted file mode 100644 index d403ba29d..000000000 --- a/pyramid/paster_templates/pylons_sqla/+package+/__init__.py_tmpl +++ /dev/null @@ -1,23 +0,0 @@ -from pyramid.config import Configurator - -from pyramid_beaker import session_factory_from_settings - -from sqlalchemy import engine_from_config - -from {{package}}.models import initialize_sql - -def main(global_config, **settings): - """ This function returns a Pyramid WSGI application. - """ - engine = engine_from_config(settings, 'sqlalchemy.') - initialize_sql(engine) - config = Configurator(settings=settings) - session_factory = session_factory_from_settings(settings) - config.set_session_factory(session_factory) - config.add_static_view('static', '{{package}}:static/') - config.add_handler('main', '/{action}', '{{package}}.handlers:MyHandler') - config.add_handler('home', '/', '{{package}}.handlers:MyHandler', - action='index') - config.add_subscriber('{{package}}.subscribers.add_renderer_globals', - 'pyramid.events.BeforeRender') - return config.make_wsgi_app() diff --git a/pyramid/paster_templates/pylons_sqla/+package+/handlers.py_tmpl b/pyramid/paster_templates/pylons_sqla/+package+/handlers.py_tmpl deleted file mode 100644 index afc8aa41e..000000000 --- a/pyramid/paster_templates/pylons_sqla/+package+/handlers.py_tmpl +++ /dev/null @@ -1,12 +0,0 @@ -from pyramid.view import action - -from {{package}}.models import MyModel - -class MyHandler(object): - def __init__(self, request): - self.request = request - - @action(renderer='mytemplate.mako') - def index(self): - root = MyModel.by_name('root') - return {'root':root, 'project':'{{package}}'} diff --git a/pyramid/paster_templates/pylons_sqla/+package+/models.py b/pyramid/paster_templates/pylons_sqla/+package+/models.py deleted file mode 100644 index 181232072..000000000 --- a/pyramid/paster_templates/pylons_sqla/+package+/models.py +++ /dev/null @@ -1,46 +0,0 @@ -import transaction - -from sqlalchemy import create_engine -from sqlalchemy import Column -from sqlalchemy import Integer -from sqlalchemy import Unicode - -from sqlalchemy.exc import IntegrityError -from sqlalchemy.ext.declarative import declarative_base - -from sqlalchemy.orm import scoped_session -from sqlalchemy.orm import sessionmaker - -from zope.sqlalchemy import ZopeTransactionExtension - -DBSession = scoped_session(sessionmaker(extension=ZopeTransactionExtension())) -Base = declarative_base() - -class MyModel(Base): - __tablename__ = 'models' - id = Column(Integer, primary_key=True) - name = Column(Unicode(255), unique=True) - value = Column(Integer) - - def __init__(self, name, value): - self.name = name - self.value = value - - @classmethod - def by_name(cls, name=None): - return DBSession.query(cls).filter(cls.name == name).first() - -def populate(): - model = MyModel(name=u'root', value=55) - DBSession.add(model) - DBSession.flush() - transaction.commit() - -def initialize_sql(engine): - DBSession.configure(bind=engine) - Base.metadata.bind = engine - Base.metadata.create_all(engine) - try: - populate() - except IntegrityError: - DBSession.rollback() diff --git a/pyramid/paster_templates/pylons_sqla/+package+/static/favicon.ico b/pyramid/paster_templates/pylons_sqla/+package+/static/favicon.ico deleted file mode 100644 index 71f837c9e..000000000 Binary files a/pyramid/paster_templates/pylons_sqla/+package+/static/favicon.ico and /dev/null differ diff --git a/pyramid/paster_templates/pylons_sqla/+package+/static/footerbg.png b/pyramid/paster_templates/pylons_sqla/+package+/static/footerbg.png deleted file mode 100644 index 1fbc873da..000000000 Binary files a/pyramid/paster_templates/pylons_sqla/+package+/static/footerbg.png and /dev/null differ diff --git a/pyramid/paster_templates/pylons_sqla/+package+/static/headerbg.png b/pyramid/paster_templates/pylons_sqla/+package+/static/headerbg.png deleted file mode 100644 index 0596f2020..000000000 Binary files a/pyramid/paster_templates/pylons_sqla/+package+/static/headerbg.png and /dev/null differ diff --git a/pyramid/paster_templates/pylons_sqla/+package+/static/ie6.css b/pyramid/paster_templates/pylons_sqla/+package+/static/ie6.css deleted file mode 100644 index b7c8493d8..000000000 --- a/pyramid/paster_templates/pylons_sqla/+package+/static/ie6.css +++ /dev/null @@ -1,8 +0,0 @@ -* html img, -* html .png{position:relative;behavior:expression((this.runtimeStyle.behavior="none")&&(this.pngSet?this.pngSet=true:(this.nodeName == "IMG" && this.src.toLowerCase().indexOf('.png')>-1?(this.runtimeStyle.backgroundImage = "none", -this.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.src + "',sizingMethod='image')", -this.src = "static/transparent.gif"):(this.origBg = this.origBg? this.origBg :this.currentStyle.backgroundImage.toString().replace('url("','').replace('")',''), -this.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.origBg + "',sizingMethod='crop')", -this.runtimeStyle.backgroundImage = "none")),this.pngSet=true) -);} -#wrap{display:table;height:100%} diff --git a/pyramid/paster_templates/pylons_sqla/+package+/static/middlebg.png b/pyramid/paster_templates/pylons_sqla/+package+/static/middlebg.png deleted file mode 100644 index 2369cfb7d..000000000 Binary files a/pyramid/paster_templates/pylons_sqla/+package+/static/middlebg.png and /dev/null differ diff --git a/pyramid/paster_templates/pylons_sqla/+package+/static/pylons.css b/pyramid/paster_templates/pylons_sqla/+package+/static/pylons.css deleted file mode 100644 index fd1914d8d..000000000 --- a/pyramid/paster_templates/pylons_sqla/+package+/static/pylons.css +++ /dev/null @@ -1,65 +0,0 @@ -html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,font,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td{margin:0;padding:0;border:0;outline:0;font-size:100%;/* 16px */ -vertical-align:baseline;background:transparent;} -body{line-height:1;} -ol,ul{list-style:none;} -blockquote,q{quotes:none;} -blockquote:before,blockquote:after,q:before,q:after{content:'';content:none;} -:focus{outline:0;} -ins{text-decoration:none;} -del{text-decoration:line-through;} -table{border-collapse:collapse;border-spacing:0;} -sub{vertical-align:sub;font-size:smaller;line-height:normal;} -sup{vertical-align:super;font-size:smaller;line-height:normal;} -ul,menu,dir{display:block;list-style-type:disc;margin:1em 0;padding-left:40px;} -ol{display:block;list-style-type:decimal-leading-zero;margin:1em 0;padding-left:40px;} -li{display:list-item;} -ul ul,ul ol,ul dir,ul menu,ul dl,ol ul,ol ol,ol dir,ol menu,ol dl,dir ul,dir ol,dir dir,dir menu,dir dl,menu ul,menu ol,menu dir,menu menu,menu dl,dl ul,dl ol,dl dir,dl menu,dl dl{margin-top:0;margin-bottom:0;} -ol ul,ul ul,menu ul,dir ul,ol menu,ul menu,menu menu,dir menu,ol dir,ul dir,menu dir,dir dir{list-style-type:circle;} -ol ol ul,ol ul ul,ol menu ul,ol dir ul,ol ol menu,ol ul menu,ol menu menu,ol dir menu,ol ol dir,ol ul dir,ol menu dir,ol dir dir,ul ol ul,ul ul ul,ul menu ul,ul dir ul,ul ol menu,ul ul menu,ul menu menu,ul dir menu,ul ol dir,ul ul dir,ul menu dir,ul dir dir,menu ol ul,menu ul ul,menu menu ul,menu dir ul,menu ol menu,menu ul menu,menu menu menu,menu dir menu,menu ol dir,menu ul dir,menu menu dir,menu dir dir,dir ol ul,dir ul ul,dir menu ul,dir dir ul,dir ol menu,dir ul menu,dir menu menu,dir dir menu,dir ol dir,dir ul dir,dir menu dir,dir dir dir{list-style-type:square;} -.hidden{display:none;} -p{line-height:1.5em;} -h1{font-size:1.75em;line-height:1.7em;font-family:helvetica,verdana;} -h2{font-size:1.5em;line-height:1.7em;font-family:helvetica,verdana;} -h3{font-size:1.25em;line-height:1.7em;font-family:helvetica,verdana;} -h4{font-size:1em;line-height:1.7em;font-family:helvetica,verdana;} -html,body{width:100%;height:100%;} -body{margin:0;padding:0;background-color:#ffffff;position:relative;font:16px/24px "Nobile","Lucida Grande",Lucida,Verdana,sans-serif;} -a{color:#1b61d6;text-decoration:none;} -a:hover{color:#e88f00;text-decoration:underline;} -body h1, -body h2, -body h3, -body h4, -body h5, -body h6{font-family:"Neuton","Lucida Grande",Lucida,Verdana,sans-serif;font-weight:normal;color:#373839;font-style:normal;} -#wrap{min-height:100%;} -#header,#footer{width:100%;color:#ffffff;height:40px;position:absolute;text-align:center;line-height:40px;overflow:hidden;font-size:12px;vertical-align:middle;} -#header{background:#000000;top:0;font-size:14px;} -#footer{bottom:0;background:#000000 url(footerbg.png) repeat-x 0 top;position:relative;margin-top:-40px;clear:both;} -.header,.footer{width:750px;margin-right:auto;margin-left:auto;} -.wrapper{width:100%} -#top,#top-small,#bottom{width:100%;} -#top{color:#000000;height:230px;background:#ffffff url(headerbg.png) repeat-x 0 top;position:relative;} -#top-small{color:#000000;height:60px;background:#ffffff url(headerbg.png) repeat-x 0 top;position:relative;} -#bottom{color:#222;background-color:#ffffff;} -.top,.top-small,.middle,.bottom{width:750px;margin-right:auto;margin-left:auto;} -.top{padding-top:40px;} -.top-small{padding-top:10px;} -#middle{width:100%;height:100px;background:url(middlebg.png) repeat-x;border-top:2px solid #ffffff;border-bottom:2px solid #b2b2b2;} -.app-welcome{margin-top:25px;} -.app-name{color:#000000;font-weight:bold;} -.bottom{padding-top:50px;} -#left{width:350px;float:left;padding-right:25px;} -#right{width:350px;float:right;padding-left:25px;} -.align-left{text-align:left;} -.align-right{text-align:right;} -.align-center{text-align:center;} -ul.links{margin:0;padding:0;} -ul.links li{list-style-type:none;font-size:14px;} -form{border-style:none;} -fieldset{border-style:none;} -input{color:#222;border:1px solid #ccc;font-family:sans-serif;font-size:12px;line-height:16px;} -input[type=text],input[type=password]{width:205px;} -input[type=submit]{background-color:#ddd;font-weight:bold;} -/*Opera Fix*/ -body:before{content:"";height:100%;float:left;width:0;margin-top:-32767px;} diff --git a/pyramid/paster_templates/pylons_sqla/+package+/static/pyramid-small.png b/pyramid/paster_templates/pylons_sqla/+package+/static/pyramid-small.png deleted file mode 100644 index a5bc0ade7..000000000 Binary files a/pyramid/paster_templates/pylons_sqla/+package+/static/pyramid-small.png and /dev/null differ diff --git a/pyramid/paster_templates/pylons_sqla/+package+/static/pyramid.png b/pyramid/paster_templates/pylons_sqla/+package+/static/pyramid.png deleted file mode 100644 index 347e05549..000000000 Binary files a/pyramid/paster_templates/pylons_sqla/+package+/static/pyramid.png and /dev/null differ diff --git a/pyramid/paster_templates/pylons_sqla/+package+/static/transparent.gif b/pyramid/paster_templates/pylons_sqla/+package+/static/transparent.gif deleted file mode 100644 index 0341802e5..000000000 Binary files a/pyramid/paster_templates/pylons_sqla/+package+/static/transparent.gif and /dev/null differ diff --git a/pyramid/paster_templates/pylons_sqla/+package+/subscribers.py_tmpl b/pyramid/paster_templates/pylons_sqla/+package+/subscribers.py_tmpl deleted file mode 100644 index 168bf55ea..000000000 --- a/pyramid/paster_templates/pylons_sqla/+package+/subscribers.py_tmpl +++ /dev/null @@ -1,26 +0,0 @@ -from pyramid.threadlocal import get_current_request -from pyramid.exceptions import ConfigurationError -from pyramid.url import route_url - -def add_renderer_globals(event): - """ A subscriber to the ``pyramid.events.BeforeRender`` events. Updates - the :term:`renderer globals` with values that are familiar to Pylons - users.""" - request = event.get('request') - if request is None: - request = get_current_request() - globs = { - 'url': route_url, - 'h':None, - } - if request is not None: - tmpl_context = request.tmpl_context - globs['c'] = tmpl_context - globs['tmpl_context'] = tmpl_context - try: - globs['session'] = request.session - except ConfigurationError: - pass - event.update(globs) - - diff --git a/pyramid/paster_templates/pylons_sqla/+package+/templates/mytemplate.mako_tmpl b/pyramid/paster_templates/pylons_sqla/+package+/templates/mytemplate.mako_tmpl deleted file mode 100644 index d12066ac8..000000000 --- a/pyramid/paster_templates/pylons_sqla/+package+/templates/mytemplate.mako_tmpl +++ /dev/null @@ -1,77 +0,0 @@ - - - - The Pyramid Web Application Development Framework - - - - - - - - - -
-
-
-
pyramid
-
-
-
-
-

- Welcome to ${project}, an application generated by
- the Pyramid web application development framework. -

-
-
-
-
-
-

Search documentation

-
- - -
-
-

The root object's name is "${root.name}"

-
- -
-
-
- - - \ No newline at end of file diff --git a/pyramid/paster_templates/pylons_sqla/+package+/tests.py_tmpl b/pyramid/paster_templates/pylons_sqla/+package+/tests.py_tmpl deleted file mode 100644 index 2cf485cc2..000000000 --- a/pyramid/paster_templates/pylons_sqla/+package+/tests.py_tmpl +++ /dev/null @@ -1,27 +0,0 @@ -import unittest - -from pyramid import testing - -class MyHandlerTests(unittest.TestCase): - def setUp(self): - from sqlalchemy import create_engine - from {{package}}.models import initialize_sql - self.session = initialize_sql(create_engine('sqlite://')) - self.config = testing.setUp() - - def tearDown(self): - testing.tearDown() - - def _makeOne(self, request): - from {{package}}.handlers import MyHandler - return MyHandler(request) - - def test_index(self): - request = DummyRequest() - handler = self._makeOne(request) - info = handler.index() - self.assertEqual(info['project'], '{{package}}') - self.assertEqual(info['root'].name, 'root') - -class DummyRequest(object): - pass diff --git a/pyramid/paster_templates/pylons_sqla/CHANGES.txt_tmpl b/pyramid/paster_templates/pylons_sqla/CHANGES.txt_tmpl deleted file mode 100644 index 35a34f332..000000000 --- a/pyramid/paster_templates/pylons_sqla/CHANGES.txt_tmpl +++ /dev/null @@ -1,4 +0,0 @@ -0.0 ---- - -- Initial version diff --git a/pyramid/paster_templates/pylons_sqla/README.txt_tmpl b/pyramid/paster_templates/pylons_sqla/README.txt_tmpl deleted file mode 100644 index 0ddebfc3e..000000000 --- a/pyramid/paster_templates/pylons_sqla/README.txt_tmpl +++ /dev/null @@ -1,4 +0,0 @@ -{{project}} README - - - diff --git a/pyramid/paster_templates/pylons_sqla/development.ini_tmpl b/pyramid/paster_templates/pylons_sqla/development.ini_tmpl deleted file mode 100644 index 30ffef35f..000000000 --- a/pyramid/paster_templates/pylons_sqla/development.ini_tmpl +++ /dev/null @@ -1,60 +0,0 @@ -[app:{{project}}] -use = egg:{{project}} -reload_templates = true -debug_authorization = false -debug_notfound = false -debug_routematch = false -debug_templates = true -default_locale_name = en -mako.directories = {{package}}:templates -sqlalchemy.url = sqlite:///%(here)s/{{project}}.db -session.type = file -session.data_dir = %(here)s/data/sessions/data -session.lock_dir = %(here)s/data/sessions/lock -session.key = {{project}} -session.secret = {{random_string}} - -[pipeline:main] -pipeline = - egg:WebError#evalerror - egg:repoze.tm2#tm - {{project}} - -[server:main] -use = egg:Paste#http -host = 0.0.0.0 -port = 6543 - -# Begin logging configuration - -[loggers] -keys = root, sqlalchemy - -[handlers] -keys = console - -[formatters] -keys = generic - -[logger_root] -level = INFO -handlers = console - -[logger_sqlalchemy] -level = INFO -handlers = -qualname = sqlalchemy.engine -# "level = INFO" logs SQL queries. -# "level = DEBUG" logs SQL queries and results. -# "level = WARN" logs neither. (Recommended for production systems.) - -[handler_console] -class = StreamHandler -args = (sys.stderr,) -level = NOTSET -formatter = generic - -[formatter_generic] -format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s - -# End logging configuration diff --git a/pyramid/paster_templates/pylons_sqla/setup.cfg_tmpl b/pyramid/paster_templates/pylons_sqla/setup.cfg_tmpl deleted file mode 100644 index 5bec29823..000000000 --- a/pyramid/paster_templates/pylons_sqla/setup.cfg_tmpl +++ /dev/null @@ -1,27 +0,0 @@ -[nosetests] -match=^test -nocapture=1 -cover-package={{package}} -with-coverage=1 -cover-erase=1 - -[compile_catalog] -directory = {{package}}/locale -domain = {{project}} -statistics = true - -[extract_messages] -add_comments = TRANSLATORS: -output_file = {{package}}/locale/{{project}}.pot -width = 80 - -[init_catalog] -domain = {{project}} -input_file = {{package}}/locale/{{project}}.pot -output_dir = {{package}}/locale - -[update_catalog] -domain = {{project}} -input_file = {{package}}/locale/{{project}}.pot -output_dir = {{package}}/locale -previous = true diff --git a/pyramid/paster_templates/pylons_sqla/setup.py_tmpl b/pyramid/paster_templates/pylons_sqla/setup.py_tmpl deleted file mode 100644 index 578d186f3..000000000 --- a/pyramid/paster_templates/pylons_sqla/setup.py_tmpl +++ /dev/null @@ -1,49 +0,0 @@ -import os -import sys - -from setuptools import setup, find_packages - -here = os.path.abspath(os.path.dirname(__file__)) -README = open(os.path.join(here, 'README.txt')).read() -CHANGES = open(os.path.join(here, 'CHANGES.txt')).read() - -requires = [ - 'pyramid', - 'pyramid_beaker', - 'SQLAlchemy', - 'transaction', - 'repoze.tm2', - 'zope.sqlalchemy', - 'WebError', -] - -if sys.version_info[:3] < (2,5,0): - requires.append('pysqlite') - -setup(name='{{project}}', - version='0.0', - description='{{project}}', - long_description=README + '\n\n' + CHANGES, - classifiers=[ - "Programming Language :: Python", - "Framework :: Pylons", - "Topic :: Internet :: WWW/HTTP", - "Topic :: Internet :: WWW/HTTP :: WSGI :: Application", - ], - author='', - author_email='', - url='', - keywords='web pyramid pylons', - packages=find_packages(), - include_package_data=True, - zip_safe=False, - install_requires=requires, - tests_require=requires, - test_suite="{{package}}", - entry_points = """\ - [paste.app_factory] - main = {{package}}:main - """, - paster_plugins=['pyramid'], - ) - -- cgit v1.2.3 From 9e45b104edb01f725d1ab22be1e1e5e96c1464a3 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Sun, 16 Jan 2011 17:48:12 -0500 Subject: remove handler reference from latexindex --- docs/latexindex.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/latexindex.rst b/docs/latexindex.rst index 4ff3bbfe7..00f177e5c 100644 --- a/docs/latexindex.rst +++ b/docs/latexindex.rst @@ -125,7 +125,6 @@ ZCML Directive Reference zcml/configure zcml/default_permission zcml/forbidden - zcml/handler zcml/include zcml/localenegotiator zcml/notfound -- cgit v1.2.3 From 566004501e8a28c0ba8f8c882ca5ea0742e5d285 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Sun, 16 Jan 2011 17:49:54 -0500 Subject: remove references to pylons paster templates --- pyramid/paster.py | 15 --------------- setup.py | 3 --- 2 files changed, 18 deletions(-) diff --git a/pyramid/paster.py b/pyramid/paster.py index 5ac043c19..488721ef0 100644 --- a/pyramid/paster.py +++ b/pyramid/paster.py @@ -39,21 +39,6 @@ class AlchemyProjectTemplate(PyramidTemplate): summary = 'pyramid SQLAlchemy project using traversal' template_renderer = staticmethod(paste_script_template_renderer) -class PylonsBasicProjectTemplate(PyramidTemplate): - _template_dir = 'paster_templates/pylons_basic' - summary = 'Pylons basic project' - template_renderer = staticmethod(paste_script_template_renderer) - -class PylonsMinimalProjectTemplate(PyramidTemplate): - _template_dir = 'paster_templates/pylons_minimal' - summary = 'Pylons minimal project' - template_renderer = staticmethod(paste_script_template_renderer) - -class PylonsSQLAlchemyProjectTemplate(PyramidTemplate): - _template_dir = 'paster_templates/pylons_sqla' - summary = 'Pylons SQLAlchemy project' - template_renderer = staticmethod(paste_script_template_renderer) - def get_app(config_file, name, loadapp=loadapp): """ Return the WSGI application named ``name`` in the PasteDeploy config file ``config_file``""" diff --git a/setup.py b/setup.py index 889aaecec..587e1bb1f 100644 --- a/setup.py +++ b/setup.py @@ -83,9 +83,6 @@ setup(name='pyramid', pyramid_zodb=pyramid.paster:ZODBProjectTemplate pyramid_routesalchemy=pyramid.paster:RoutesAlchemyProjectTemplate pyramid_alchemy=pyramid.paster:AlchemyProjectTemplate - pylons_basic=pyramid.paster:PylonsBasicProjectTemplate - pylons_minimal=pyramid.paster:PylonsMinimalProjectTemplate - pylons_sqla=pyramid.paster:PylonsSQLAlchemyProjectTemplate [paste.paster_command] pshell=pyramid.paster:PShellCommand proutes=pyramid.paster:PRoutesCommand -- cgit v1.2.3