PyYAML: How to register my yaml.YAMLObject subclasses?

M

Matthew Wilson

I suspect the solution to my problem is something really trivial.

I wrote a module called pitz that contains a class Issue:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,436
Messages
2,571,696
Members
48,796
Latest member
Greg L.
Top