On Thu, Jun 21, 2012 at 10:55 AM, Jonathan Vanasco <[email protected]>wrote:

>
>
> > 1.       In Pylons, there is a config API which could be used to read the
> > fields in the .ini (development.ini or deployment.ini) file. Is there
> > something similar in Pyramid?
>
> all of that information is stored in the request object under:
> request.registry.settings
>

Yes, request.registry.settings is equivalent to pylons.config. (At least in
the basic sense that settings parsed from "[app:main]" will be in this
dict.)


>
>
> > 2.       In Pylons, there is util containing forward, abort etc. Is there
> > something similar in Pyramid?
>
> from pyramid.httpexceptions import *
> from pyramid.httpexceptions import HTTPFound , HTTPNotFound
>
>
> http://docs.pylonsproject.org/projects/pyramid/en/1.0-branch/api/httpexceptions.html
>
> you can read more about them here:
>
> http://pyramid.readthedocs.org/en/latest/narr/views.html#http-exceptions
>
> you can raise or return those objects from a view.
>
>
There's also a function that behaves closer to abort.

return pyramid.httpexceptions.exception_response(404)


> they behave slightly differently when you `raise` than `return`.
> IIRC, if you `return` you still have the request object in
> subscribers, but if you `raise`, then pyramid's exeception handling
> system takes control and you no longer have the request.
>

I thought Pyramid handled returning and raising HTTP exceptions
identically. Raising them does cut through intermediate stack frames
(function calls) to whichever level catches the exception, as with all
exceptions. So that may bypass subscribers. On the other hand, somebody
who's asking these questions is probably not using custom subscribers
anyway.

-- 
Mike Orr <[email protected]>

-- 
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.

Reply via email to