diff options
| author | Casey Duncan <casey.duncan@gmail.com> | 2011-01-17 12:00:37 -0700 |
|---|---|---|
| committer | Casey Duncan <casey.duncan@gmail.com> | 2011-01-17 12:00:37 -0700 |
| commit | bd3c7d796f940f8b7296631b8a3466fd00bc16f7 (patch) | |
| tree | 03547fa989487dee4df8e6fb70d45b9ee1f5f6ad | |
| parent | e849fee8351f77d1a2afd97748dd14e3603c47a8 (diff) | |
| parent | 566004501e8a28c0ba8f8c882ca5ea0742e5d285 (diff) | |
| download | pyramid-bd3c7d796f940f8b7296631b8a3466fd00bc16f7.tar.gz pyramid-bd3c7d796f940f8b7296631b8a3466fd00bc16f7.tar.bz2 pyramid-bd3c7d796f940f8b7296631b8a3466fd00bc16f7.zip | |
fix merge conflict
86 files changed, 256 insertions, 2083 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index fc1a53dd7..67562fbd6 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -7,6 +7,28 @@ 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. + +- 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 -------- @@ -19,6 +41,16 @@ 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). + +- 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 ---------------- @@ -62,6 +62,11 @@ Must-Have (before 1.0) zope.configuration.config.ConfigurationExecutionError: <type 'exceptions.TypeError'>: object of type 'NoneType' has no len() in: ('reversed.py', 14, '<module>', "c.add_view(aview, renderer='__main__:foo.pt')") +- Fix misleading conflict error reports for static views ala + http://cluebin.appspot.com/pasted/7242843 + +- Document ``add_directive``. + Should-Have ----------- diff --git a/docs/api/config.rst b/docs/api/config.rst index 3f37e739c..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 @@ -76,6 +74,8 @@ .. automethod:: set_renderer_globals_factory + .. automethod:: add_directive + .. automethod:: testing_securitypolicy .. automethod:: testing_resources 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 <http://wsgi.org/>`_. 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 diff --git a/docs/latexindex.rst b/docs/latexindex.rst index e5a83bfff..2e6be2f3f 100644 --- a/docs/latexindex.rst +++ b/docs/latexindex.rst @@ -126,7 +126,6 @@ ZCML Directive Reference zcml/configure zcml/default_permission zcml/forbidden - zcml/handler zcml/include zcml/localenegotiator zcml/notfound diff --git a/docs/narr/advconfig.rst b/docs/narr/advconfig.rst index f8b3ee191..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``). @@ -338,6 +335,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`. @@ -387,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: - - <handler - route_name="myroute" - pattern="/prefix/{action}" - handler=".handlers.MyHandler" - /> - -.. 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 ``<route>`` 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 2e0068e63..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 ``<view>`` or + ``<route>`` 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 ``<view>``, - ``<route>`` or ``<handler>`` 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,7 +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. - .. index:: single: resource interfaces diff --git a/docs/narr/views.rst b/docs/narr/views.rst index 4a54a6b16..3e0451383 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. .. note:: You can also create :term:`view handler` classes that define 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/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/config.py b/pyramid/config.py index 9604833f3..f3323ae5d 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 @@ -507,9 +508,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 @@ -521,7 +525,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 @@ -534,7 +538,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 @@ -547,9 +563,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) @@ -558,6 +576,37 @@ class Configurator(object): config = self.__class__.with_context(context) c(config) + 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 + + 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__) + return m + @classmethod def with_context(cls, context): """A classmethod used by ZCML directives, @@ -912,136 +961,6 @@ class Configurator(object): 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, request_param=None, containment=None, attr=None, @@ -3073,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 @@ -35,12 +35,6 @@ /> <meta:directive - name="handler" - schema="pyramid.zcml.IHandlerDirective" - handler="pyramid.zcml.handler" - /> - - <meta:directive name="asset" schema="pyramid.zcml.IAssetDirective" handler="pyramid.zcml.asset" 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/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 Binary files differdeleted file mode 100644 index 71f837c9e..000000000 --- a/pyramid/paster_templates/pylons_basic/+package+/static/favicon.ico +++ /dev/null diff --git a/pyramid/paster_templates/pylons_basic/+package+/static/footerbg.png b/pyramid/paster_templates/pylons_basic/+package+/static/footerbg.png Binary files differdeleted file mode 100644 index 1fbc873da..000000000 --- a/pyramid/paster_templates/pylons_basic/+package+/static/footerbg.png +++ /dev/null diff --git a/pyramid/paster_templates/pylons_basic/+package+/static/headerbg.png b/pyramid/paster_templates/pylons_basic/+package+/static/headerbg.png Binary files differdeleted file mode 100644 index 0596f2020..000000000 --- a/pyramid/paster_templates/pylons_basic/+package+/static/headerbg.png +++ /dev/null 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 Binary files differdeleted file mode 100644 index 2369cfb7d..000000000 --- a/pyramid/paster_templates/pylons_basic/+package+/static/middlebg.png +++ /dev/null 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 Binary files differdeleted file mode 100644 index a5bc0ade7..000000000 --- a/pyramid/paster_templates/pylons_basic/+package+/static/pyramid-small.png +++ /dev/null diff --git a/pyramid/paster_templates/pylons_basic/+package+/static/pyramid.png b/pyramid/paster_templates/pylons_basic/+package+/static/pyramid.png Binary files differdeleted file mode 100644 index 347e05549..000000000 --- a/pyramid/paster_templates/pylons_basic/+package+/static/pyramid.png +++ /dev/null diff --git a/pyramid/paster_templates/pylons_basic/+package+/static/transparent.gif b/pyramid/paster_templates/pylons_basic/+package+/static/transparent.gif Binary files differdeleted file mode 100644 index 0341802e5..000000000 --- a/pyramid/paster_templates/pylons_basic/+package+/static/transparent.gif +++ /dev/null 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 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" xmlns:tal="http://xml.zope.org/namespaces/tal"> -<head> - <title>The Pyramid Web Application Development Framework</title> - <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/> - <meta name="keywords" content="python web application" /> - <meta name="description" content="pyramid web application" /> - <link rel="shortcut icon" href="${request.static_url('{{package}}:static/favicon.ico')}" /> - <link rel="stylesheet" href="${request.static_url('{{package}}:static/pylons.css')}" type="text/css" media="screen" charset="utf-8" /> - <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Neuton|Nobile:regular,i,b,bi&subset=latin" type="text/css" media="screen" charset="utf-8" /> - <!--[if lte IE 6]> - <link rel="stylesheet" href="${request.static_url('{{package}}:static/ie6.css')}" type="text/css" media="screen" charset="utf-8" /> - <![endif]--> -</head> -<body> - <div id="wrap"> - <div id="top"> - <div class="top align-center"> - <div><img src="${request.static_url('{{package}}:static/pyramid.png')}" width="750" height="169" alt="pyramid"/></div> - </div> - </div> - <div id="middle"> - <div class="middle align-center"> - <p class="app-welcome"> - Welcome to <span class="app-name">${project}</span>, an application generated by<br/> - the Pyramid web application development framework. - </p> - </div> - </div> - <div id="bottom"> - <div class="bottom"> - <div id="left" class="align-right"> - <h2>Search documentation</h2> - <form method="get" action="http://docs.pylonsproject.org/projects/pyramid/dev/search.html"> - <input type="text" id="q" name="q" value="" /> - <input type="submit" id="x" value="Go" /> - </form> - </div> - <div id="right" class="align-left"> - <h2>Pyramid links</h2> - <ul class="links"> - <li> - <a href="http://pylonsproject.org">Pylons Website</a> - </li> - <li> - <a href="http://docs.pylonsproject.org/projects/pyramid/dev/#narrative-documentation">Narrative Documentation</a> - </li> - <li> - <a href="http://docs.pylonsproject.org/projects/pyramid/dev/#api-documentation">API Documentation</a> - </li> - <li> - <a href="http://docs.pylonsproject.org/projects/pyramid/dev/#tutorials">Tutorials</a> - </li> - <li> - <a href="http://docs.pylonsproject.org/projects/pyramid/dev/#change-history">Change History</a> - </li> - <li> - <a href="http://docs.pylonsproject.org/projects/pyramid/dev/#sample-applications">Sample Applications</a> - </li> - <li> - <a href="http://docs.pylonsproject.org/projects/pyramid/dev/#support-and-development">Support and Development</a> - </li> - <li> - <a href="irc://irc.freenode.net#pyramid">IRC Channel</a> - </li> - </ul> - </div> - </div> - </div> - </div> - <div id="footer"> - <div class="footer">© Copyright 2008-2011, Agendaless Consulting.</div> - </div> -</body> -</html>
\ 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 Binary files differdeleted file mode 100644 index 71f837c9e..000000000 --- a/pyramid/paster_templates/pylons_minimal/+package+/static/favicon.ico +++ /dev/null diff --git a/pyramid/paster_templates/pylons_minimal/+package+/static/footerbg.png b/pyramid/paster_templates/pylons_minimal/+package+/static/footerbg.png Binary files differdeleted file mode 100644 index 1fbc873da..000000000 --- a/pyramid/paster_templates/pylons_minimal/+package+/static/footerbg.png +++ /dev/null diff --git a/pyramid/paster_templates/pylons_minimal/+package+/static/headerbg.png b/pyramid/paster_templates/pylons_minimal/+package+/static/headerbg.png Binary files differdeleted file mode 100644 index 0596f2020..000000000 --- a/pyramid/paster_templates/pylons_minimal/+package+/static/headerbg.png +++ /dev/null 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 Binary files differdeleted file mode 100644 index 2369cfb7d..000000000 --- a/pyramid/paster_templates/pylons_minimal/+package+/static/middlebg.png +++ /dev/null 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 Binary files differdeleted file mode 100644 index a5bc0ade7..000000000 --- a/pyramid/paster_templates/pylons_minimal/+package+/static/pyramid-small.png +++ /dev/null diff --git a/pyramid/paster_templates/pylons_minimal/+package+/static/pyramid.png b/pyramid/paster_templates/pylons_minimal/+package+/static/pyramid.png Binary files differdeleted file mode 100644 index 347e05549..000000000 --- a/pyramid/paster_templates/pylons_minimal/+package+/static/pyramid.png +++ /dev/null diff --git a/pyramid/paster_templates/pylons_minimal/+package+/static/transparent.gif b/pyramid/paster_templates/pylons_minimal/+package+/static/transparent.gif Binary files differdeleted file mode 100644 index 0341802e5..000000000 --- a/pyramid/paster_templates/pylons_minimal/+package+/static/transparent.gif +++ /dev/null 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 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" xmlns:tal="http://xml.zope.org/namespaces/tal"> -<head> - <title>The Pyramid Web Application Development Framework</title> - <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/> - <meta name="keywords" content="python web application" /> - <meta name="description" content="pyramid web application" /> - <link rel="shortcut icon" href="${request.static_url('{{package}}:static/favicon.ico')}" /> - <link rel="stylesheet" href="${request.static_url('{{package}}:static/pylons.css')}" type="text/css" media="screen" charset="utf-8" /> - <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Neuton|Nobile:regular,i,b,bi&subset=latin" type="text/css" media="screen" charset="utf-8" /> - <!--[if lte IE 6]> - <link rel="stylesheet" href="${request.static_url('{{package}}:static/ie6.css')}" type="text/css" media="screen" charset="utf-8" /> - <![endif]--> -</head> -<body> - <div id="wrap"> - <div id="top"> - <div class="top align-center"> - <div><img src="${request.static_url('{{package}}:static/pyramid.png')}" width="750" height="169" alt="pyramid"/></div> - </div> - </div> - <div id="middle"> - <div class="middle align-center"> - <p class="app-welcome"> - Welcome to <span class="app-name">${project}</span>, an application generated by<br/> - the Pyramid web application development framework. - </p> - </div> - </div> - <div id="bottom"> - <div class="bottom"> - <div id="left" class="align-right"> - <h2>Search documentation</h2> - <form method="get" action="http://docs.pylonsproject.org/projects/pyramid/dev/search.html"> - <input type="text" id="q" name="q" value="" /> - <input type="submit" id="x" value="Go" /> - </form> - </div> - <div id="right" class="align-left"> - <h2>Pyramid links</h2> - <ul class="links"> - <li> - <a href="http://pylonsproject.org">Pylons Website</a> - </li> - <li> - <a href="http://docs.pylonsproject.org/projects/pyramid/dev/#narrative-documentation">Narrative Documentation</a> - </li> - <li> - <a href="http://docs.pylonsproject.org/projects/pyramid/dev/#api-documentation">API Documentation</a> - </li> - <li> - <a href="http://docs.pylonsproject.org/projects/pyramid/dev/#tutorials">Tutorials</a> - </li> - <li> - <a href="http://docs.pylonsproject.org/projects/pyramid/dev/#change-history">Change History</a> - </li> - <li> - <a href="http://docs.pylonsproject.org/projects/pyramid/dev/#sample-applications">Sample Applications</a> - </li> - <li> - <a href="http://docs.pylonsproject.org/projects/pyramid/dev/#support-and-development">Support and Development</a> - </li> - <li> - <a href="irc://irc.freenode.net#pyramid">IRC Channel</a> - </li> - </ul> - </div> - </div> - </div> - </div> - <div id="footer"> - <div class="footer">© Copyright 2008-2011, Agendaless Consulting.</div> - </div> -</body> -</html>
\ 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 Binary files differdeleted file mode 100644 index 71f837c9e..000000000 --- a/pyramid/paster_templates/pylons_sqla/+package+/static/favicon.ico +++ /dev/null diff --git a/pyramid/paster_templates/pylons_sqla/+package+/static/footerbg.png b/pyramid/paster_templates/pylons_sqla/+package+/static/footerbg.png Binary files differdeleted file mode 100644 index 1fbc873da..000000000 --- a/pyramid/paster_templates/pylons_sqla/+package+/static/footerbg.png +++ /dev/null diff --git a/pyramid/paster_templates/pylons_sqla/+package+/static/headerbg.png b/pyramid/paster_templates/pylons_sqla/+package+/static/headerbg.png Binary files differdeleted file mode 100644 index 0596f2020..000000000 --- a/pyramid/paster_templates/pylons_sqla/+package+/static/headerbg.png +++ /dev/null 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 Binary files differdeleted file mode 100644 index 2369cfb7d..000000000 --- a/pyramid/paster_templates/pylons_sqla/+package+/static/middlebg.png +++ /dev/null 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 Binary files differdeleted file mode 100644 index a5bc0ade7..000000000 --- a/pyramid/paster_templates/pylons_sqla/+package+/static/pyramid-small.png +++ /dev/null diff --git a/pyramid/paster_templates/pylons_sqla/+package+/static/pyramid.png b/pyramid/paster_templates/pylons_sqla/+package+/static/pyramid.png Binary files differdeleted file mode 100644 index 347e05549..000000000 --- a/pyramid/paster_templates/pylons_sqla/+package+/static/pyramid.png +++ /dev/null diff --git a/pyramid/paster_templates/pylons_sqla/+package+/static/transparent.gif b/pyramid/paster_templates/pylons_sqla/+package+/static/transparent.gif Binary files differdeleted file mode 100644 index 0341802e5..000000000 --- a/pyramid/paster_templates/pylons_sqla/+package+/static/transparent.gif +++ /dev/null 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 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" xmlns:tal="http://xml.zope.org/namespaces/tal"> -<head> - <title>The Pyramid Web Application Development Framework</title> - <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/> - <meta name="keywords" content="python web application" /> - <meta name="description" content="pyramid web application" /> - <link rel="shortcut icon" href="${request.static_url('{{package}}:static/favicon.ico')}" /> - <link rel="stylesheet" href="${request.static_url('{{package}}:static/pylons.css')}" type="text/css" media="screen" charset="utf-8" /> - <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Neuton|Nobile:regular,i,b,bi&subset=latin" type="text/css" media="screen" charset="utf-8" /> - <!--[if lte IE 6]> - <link rel="stylesheet" href="${request.static_url('{{package}}:static/ie6.css')}" type="text/css" media="screen" charset="utf-8" /> - <![endif]--> -</head> -<body> - <div id="wrap"> - <div id="top"> - <div class="top align-center"> - <div><img src="${request.static_url('{{package}}:static/pyramid.png')}" width="750" height="169" alt="pyramid"/></div> - </div> - </div> - <div id="middle"> - <div class="middle align-center"> - <p class="app-welcome"> - Welcome to <span class="app-name">${project}</span>, an application generated by<br/> - the Pyramid web application development framework. - </p> - </div> - </div> - <div id="bottom"> - <div class="bottom"> - <div id="left" class="align-right"> - <h2>Search documentation</h2> - <form method="get" action="http://docs.pylonsproject.org/projects/pyramid/dev/search.html"> - <input type="text" id="q" name="q" value="" /> - <input type="submit" id="x" value="Go" /> - </form> - <br/> - <p>The root object's name is "${root.name}"</p> - </div> - <div id="right" class="align-left"> - <h2>Pyramid links</h2> - <ul class="links"> - <li> - <a href="http://pylonsproject.org">Pylons Website</a> - </li> - <li> - <a href="http://docs.pylonsproject.org/projects/pyramid/dev/#narrative-documentation">Narrative Documentation</a> - </li> - <li> - <a href="http://docs.pylonsproject.org/projects/pyramid/dev/#api-documentation">API Documentation</a> - </li> - <li> - <a href="http://docs.pylonsproject.org/projects/pyramid/dev/#tutorials">Tutorials</a> - </li> - <li> - <a href="http://docs.pylonsproject.org/projects/pyramid/dev/#change-history">Change History</a> - </li> - <li> - <a href="http://docs.pylonsproject.org/projects/pyramid/dev/#sample-applications">Sample Applications</a> - </li> - <li> - <a href="http://docs.pylonsproject.org/projects/pyramid/dev/#support-and-development">Support and Development</a> - </li> - <li> - <a href="irc://irc.freenode.net#pyramid">IRC Channel</a> - </li> - </ul> - </div> - </div> - </div> - </div> - <div id="footer"> - <div class="footer">© Copyright 2008-2011, Agendaless Consulting.</div> - </div> -</body> -</html>
\ 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'], - ) - 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..1073e53cc 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() @@ -1858,278 +1875,6 @@ class ConfiguratorTests(unittest.TestCase): request = self._makeRequest(config) self.assertEqual(view(None, request), 'OK') - def test_add_handler_action_in_route_pattern(self): - config = self._makeOne(autocommit=True) - views = [] - def dummy_add_view(**kw): - views.append(kw) - config.add_view = dummy_add_view - config.add_handler('name', '/:action', DummyHandler) - self._assertRoute(config, 'name', '/:action', 0) - self.assertEqual(len(views), 2) - - view = views[0] - preds = view['custom_predicates'] - self.assertEqual(len(preds), 1) - pred = preds[0] - request = DummyRequest() - self.assertEqual(pred(None, request), False) - request.matchdict = {'action':'action1'} - self.assertEqual(pred(None, request), True) - self.assertEqual(view['route_name'], 'name') - self.assertEqual(view['attr'], 'action1') - self.assertEqual(view['view'], DummyHandler) - - view = views[1] - preds = view['custom_predicates'] - self.assertEqual(len(preds), 1) - pred = preds[0] - request = DummyRequest() - self.assertEqual(pred(None, request), False) - request.matchdict = {'action':'action2'} - self.assertEqual(pred(None, request), True) - self.assertEqual(view['route_name'], 'name') - self.assertEqual(view['attr'], 'action2') - self.assertEqual(view['view'], DummyHandler) - - def test_add_handler_with_view_overridden_autoexpose_None(self): - config = self._makeOne(autocommit=True) - views = [] - def dummy_add_view(**kw): - views.append(kw) # pragma: no cover - config.add_view = dummy_add_view - class MyView(DummyHandler): - __autoexpose__ = None - config.add_handler('name', '/:action', MyView) - self._assertRoute(config, 'name', '/:action', 0) - self.assertEqual(len(views), 0) - - def test_add_handler_with_view_overridden_autoexpose_broken_regex1(self): - from pyramid.exceptions import ConfigurationError - config = self._makeOne() - def dummy_add_view(**kw): - """ """ - config.add_view = dummy_add_view - class MyView(DummyHandler): - __autoexpose__ = 1 - self.assertRaises(ConfigurationError, config.add_handler, - 'name', '/{action}', MyView) - - def test_add_handler_with_view_overridden_autoexpose_broken_regex2(self): - from pyramid.exceptions import ConfigurationError - config = self._makeOne() - def dummy_add_view(**kw): - """ """ - config.add_view = dummy_add_view - class MyView(DummyHandler): - __autoexpose__ = 'a\\' - self.assertRaises(ConfigurationError, config.add_handler, - 'name', '/{action}', MyView) - - def test_add_handler_with_view_method_has_expose_config(self): - config = self._makeOne(autocommit=True) - views = [] - def dummy_add_view(**kw): - views.append(kw) - config.add_view = dummy_add_view - class MyView(object): - def action(self): # pragma: no cover - return 'response' - action.__exposed__ = [{'custom_predicates':(1,)}] - config.add_handler('name', '/:action', MyView) - self._assertRoute(config, 'name', '/:action', 0) - self.assertEqual(len(views), 1) - view = views[0] - preds = view['custom_predicates'] - self.assertEqual(len(preds), 2) - self.assertEqual(view['route_name'], 'name') - self.assertEqual(view['attr'], 'action') - self.assertEqual(view['view'], MyView) - - def test_add_handler_with_view_method_has_expose_config_with_action(self): - config = self._makeOne(autocommit=True) - views = [] - def dummy_add_view(**kw): - views.append(kw) - config.add_view = dummy_add_view - class MyView(object): - def action(self): # pragma: no cover - return 'response' - action.__exposed__ = [{'name':'action3000'}] - config.add_handler('name', '/:action', MyView) - self._assertRoute(config, 'name', '/:action', 0) - self.assertEqual(len(views), 1) - view = views[0] - preds = view['custom_predicates'] - self.assertEqual(len(preds), 1) - pred = preds[0] - request = DummyRequest() - self.assertEqual(pred(None, request), False) - request.matchdict = {'action':'action3000'} - self.assertEqual(pred(None, request), True) - self.assertEqual(view['route_name'], 'name') - self.assertEqual(view['attr'], 'action') - self.assertEqual(view['view'], MyView) - - def test_add_handler_with_view_method_has_expose_config_with_action_regex( - self): - config = self._makeOne(autocommit=True) - views = [] - def dummy_add_view(**kw): - views.append(kw) - config.add_view = dummy_add_view - class MyView(object): - def action(self): # pragma: no cover - return 'response' - action.__exposed__ = [{'name':'^action3000$'}] - config.add_handler('name', '/:action', MyView) - self._assertRoute(config, 'name', '/:action', 0) - self.assertEqual(len(views), 1) - view = views[0] - preds = view['custom_predicates'] - self.assertEqual(len(preds), 1) - pred = preds[0] - request = DummyRequest() - self.assertEqual(pred(None, request), False) - request.matchdict = {'action':'action3000'} - self.assertEqual(pred(None, request), True) - self.assertEqual(view['route_name'], 'name') - self.assertEqual(view['attr'], 'action') - self.assertEqual(view['view'], MyView) - - def test_add_handler_with_action_decorator(self): - config = self._makeOne(autocommit=True) - views = [] - def dummy_add_view(**kw): - views.append(kw) - config.add_view = dummy_add_view - class MyHandler(object): - @classmethod - def __action_decorator__(cls, fn): # pragma: no cover - return fn - def action(self): # pragma: no cover - return 'response' - config.add_handler('name', '/{action}', MyHandler) - self.assertEqual(len(views), 1) - self.assertEqual(views[0]['decorator'], MyHandler.__action_decorator__) - - def test_add_handler_with_action_decorator_fail_on_instancemethod(self): - config = self._makeOne(autocommit=True) - class MyHandler(object): - def __action_decorator__(self, fn): # pragma: no cover - return fn - def action(self): # pragma: no cover - return 'response' - from pyramid.exceptions import ConfigurationError - self.assertRaises(ConfigurationError, config.add_handler, - 'name', '/{action}', MyHandler) - - def test_add_handler_doesnt_mutate_expose_dict(self): - config = self._makeOne(autocommit=True) - views = [] - def dummy_add_view(**kw): - views.append(kw) - config.add_view = dummy_add_view - exposed = [{'name':'^action3000$'}] - class MyView(object): - def action(self): # pragma: no cover - return 'response' - action.__exposed__ = exposed - config.add_handler('name', '/{action}', MyView) - self.assertEqual(exposed[0], {'name':'^action3000$'}) # not mutated - - def test_add_handler_with_action_and_action_in_path(self): - from pyramid.exceptions import ConfigurationError - config = self._makeOne() - self.assertRaises(ConfigurationError, config.add_handler, - 'name', '/{action}', DummyHandler, action='abc') - - def test_add_handler_with_explicit_action(self): - config = self._makeOne(autocommit=True) - class DummyHandler(object): - def index(self): pass - index.__exposed__ = [{'a':'1'}] - views = [] - def dummy_add_view(**kw): - views.append(kw) - config.add_view = dummy_add_view - config.add_handler('name', '/abc', DummyHandler, action='index') - self.assertEqual(len(views), 1) - view = views[0] - self.assertEqual(view['a'], '1') - self.assertEqual(view['attr'], 'index') - self.assertEqual(view['route_name'], 'name') - self.assertEqual(view['view'], DummyHandler) - - def test_add_handler_with_implicit_action(self): - config = self._makeOne(autocommit=True) - class DummyHandler(object): - def __call__(self): pass - __call__.__exposed__ = [{'a':'1'}] - views = [] - def dummy_add_view(**kw): - views.append(kw) - config.add_view = dummy_add_view - config.add_handler('name', '/abc', DummyHandler) - self.assertEqual(len(views), 1) - view = views[0] - self.assertEqual(view['a'], '1') - self.assertEqual(view['attr'], None) - self.assertEqual(view['route_name'], 'name') - self.assertEqual(view['view'], DummyHandler) - - def test_add_handler_with_multiple_action(self): - config = self._makeOne(autocommit=True) - class DummyHandler(object): - def index(self): pass - def create(self): pass - create.__exposed__ = [{'name': 'index'}] - views = [] - def dummy_add_view(**kw): - views.append(kw) - config.add_view = dummy_add_view - config.add_handler('name', '/abc', DummyHandler, action='index') - self.assertEqual(len(views), 2) - view = views[0] - self.assertEqual(view['attr'], 'create') - self.assertEqual(view['route_name'], 'name') - self.assertEqual(view['view'], DummyHandler) - view = views[1] - self.assertEqual(view['attr'], 'index') - - def test_add_handler_string(self): - import pyramid - views = [] - config = self._makeOne(autocommit=True) - def dummy_add_view(**kw): - views.append(kw) - config.add_view = dummy_add_view - config.add_handler('name', '/abc', 'pyramid') - self.assertEqual(len(views), 1) - view = views[0] - self.assertEqual(view['view'], pyramid) - - def test_add_handler_pattern_None_no_previous_route(self): - from pyramid.exceptions import ConfigurationError - config = self._makeOne() - self.assertRaises(ConfigurationError, config.add_handler, - 'name', None, 'pyramid') - - def test_add_handler_pattern_None_with_previous_route(self): - import pyramid - config = self._makeOne(autocommit=True) - config.add_route('name', ':def') - views = [] - def dummy_add_view(**kw): - views.append(kw) - config.add_view = dummy_add_view - config.add_route = None # shouldn't be called - config.add_handler('name', None, 'pyramid') - self.assertEqual(len(views), 1) - view = views[0] - self.assertEqual(view['view'], pyramid) - - def _assertRoute(self, config, name, path, num_predicates=0): from pyramid.interfaces import IRoutesMapper mapper = config.registry.getUtility(IRoutesMapper) @@ -3171,24 +2916,6 @@ class ConfiguratorTests(unittest.TestCase): else: # pragma: no cover raise AssertionError - def test_conflict_add_handler(self): - class AHandler(object): - def aview(self): pass - from zope.configuration.config import ConfigurationConflictError - config = self._makeOne() - config.add_handler('h1', '/h1', handler=AHandler) - config.add_handler('h1', '/h1', handler=AHandler) - try: - config.commit() - except ConfigurationConflictError, why: - c1, c2, c3, c4 = self._conflictFunctions(why) - self.assertEqual(c1, 'test_conflict_add_handler') - self.assertEqual(c2, 'test_conflict_add_handler') - self.assertEqual(c3, 'test_conflict_add_handler') - self.assertEqual(c3, 'test_conflict_add_handler') - else: # pragma: no cover - raise AssertionError - def test_scan_conflict(self): from zope.configuration.config import ConfigurationConflictError from pyramid.tests import selfscanapp @@ -3216,6 +2943,101 @@ class ConfiguratorTests(unittest.TestCase): for confinst in conflict: yield confinst[2] + def test___getattr__missing_when_directives_exist(self): + config = self._makeOne() + directives = {} + config.registry._directives = directives + self.assertRaises(AttributeError, config.__getattr__, 'wontexist') + + def test___getattr__missing_when_directives_dont_exist(self): + config = self._makeOne() + self.assertRaises(AttributeError, config.__getattr__, 'wontexist') + + def test___getattr__matches(self): + config = self._makeOne() + def foo(config): pass + directives = {'foo':foo} + config.registry._directives = directives + foo_meth = config.foo + self.failUnless(foo_meth.im_func.__docobj__ is foo) + +class TestConfigurator_add_directive(unittest.TestCase): + + def setUp(self): + from pyramid.config import Configurator + self.config = Configurator() + + def test_extend_with_dotted_name(self): + from pyramid import tests + config = self.config + 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 + actions = context_after.actions + self.assertEqual(len(actions), 1) + self.assertEqual( + context_after.actions[0][:3], + ('discrim', None, tests), + ) + + def test_extend_with_python_callable(self): + from pyramid import tests + config = self.config + config.add_directive( + 'dummy_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), + ) + + def test_extend_same_name_doesnt_conflict(self): + config = self.config + 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_action_method_successful(self): + from zope.configuration.config import ConfigurationConflictError + config = self.config + config.add_directive( + 'dummy_extend', dummy_extend) + config.dummy_extend('discrim') + config.dummy_extend('discrim') + self.assertRaises(ConfigurationConflictError, config.commit) + + def test_directive_persists_across_configurator_creations(self): + from zope.configuration.config import GroupingContextDecorator + config = self.config + 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): self.config = testing.setUp() @@ -4742,57 +4564,6 @@ class Test_isexception(unittest.TestCase): pass self.assertEqual(self._callFUT(ISubException), True) -class TestActionPredicate(unittest.TestCase): - def _getTargetClass(self): - from pyramid.config import ActionPredicate - return ActionPredicate - - def _makeOne(self, action='myaction'): - return self._getTargetClass()(action) - - def test_bad_action_regex_string(self): - from pyramid.exceptions import ConfigurationError - cls = self._getTargetClass() - self.assertRaises(ConfigurationError, cls, '[a-z') - - def test_bad_action_regex_None(self): - from pyramid.exceptions import ConfigurationError - cls = self._getTargetClass() - self.assertRaises(ConfigurationError, cls, None) - - def test___call__no_matchdict(self): - pred = self._makeOne() - request = DummyRequest() - self.assertEqual(pred(None, request), False) - - def test___call__no_action_in_matchdict(self): - pred = self._makeOne() - request = DummyRequest() - request.matchdict = {} - self.assertEqual(pred(None, request), False) - - def test___call__action_does_not_match(self): - pred = self._makeOne() - request = DummyRequest() - request.matchdict = {'action':'notmyaction'} - self.assertEqual(pred(None, request), False) - - def test___call__action_matches(self): - pred = self._makeOne() - request = DummyRequest() - request.matchdict = {'action':'myaction'} - self.assertEqual(pred(None, request), True) - - def test___hash__(self): - pred1 = self._makeOne() - pred2 = self._makeOne() - pred3 = self._makeOne(action='notthesame') - self.assertEqual(hash(pred1), hash(pred2)) - self.assertNotEqual(hash(pred1), hash(pred3)) - self.assertNotEqual(hash(pred2), hash(pred3)) - - - class DummyRequest: subpath = () matchdict = None @@ -4931,16 +4702,14 @@ def dummy_view(request): def dummyfactory(request): """ """ -class DummyHandler(object): # pragma: no cover - def __init__(self, request): - self.request = request +def dummy_include(config): + config.action('discrim', None, config.package) - def action1(self): - return 'response 1' +includeme = dummy_include - def action2(self): - return 'response 2' +def dummy_extend(config, discrim): + config.action(discrim, None, config.package) -def dummy_include(config): - config.action('discrim', None, config.package) +def dummy_extend2(config, discrim): + config.action(discrim, None, config.registry) diff --git a/pyramid/tests/test_view.py b/pyramid/tests/test_view.py index 204547cf2..35925098d 100644 --- a/pyramid/tests/test_view.py +++ b/pyramid/tests/test_view.py @@ -429,28 +429,6 @@ class Test_default_exceptionresponse_view(unittest.TestCase): result = self._callFUT(context, request) self.assertEqual(result, 'abc') -class Test_action(unittest.TestCase): - def _makeOne(self, **kw): - from pyramid.view import action - return action(**kw) - - def test_call_no_previous__exposed__(self): - inst = self._makeOne(a=1, b=2) - def wrapped(): - """ """ - result = inst(wrapped) - self.failUnless(result is wrapped) - self.assertEqual(result.__exposed__, [{'a':1, 'b':2}]) - - def test_call_with_previous__exposed__(self): - inst = self._makeOne(a=1, b=2) - def wrapped(): - """ """ - wrapped.__exposed__ = [None] - result = inst(wrapped) - self.failUnless(result is wrapped) - self.assertEqual(result.__exposed__, [None, {'a':1, 'b':2}]) - class ExceptionResponse(Exception): status = '404 Not Found' app_iter = ['Not Found'] diff --git a/pyramid/tests/test_zcml.py b/pyramid/tests/test_zcml.py index 4c32e4d52..af0ac9742 100644 --- a/pyramid/tests/test_zcml.py +++ b/pyramid/tests/test_zcml.py @@ -639,86 +639,6 @@ class TestRouteDirective(unittest.TestCase): context = self.config._ctx self.assertRaises(ConfigurationError, self._callFUT, context, 'name') -class TestHandlerDirective(unittest.TestCase): - def setUp(self): - self.config = testing.setUp(autocommit=False) - self.config._ctx = self.config._make_context() - - def tearDown(self): - testing.tearDown() - - def _callFUT(self, *arg, **kw): - from pyramid.zcml import handler - return handler(*arg, **kw) - - def _assertRoute(self, name, pattern, num_predicates=0): - from pyramid.interfaces import IRoutesMapper - reg = self.config.registry - mapper = reg.getUtility(IRoutesMapper) - routes = mapper.get_routes() - route = routes[0] - self.assertEqual(len(routes), 1) - self.assertEqual(route.name, name) - self.assertEqual(route.pattern, pattern) - self.assertEqual(len(routes[0].predicates), num_predicates) - return route - - def test_it(self): - from pyramid.view import action - from zope.interface import Interface - from pyramid.interfaces import IView - from pyramid.interfaces import IViewClassifier - from pyramid.interfaces import IRouteRequest - reg = self.config.registry - context = self.config._ctx - class Handler(object): # pragma: no cover - def __init__(self, request): - self.request = request - action(renderer='json') - def one(self): - return 'OK' - action(renderer='json') - def two(self): - return 'OK' - self._callFUT(context, 'name', '/:action', Handler) - actions = extract_actions(context.actions) - self.assertEqual(len(actions), 3) - - route_action = actions[0] - route_discriminator = route_action['discriminator'] - self.assertEqual(route_discriminator, - ('route', 'name', False, None, None, None, None,None)) - self._assertRoute('name', '/:action') - - view_action = actions[1] - request_type = reg.getUtility(IRouteRequest, 'name') - view_discriminator = view_action['discriminator'] - discrim = ('view', None, '', None, IView, None, None, None, 'name', - 'one', False, None, None, None) - self.assertEqual(view_discriminator[:14], discrim) - view_action['callable'](*view_action['args'], **view_action['kw']) - - view_action = actions[2] - request_type = reg.getUtility(IRouteRequest, 'name') - view_discriminator = view_action['discriminator'] - discrim = ('view', None, '', None, IView, None, None, None, 'name', - 'two', False, None, None, None) - self.assertEqual(view_discriminator[:14], discrim) - view_action['callable'](*view_action['args'], **view_action['kw']) - - wrapped = reg.adapters.lookup( - (IViewClassifier, request_type, Interface), IView, name='') - self.failUnless(wrapped) - - def test_pattern_is_None(self): - from pyramid.exceptions import ConfigurationError - - context = self.config._ctx - class Handler(object): - pass - self.assertRaises(ConfigurationError, self._callFUT, - context, 'name', None, Handler) - class TestStaticDirective(unittest.TestCase): def setUp(self): self.config = testing.setUp(autocommit=False) diff --git a/pyramid/view.py b/pyramid/view.py index 26f64d5fc..f1d8a33e3 100644 --- a/pyramid/view.py +++ b/pyramid/view.py @@ -529,14 +529,3 @@ See also :ref:`changing_the_notfound_view`. """ -class action(object): - def __init__(self, **kw): - self.kw = kw - - def __call__(self, wrapped): - if hasattr(wrapped, '__exposed__'): - wrapped.__exposed__.append(self.kw) - else: - wrapped.__exposed__ = [self.kw] - return wrapped - diff --git a/pyramid/zcml.py b/pyramid/zcml.py index 298086912..9eceee244 100644 --- a/pyramid/zcml.py +++ b/pyramid/zcml.py @@ -296,74 +296,6 @@ def route(_context, traverse=traverse, ) -class IHandlerDirective(IRouteLikeDirective): - route_name = TextLine(title=u'route_name', required=True) - handler = GlobalObject(title=u'handler', required=True) - action = TextLine(title=u"action", required=False) - -def handler(_context, - route_name, - pattern, - handler, - action=None, - view=None, - view_for=None, - permission=None, - factory=None, - for_=None, - header=None, - xhr=False, - accept=None, - path_info=None, - request_method=None, - request_param=None, - custom_predicates=(), - view_permission=None, - view_attr=None, - renderer=None, - view_renderer=None, - view_context=None, - traverse=None, - use_global_views=False): - """ Handle ``handler`` ZCML directives - """ - # the strange ordering of the request kw args above is for b/w - # compatibility purposes. - - # these are route predicates; if they do not match, the next route - # in the routelist will be tried - if view_context is None: - view_context = view_for or for_ - - view_permission = view_permission or permission - view_renderer = view_renderer or renderer - - if pattern is None: - raise ConfigurationError('handler directive must include a "pattern"') - - config = Configurator.with_context(_context) - config.add_handler( - route_name, - pattern, - handler, - action=action, - factory=factory, - header=header, - xhr=xhr, - accept=accept, - path_info=path_info, - request_method=request_method, - request_param=request_param, - custom_predicates=custom_predicates, - view=view, - view_context=view_context, - view_permission=view_permission, - view_renderer=view_renderer, - view_attr=view_attr, - use_global_views=use_global_views, - traverse=traverse, - ) - class ISystemViewDirective(Interface): view = GlobalObject( title=u"", @@ -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 |
