Hello group,
I am looking for a way to build up and keep my domain model in memory
during pyramid serves my application. This time I do not want to use a SQL
database or ZODB as the persistence layer. I currently maintain an URL
dispatch based pyramid app using ZODB - this is where my current pyramid
experience is coming from.
Now I want to use pyramid to build an application to visualize data loaded
from large CSV files on local harddisk. I use traversal to map URLs to
folders and files. During application startup I create a basic resource
tree while using several plain python model classes. Typical application
usage should enlarge the resource tree by lazy loading child objects as
requested by users. Lazy loading takes several seconds. This should happen
only one time for every "resource" in the resource tree. My intention is to
keep the main application object(a.k.a resource tree) in memory during
several requests. Parsing CSV files during every request is way to slow.
This actually happens.
As request by traversal based applications I do pass the root_factory to
the Configurator. The pyramid glossary cleary notes: "The “root factory” of
a Pyramid application is called on every request sent to the application.".
This way the application restarts building the resource tree on every
request.
def main(global_config, **settings):
root = settings['root']
if root is None:
raise ValueError('virginia requires a root')
def get_root(environ):
fs = Filesystem(os.path.abspath(os.path.normpath(root)))
directory = Directory(fs, root)
application = Application(directory)
return application
config = Configurator(root_factory=get_root, settings=settings)
I already tried passing a singleton to the root_factory. I currently do not
use any caching/sessioning like beaker.
Any suggestions how to build up a resource tree at runtime that keeps alive
during requests??? Thanks for your answers!
--
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/pylons-discuss/-/HtaxoGpq8dQJ.
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.