Subject: | XML::Atom::Link subclass problem |
I was having problems with Net::Google::Calendar.
I'd defined Net::Google::Calendar::WebContent to be a subclass of
XML::Atom::Link. When I instantiated it with various values and printed
it out the XML it came out fine however if I then added it to an
Net::Google::Calendar::Entry (which ISA XML::Atom::Entry) and then
printed out the XML again my values were missing.
This didn't happen if I added a plain XML::Atom::Link object with the
same values.
It turned out to be a problem in XML::Atom::Base's
mk_object_list_accessor - you were checking ref ($obj) eq $ext_class
when really you should be checking to see that $obj ISA $ext_class.
I've attached a patch but looking through the rest of the code it looks
like there are other places where the same pattern of code is occurring.
Thanks,
Simon
Subject: | XML-Atom-Base.patch |
--- /usr/local/lib/perl5/site_perl/5.8.8/XML/Atom/Base.pm Fri Apr 27 12:31:32 2007
+++ Base.pm Fri Apr 27 12:31:57 2007
@@ -292,7 +292,7 @@
my($stuff) = @_;
my $ns_uri = $ext_class->element_ns || $obj->ns;
- my $elem = ref $stuff eq $ext_class ?
+ my $elem = (ref $stuff && UNIVERSAL::isa($stuff, $ext_class)) ?
$stuff->elem : create_element($ns_uri, $name);
$obj->elem->appendChild($elem);