[Cubicweb] Build the absolute url of an entity directly from database

Adrien Di Mascio adrien.dimascio at logilab.fr
Mon Jan 28 09:59:29 CET 2013

Hi Carlos,

Le 28/01/2013 01:48, Carlos Balderas a écrit :
> One thing I am missing is the absolute_url of every requested entity,
> would it be possible to get in the same rql sentence just by doing some
> joins?
> e.g.
> Any X, Z WHERE X eid 1234, X some_cwmeta_relation Y, Y entity_url_key Z
> so Z can give the key to build the absolute_url directly from database.

There is no such information in the database, it's purely defined by 
your application's logic (although cwuri could be used for that). 
Therefore, it should only be a matter of retrieving once and for all 
every attributes from the database that are used to build your absolute 

If absolute_url() calls are too time consuming for your specific case, 
especially because it looks for possible external source information, 
you could override it in your entity classes.

Finally, if your absolute urls are only eid based, you could always do 
something like :

   req.execute('Any X,Y,"%s" +CAST(String, X) WHERE X some_relation Y'
               % req.vreg.config['base-url'])

Adrien Di Mascio - LOGILAB, Paris (France).
Formations - http://www.logilab.fr/formations
Développements - http://www.logilab.fr/services
Gestion de connaissances - http://www.cubicweb.org/

More information about the Cubicweb mailing list