add_request_method vs custom request factory

120 views
Skip to first unread message

Wyatt Baldwin

unread,
Feb 6, 2013, 4:15:48 PM2/6/13
to pylons-...@googlegroups.com
The docs say config.add_request_method() "is the recommended method for extending the request object and should be used in favor of providing a custom request factory via pyramid.config.Configurator.set_request_factory()" but doesn't say why (or at least not that I could find).

Does anyone have any thoughts on the pros and cons of each approach and especially why add_request_method is recommended?

Michael Merickel

unread,
Feb 6, 2013, 4:22:22 PM2/6/13
to Pylons
Well you only get one request factory. Thus there is only one point in your app where you can extend the request using this hook. The introduction of the request methods allows you to extend the request from any addon/plugin in your app and they can all interoperate on the same request object without plugins having to provide request mixins, etc, that you throw into a custom factory. Request methods also support conflict resolution. Thus, if multiple addons extend the request with the same method/property you will see an error or an override, as defined by Pyramid's include mechanism.


On Wed, Feb 6, 2013 at 3:15 PM, Wyatt Baldwin <wyatt.le...@gmail.com> wrote:
The docs say config.add_request_method() "is the recommended method for extending the request object and should be used in favor of providing a custom request factory via pyramid.config.Configurator.set_request_factory()" but doesn't say why (or at least not that I could find).

Does anyone have any thoughts on the pros and cons of each approach and especially why add_request_method is recommended?

--
You received this message because you are subscribed to the Google Groups "pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pylons-discus...@googlegroups.com.
To post to this group, send email to pylons-...@googlegroups.com.
Visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Wyatt Baldwin

unread,
Feb 6, 2013, 5:29:15 PM2/6/13
to pylons-...@googlegroups.com
Thanks. That all makes senses. I guess the only thing I don't like is that my IDE can't do completion on methods/properties added via add_request_method, but the benefits you've listed are worth that minor inconvenience.
Reply all
Reply to author
Forward
0 new messages