[Cubicweb] comma issue in StaticVocabularyConstraint, vocabulary

Carlos Balderas carlos.balderas at gmail.com
Fri Aug 13 00:20:27 CEST 2010

Hi everyone!

I found this situation when using commas inside string values of
StaticVocabularyConstraint and vocabulary when I was creating my schema.py

The error thrown:

/yams/constraints.py", line 346, in deserialize
    return cls([eval(w) for w in value.split(', ')])
  File "<string>", line 1

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

    def deserialize(cls, value):
        """deserialize possible values from a csv list of evaluable
        return cls([eval(w) for w in value.split(', ')])

The test case:

class TestVocabulary(EntityType):

    attribute1 = String(vocabulary=('python', 'postgresql'
                                    , 'apache', 'python, apache and
postgresql' ))
    attribute2 = String(constraints=[StaticVocabularyConstraint(
                ('python', 'postgresql'
                 , 'apache', 'python, apache and postgresql'))])

cubicweb changeset:   6107

Best Regards
Carlos Balderas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cubicweb.org/pipermail/cubicweb/attachments/20100812/bd56c7f3/attachment-0186.html>

More information about the Cubicweb mailing list