The way Pyramid thinks about decorators is that when the decorator's callback is invoked upon scan, the configurator object is passed into the callback. From there you can do what you need to do via config or config.registry or config.registry.settings, etc. The simplest way to setup decorators is to create a new directive on the configurator which does what you want imperatively. Then just have the decorator call that.
For example, @view_config simply calls config.add_view(). This keeps view_config very focused only on decorator logic and not how to add views. For direction on writing a decorator like view_config just look at config.add_directive and the view_config implementation (after reading how venusian works). Yeah the docs could probably be improved here. Below are the two links I know of in the docs which should get you started. http://docs.pylonsproject.org/projects/pyramid/en/1.3-branch/narr/hooks.html#registering-configuration-decorators http://docs.pylonsproject.org/projects/pyramid/en/1.3-branch/narr/extconfig.html#adding-methods-to-the-configurator-via-add-directive The @action decorator in pyramid_handlers is different because it is not found at scan-time. Rather, when you call add_handler(MyHandler), the class methods are scanned for @action decorators. HTH, Michael On Wed, May 16, 2012 at 7:05 AM, Peter Hartmann <[email protected]> wrote: > Hi, > > I find myself in need to write a custom configuration decoration that > would mark a resource to be included in config during a scan(). Quite > surprisingly, the only configuration decoration (needed a special term > in glossary) in Pyramid seems to be pyramid.view.view_config. I've > looked into it, as well as pyramid_handlers.action. Both look > different in what they do and I suspect what actually matters is how > they are called. Can anyone offer explanation on this process? A > guidance on how to write a simple configuration decoration myself > would be appreciated, too. > > Regards, > Peter > > -- > You received this message because you are subscribed to the Google Groups > "pylons-discuss" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/pylons-discuss?hl=en. > -- You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
