PyYAML: How to register my yaml.YAMLObject subclasses?
Matthew Wilson
matt at tplus1.com
Sat Oct 11 11:49:30 EDT 2008
I suspect the solution to my problem is something really trivial.
I wrote a module called pitz that contains a class Issue:
>>> pitz.Issue.yaml_tag
u'ditz.rubyforge.org,2008-03-06/issue'
Then I try to load a document with that same tag, but I get a
ConstructorError:
ConstructorError: could not determine a constructor for the tag
'!ditz.rubyforge.org,2008-03-06/issue'
I think there's some namespace/scoping problem, because when I define
the same class in my interpreter and then run yaml.load(issue_file),
everything works OK.
So, how do I tell yaml to build pitz.Issue instances when it runs across
that tag?
Do I need to use add_constructor? If so, I'd *really* appreciate some
example usage.
Thanks!
Matt
More information about the Python-list
mailing list