[Cubicweb] Access 'data_url' in postcreate.py
stephane.bugat at free.fr
Mon Aug 27 09:18:58 CEST 2012
Thank you for those precisions. I do understand that this is a bad idea and that data/ is reserved to data needed by the interface... However, I'm still wondering where to put the following information:
1- I need to have a "repository" containing the list of know airports in the world (a csv file), and also a list of known countries / territories. These static information will be updated very rarely, for instance once a year. Such information should be available to migration/postcreate.py to create the corresponding entries in the cw database.
==> Shall I put such csv files in a subdir of migration/ for instance?
2- I have developed a certain number of "crawlers" that are able to retrieve airports informations (number of runways, nearby services and so on) from the web. I prefer to store these informations in static files, one file per airport, so they are available to me even when not connected to the net. The crawlers are called for the moment manually, but I intend to add a functionality available to 'managers' of the website to update these through the interface, so they will be used very often.
==> What should be the preferred place to put those static files?
I saw that the tutorial for building a photo gallery recommends the creation of the specific byte file-system storage for image storage... Shall I adapt it to store those text informations?
----- Mail original -----
> De: "Sylvain Thénault" <sylvain.thenault at logilab.fr>
> À: "Stéphane Bugat" <stephane.bugat at free.fr>
> Cc: cubicweb at lists.cubicweb.org
> Envoyé: Vendredi 24 Août 2012 14:46:05
> Objet: Re: [Cubicweb] Access 'data_url' in postcreate.py
> On 24 août 13:25, Stéphane Bugat wrote:
> > Same question but this time in another context: self._cw.data_url
> > is not available in Hooks with events like 'server_startup'...
> Beside the points noticed by Aurélien, you should remember that
> a cubicweb instance can be splitted in two distincts processes:
> * the data repository (eg running hooks and operations of cubes,
> + some views when hooks trigger notifications for instances)
> * the web server (running views)
> Most instances are "all-in-one", eg data repository and web server in
> the same process, leading to confusion. But you should keep that in
> and that some resources may only be available for one or another
> 'data_url' is a web resource, for instance, though made available for
> conveniency on the repository side.
> Now regarding server_startup and server_shutdown events: those are
> without a session as context (ie the _cw object you get on the
> side) since they are not tied to a session. You can still create an
> internal session (self.repo.internal_session()) in the hook if you
> access to such ressources.
> Sylvain Thénault, LOGILAB, Paris (01.45.32.03.12) - Toulouse
> Formations Python, Debian, Méth. Agiles:
> Développement logiciel sur mesure:
> CubicWeb, the semantic web framework: http://www.cubicweb.org
More information about the Cubicweb