D'oh!
In the generateDS documentation, using the "people" example, you have
code that looks like this:
def test(names):
people = api.people()
for count, name in enumerate(names):
id = '%d' % (count + 1, )
person = api.person(name=name, id=id)
people.add_person(person)
people.export(sys.stdout, 0)
when it ought to look like this:
def test(names):
people = api.peopleType()
for count, name in enumerate(names):
id = '%d' % (count + 1, )
person = api.personType(name=name, id=id)
people.add_person(person)
people.export(sys.stdout, 0)
It should call "peopleType()" and "personType()" instead of "people()"
or "person()."
A simple mistake I should have noticed straight away. Sorry to pester you.
Regards,
Allyn
On 09/21/2011 04:50 PM, Allyn Treshansky wrote:
> Hi Dave,
>
> Many thanks for this quick response. I have successfully run the
> people demo and your simple application.
>
> I'm not sure why my simple application is not working, but I really
> suspect it is an environment issue and not an issue with your or my
> code. I'll let you know what I find out tonight.
>
> Regards,
> Allyn
>
> On 09/20/2011 04:33 PM, Dave Kuhlman wrote:
>>> From: Allyn Treshansky
>>> Sent: Friday, September 16, 2011 3:56 PM
>>> Hello.
>>>
>>> Apologies if this is a naive question; I am very new to Python.
>>> I am hoping to use generateDS to generate a Python class based on
>>> an XSD file that I can then associate with a Django webform in
>>> order to allow users to create and edit XML files.
>>>
>>> I am looking at the documentation at
>>> http://www.rexx.com/~dkuhlman/generateds_tutorial.html. In
>>> section 6.2 it provides some sample code (tmp.py) to use the
>>> generated API module. When I try and run this code, though, I
>>> get the following errors:
>>>
>>> <snip>
>>> Traceback (most recent call last):
>>> File "tmp.py", line 12, in<module>
>>> test(['albert', 'betsy', 'charlie'])
>>> File "tmp.py", line 5, in test
>>> people = api.people()
>>> AttributeError: 'module' object has no attribute 'people'
>>> </snip>
>>>
>>> Any ideas on what I am doing wrong?
>>>
>>> Many thanks for your time and your help.
>>>
>>> Regards,
>> Allyn -
>>
>> Good to hear from you.
>>
>> Without knowing what code you ran, I'm not too sure what went wrong
>> and why.
>>
>> However, here are a couple of things that you can try in order to
>> get a little more understanding of how generateDS.py works.
>>
>> 1. Run the People demo.
>>
>> After unrolling the distribution with something like this:
>>
>> $ tar xf generateDS-2.6a.tar.gz
>> Then, try the People demo with something like the following:
>>
>> $ cd generateDS-2.6a/Demos/People
>> $ ../../generateDS.py -o tmp1sup.py people.xsd
>> $ python tmp1sup.py people.xml
>>
>> You should see the contents of people.xml printed out to the screen.
>> It's using the export methods in the various classes to write the
>> contents to stdout.
>>
>> 2. Write a simple application that uses the generated API. Here is a
>> sample:
>>
>>
>> # ===============================================
>> import sys
>> import tmp1sup as api
>>
>> def test():
>> people = api.peopleType()
>> person = api.personType(name='Albert Ableperson')
>> people.add_person(person)
>> people.export(sys.stdout, 0)
>>
>> test()
>> # ===============================================
>>
>> You can look at classes peopleType and personType in the generated
>> file (tmp1sup.py in this case) to find out what you can do with
>> these classes, for example, (1) how to create an instance, (2) how
>> to set values in the instance, and (3) how to export (write out) the
>> instance. The example app above does those 3 things.
>>
>> From your message, it seems that you were trying to do something
>> like what this little app is doing. Hopefully this sample will help
>> you to get started.
>>
>> Hope this helps.
>>
>> I'll try to work over the tutorial. Perhaps I can make it easier to
>> use in a future version.
>>
>> - Dave
>>
>>
>>
>>
>>
>>
>
------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
_______________________________________________
generateds-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/generateds-users