On Wed, 2011-02-09 at 15:11 -0800, Seth wrote:
> This seems to me like it should be simple, so please excuse me if the
> answer is staring me in the face (I did some searching in the docs and
> elsewhere and couldn't find anything satisfactory):
> 
> 
> I'm wondering what the recommended way is to run Pyramid view code
> from a shell/cron. It seems like it'd be pretty simple to load the
> pyramid.testing module and use DummyRequest to do things like create
> POSTs to view methods, but since testing.* probably wasn't intended
> for such purposes I'm hesitant to make that leap.
> 
> 
> To be clear: I'm looking for a little more than a "from views import
> view_method; view_method()" approach. I'm hoping to be able to
> bootstrap the whole Pyramid app and actually simulate view *requests*
> (GET and POST) to these methods from a cron.

The most straightforward way to execute a view as it would be executed
if a real request were to come in is to use the technique described in
http://docs.pylonsproject.org/projects/pyramid/1.0/narr/testing.html#creating-functional-tests

If that seems unreasonable, probably you'll want to modify your
requirements.  Your view code has the logic you want to execute right
now, but if you want to call it programmatically, you should likely
factor the bits of it out that need to be called outside of the context
of an actual request and just call the refactored function from within
your cron-executed script.

- C



-- 
You received this message because you are subscribed to the Google Groups 
"pylons-devel" group.
To post to this group, send email to pylons-devel@googlegroups.com.
To unsubscribe from this group, send email to 
pylons-devel+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/pylons-devel?hl=en.

Reply via email to