[Cubicweb] customize rendering of a specific attribute in cw
stephane.bugat at free.fr
Fri May 25 10:01:55 CEST 2012
Ok. If I get this well, this means I have to overwrite the method "def printable_value(self, name)" in my "class Airport(EntityType)" and select the case when the name corresponds to "latitude" or "longitude", right?
Or do I have to do it in the equivalent AnyEntity class that I have defined?
----- Mail original -----
De: "aurélien campéas" <aurelien.campeas at gmail.com>
À: "Stéphane Bugat" <stephane.bugat at free.fr>
Cc: cubicweb at lists.cubicweb.org
Envoyé: Vendredi 25 Mai 2012 09:29:43
Objet: Re: [Cubicweb] customize rendering of a specific attribute in cw
On entity classes, there is a printable_value method that can also be customized (on Airport in your case) .
This should be invoked (automatically) by the 'attribute' view (in views/primary.py).
2012/5/25 Stéphane Bugat < stephane.bugat at free.fr >
I was wondering if there was a way to customize the rendering of a specific attribute of an entity.
For instance, I have an Airport entity with 2 Float(), latitude and longitude. These floats are usually displayed using the form xx°yy'zz'' (for instance 45.658333 ==> 45° 39' 30.00 " N).
At present I have modified the Airport PrimaryView function render_attributes(), but this means I have to set up how all other attributes are rendered. Moreover I have to do this for all specific context views of the Airport object.
Another option would be to define a full Entity "Coordinate" and to put an inlined relation between Airport and Coordinate, but that would be a hammer to crush a fly.
Thanks for any help!
Cubicweb mailing list
Cubicweb at lists.cubicweb.org
More information about the Cubicweb