Object has no attribute 'export'
Brought to you by:
dkuhlman
Hi Dave,
I used the latest version of generateDS (v2.40.1) and there seems to be a problem.
The generated code has __str__ method in the GeneratedsSuper class. This is new since the version 2.36.2
The problem is with the following:
def __str__(self):
...
from io import StringIO
output = StringIO()
self.export(
output,
settings['str_indent_level'],
pretty_print=settings['str_pretty_print'],
namespaceprefix_=settings['str_namespaceprefix'],
name_=settings['str_name'],
namespacedef_=settings['str_namespacedefs']
)
strval = output.getvalue()
output.close()
return strval
The self.export method does not exist because it is commented out. It gets commented out because in the template those lines are prefixed by #xmldisable# and we are using --disable-xml flag.
Mustafa,
Oops.
OK, so I've "disabled" generation of that
__str__method. Actually, it's generated, but is commented out. That method is intended as a convenience for a programmer who wants to display an object while debugging. Am I right that you can do without it?With the new code and when using
--disable-xml, when you ask for a string representation, you will see:Attached is a patch file.
I did some checking. But, I'm a little unsure about possible dependencies in that code. Could you try this patch and let me know. If all is well with it and you do not need that
__str__method, I'll create a new release.Dave
Hi Dave, the patch works for me.
Although having string representation could be nice. Something like the following when xml is not enabled:
Class1(field1=value1, field2=value2, field3=Class2(field4=value4))However, it is not critical right now.
Mustafa,
Uploaded the fix for
__str__andexportwith--disable-xml.It's version 2.40.2.
Thanks for the help with this.
Dave
Mustafa,
I introduced a bug. I got the indentation of
__str__wrong.It is fixed in version 2.40.3.
I apologize. Hope I got it right this time.
I'll look into your suggestion for the improved
__str__method, next week.Dave