By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,369 Members | 1,147 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,369 IT Pros & Developers. It's quick & easy.

PyYAML: How to register my yaml.YAMLObject subclasses?

P: n/a
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
Oct 11 '08 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.