Pyramid reacts to web requests. It does not run periodic jobs without
being prodded by a request. You can use 'prequest' in a cron script to
send the application a request. But that gets into authorization
because you probably don't want Internet yobos accessing those URLs.
There are different philosophies of model design, but the one I follow
says that the model should not depend on the rest of the application
or framework. So if you've designed it that way, you can write a
command script that imports the model and makes any needed changes to
the database. But then if you're using caching, how do you tell the
application to expire its cache? Perhaps just let the cache continue
until it's scheduled to expire.
As for having the application monitor changes in files, there's a
kernel feature to do this in some OSes, but not in a way convenient to
Pyramid. The routine would block until a file changes, or the kernel
would trigger a callback when it changes. Neither of these paradigms
fits into a Pyramid application very well.
The other way to do this is with a long-running thread, separate from
the WSGI server's thread pool. You would spawn a thread in the main
function, and it would periodically do its job and sleep for an
interval. However, this adds complexity to the application, so it may
not have much advantage over a cron job. Especially when using
SQLAlchemy, where two different processes can modify the database
without any interaction between them. (The server-based DBs allow this
by design, while SQLite uses sophisticated file locking to allow it.)
--
Mike Orr <
slugg...@gmail.com>