From: Tennis Smith
Sent: Wednesday, July 8, 2009 1:11:20 PM
Subject: Deriving Object Type

> Hi,
> 
> In the schema I sent you, there an attribute called
> "CancellationDateTime".  This is actually an object of type
> "DateTime".  If I'm dynamically creating objects, how can I
> programmatically figure out that setting "CancellationDateTime"
> actually needs "DateTIme"?
> 

Tennis -

There is some support for this in generateDS.py, but it is hidden
and is currently only used for user methods.  See:
http://www.rexx.com/~dkuhlman/generateDS.html#user-methods

Make the following change to generateDS.py.  Then, I believe that
it will give you what you are asking for:

# -----------------------------------------------------------------
--- Tmp/generateDS.py   2009-07-09 08:42:22.000000000 -0700
+++ generateDS.py       2009-07-09 08:41:05.000000000 -0700
@@ -3085,7 +3085,7 @@
     else:
         s1 = 'class %s%s(GeneratedsSuper):\n' % (prefix, name)
     wrt(s1)
-    if UserMethodsModule:
+    if True:
         generateMemberSpec(outfile, element)
     wrt('    subclass = None\n')
     superclass_name = 'None'
# -----------------------------------------------------------------

Here is a comment that explains a bit about what that change will
cause generateDS.py to produce:

#
# Generate a class variable whose value is a list of tuples, one
#   tuple for each member data item of the class.
#   Each tuble has 3 elements: (1) member name, (2) member data type,
#   (3) container/list or not (maxoccurs > 1).

OK, so actually, it generates a list of instances that are
effectively 3-tuples.

Here is an example -- Something like the following is added to each
generated class:

    _member_data_items = [
        _MemberSpec('Size', 'xs:integer', 0),
        _MemberSpec('Code', 'xs:string', 0),
        _MemberSpec('Name', 'xs:string', 0),
        o
        o
        o
        ]

Would a dictionary in which you could do a look-up by member
name be more convenient?

If this is what you need and you think this might be generally
useful, I'll add a command line option so that you can generate
this even when you do not want the user methods stuff.

> Hope that makes some kinda sense. ;-)

Hope my reply does, too.

- Dave

-- 


Dave Kuhlman
http://www.rexx.com/~dkuhlman

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
generateds-users mailing list
generateds-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/generateds-users

Reply via email to