On Sat, Jun 11, 2011 at 10:58 PM, Matt Feifarek <[email protected]> wrote:
> On Sat, Jun 11, 2011 at 3:36 PM, Danny Navarro <[email protected]> wrote:
>>
>> I see Pyramid as just an application (a WSGI app) that just takes
>> requests and returns responses. The rest of Pyramid functionality is
>> to configure the application in the way it processes the requests and
>> returns the responses.
>
> Yes, I see your point. And I agree; I try and configure my apps this way,
> with most code not inside of view-callables, but called *from* view
> callables; I hook my code into the events corresponding to requests and
> responses; I like this way of thinking, and in principle, it would be easier
> to code and debug, since you can just fire off these bits of code from an
> interpeter or tests. Needing to have a web request means that I'm stuck
> talking through a web browser rather than ipython or something nice like
> WingIDE, which is frustrating.
>
>>
>> What other things you have mind where you think you it's awkward to
>> use a request?
>
> Of course I know I can hook into ZODB (or whatever) alone, but there are
> aspects of the pyramid app that I might need, for example, the settings to
> determine where the ZODB is (or where ZEO is). One can't grab the
> configuration without being inside of request either... except that I expect
> one can, I just don't know how.
> I suppose I can make my own plumbing to make this happen, but that seems
> strange; pyramid has these tools to find, open, expose a ZODB, including
> transactions, retry, etc... I'd rather just tie into that. I suppose if the
> "right way" to work is to always have a request or a response, I'll just
> have to get into the habit of using testing-like stubs... ?

If you mean accessing the settings, the database configuration
settings, have a look at repoze.zodbconn, you can reuse the same
configuration for ZEO/ZODB that you have for Pyramid, just use the
script the same URL you use in your paster ini file to configure
ZEO/ZODB.

Testing is another story. You can use
``pyramid.threadlocal.get_current_request`` anywhere in your
application to get the current request. It's not recommended in a real
application but it's OK while testing.
http://docs.pylonsproject.org/projects/pyramid/1.0/api/threadlocal.html

``pyramid.testing`` offers you many helpers to ease the creation of
dummy requests and for the activation of a dummy registry so that the
request runs as if it were within pyramid.
http://docs.pylonsproject.org/projects/pyramid/1.0/narr/testing.html
http://docs.pylonsproject.org/projects/pyramid/1.0/api/testing.html

> Thanks, Danny.
>
> --
> 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.
>



-- 
Danny Navarro  |  http://dannynavarro.net

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