[Cubicweb] comma issue in StaticVocabularyConstraint, vocabulary

Sylvain Thénault sylvain.thenault at logilab.fr
Mon Aug 16 09:23:13 CEST 2010


Hi,

On 15 août 21:27, Aurélien Campéas wrote:
> Le 13/08/10 00:20, Carlos Balderas a écrit :
> >I found this situation when using commas inside string values of
> >StaticVocabularyConstraint and vocabulary when I was creating my
> >schema.py file.
> >
> >The error thrown:
> >
> >/yams/constraints.py", line 346, in deserialize
> >     return cls([eval(w) for w in value.split(', ')])
> >   File "<string>", line 1
> >      u'python
> >             ^
> >
> >When it happens:
> >
> >At the moment to run the cube instance...
> >
> >When vocabulary values options have a comma and a SPACE inside the tuple
> >element, for example : ('python, apache ...') this exception is thrown,
> >in case you remove the SPACE after the comma like ('python,apache ...')
> >every thing works fine.
> >
> >It should be noted that the scheme of the database is successfully
> >created, this issue occurs at the moment of running the cube instance.
> >
> >The classmethod in question:
> >
> >/yams/constraints.py", line 346
> >
> >@classmethod
> >     def deserialize(cls, value):
> >"""deserialize possible values from a csv list of evaluable strings"""
> >         return cls([eval(w) for w in value.split(', ')])
> >
> 
> I guess eval(w.strip()) for w in ...) would do it, but I'm curious
> to see why we eval there ...

because vocabulary can be used for Int for instance. This pb could be 
easily fixed with proper escaping, I'll fix that this week.

-- 
Sylvain Thénault                               LOGILAB, Paris (France)
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