Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

calling feed.dump(validate=False) still validates reports #2

Open
jjguy opened this issue Feb 5, 2015 · 0 comments
Open

calling feed.dump(validate=False) still validates reports #2

jjguy opened this issue Feb 5, 2015 · 0 comments

Comments

@jjguy
Copy link
Contributor

jjguy commented Feb 5, 2015

Traceback (most recent call last):
  File "/usr/lib/python2.6/site-packages/cballiance/feed_blueprint.py", line 93, in get_feed
    feed_io.write(feed.dump(validate=False))
  File "/usr/lib/python2.6/site-packages/cbfeeds/feed.py", line 25, in dump
    return json.dumps(self.data, cls=CbJSONEncoder, indent=2)
  File "/usr/lib64/python2.6/json/__init__.py", line 237, in dumps
    **kw).encode(obj)
  File "/usr/lib64/python2.6/json/encoder.py", line 367, in encode
    chunks = list(self.iterencode(o))
  File "/usr/lib64/python2.6/json/encoder.py", line 309, in _iterencode
    for chunk in self._iterencode_dict(o, markers):
  File "/usr/lib64/python2.6/json/encoder.py", line 275, in _iterencode_dict
    for chunk in self._iterencode(value, markers):
  File "/usr/lib64/python2.6/json/encoder.py", line 306, in _iterencode
    for chunk in self._iterencode_list(o, markers):
File "/usr/lib64/python2.6/json/encoder.py", line 204, in _iterencode_list
    for chunk in self._iterencode(value, markers):
  File "/usr/lib64/python2.6/json/encoder.py", line 317, in _iterencode
    for chunk in self._iterencode_default(o, markers):
  File "/usr/lib64/python2.6/json/encoder.py", line 323, in _iterencode_default
    newobj = self.default(o)
  File "/usr/lib/python2.6/site-packages/cbfeeds/feed.py", line 14, in default
    return o.dump()
  File "/usr/lib/python2.6/site-packages/cbfeeds/feed.py", line 144, in dump
    self.validate()
  File "/usr/lib/python2.6/site-packages/cbfeeds/feed.py", line 175, in validate
    if not re.match("^[a-zA-Z0-9-_.]+$", self.data["id"]):
  File "/usr/lib64/python2.6/re.py", line 137, in match
    return _compile(pattern, flags).match(string)

Note the following lines:

    feed_io.write(feed.dump(validate=False))
    ...
    return json.dumps(self.data, cls=CbJSONEncoder, indent=2)
    ...
    return o.dump()
    ... 
    self.validate()

The caller passed validate=False() but when each object is passed through CbJSONEncoder, it calls o.dump() -- and triggers validation on the sub-objects.

Recommend:

  • having two CbJSONEncoder classes - one that validates and one that does not
  • updating the CbFeedInfo and CbReport dump() functions to take validate kwarg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant