[Cubicweb] Access 'data_url' in postcreate.py

Sylvain Thénault sylvain.thenault at logilab.fr
Fri Aug 24 14:46:05 CEST 2012


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 mind,
and that some resources may only be available for one or another side.
'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 triggered
without a session as context (ie the _cw object you get on the repository 
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 need
access to such ressources.
-- 
Sylvain Thénault, LOGILAB, Paris (01.45.32.03.12) - Toulouse (09.54.03.55.76)
Formations Python, Debian, Méth. Agiles: http://www.logilab.fr/formations
Développement logiciel sur mesure:       http://www.logilab.fr/services
CubicWeb, the semantic web framework:    http://www.cubicweb.org



More information about the Cubicweb mailing list