Re: dynamic class instantiation

2006-02-03 Thread Volker Grabsch
Kent Johnson wrote: > Ognen Duzlevski wrote: >> I appreciate your comments. Basically, the reason why this code generator >> exists is the fact that I do not want to hard-code the resulting xml in >> any way. The users of the web/db framework of which this solution is part of >> might like the "we

Re: dynamic class instantiation

2006-02-02 Thread Ognen Duzlevski
Kent Johnson <[EMAIL PROTECTED]> wrote: > Ognen Duzlevski wrote: > > Can you suggest a better approach or did you already do that and I just > > missed > > it? :) > With the above definitions, an equivalent class is created by calling > page = classFactory( 'page', { 'name' : None, 'caption': No

Re: dynamic class instantiation

2006-02-02 Thread Kent Johnson
Ognen Duzlevski wrote: > Volker Grabsch <[EMAIL PROTECTED]> wrote: >>I'm sure you could replace 2/3 of your code with something much simpler >>(and shorter!) just by not inventing a new language and using the power >>of Python instead. > > > Hi Volker, > > I appreciate your comments. Basically,

Re: dynamic class instantiation

2006-02-01 Thread Ognen Duzlevski
Volker Grabsch <[EMAIL PROTECTED]> wrote: > Ognen Duzlevski wrote: > > Kent Johnson <[EMAIL PROTECTED]> wrote: > >> Ognen Duzlevski wrote: > >> > Say I got "page" as a string. How do I go about > >> > instantiating a class from this piece of information? To make it > >> > more obvious how do I cr

Re: dynamic class instantiation

2006-01-31 Thread Volker Grabsch
Ognen Duzlevski wrote: > Kent Johnson <[EMAIL PROTECTED]> wrote: >> Ognen Duzlevski wrote: >> > Say I got "page" as a string. How do I go about >> > instantiating a class from this piece of information? To make it >> > more obvious how do I create the page() class based on the "page" >> > string

Re: dynamic class instantiation

2006-01-31 Thread Ognen Duzlevski
Kent Johnson <[EMAIL PROTECTED]> wrote: > Ognen Duzlevski wrote: > > Say I got "page" as a string. How do I go about > > instantiating a class from this piece of information? To make it > > more obvious how do I create the page() class based on the "page" > > string I have? > Use getattr(). H

Re: dynamic class instantiation

2006-01-30 Thread Kent Johnson
Ognen Duzlevski wrote: > I have a parser that will go through the language definition > file and produce the following as a separate .py file: > > class page(object): > def __init__(): > self.name = None > self.caption = None > self.functions = [] >

Re: dynamic class instantiation

2006-01-30 Thread Larry Bates
Ognen Duzlevski wrote: > Larry Bates <[EMAIL PROTECTED]> wrote: >>> Now I want to use something like xml.dom.minidom to "parse" the >>> .xml file into a set of classes defined according to the "language >>> definition" file. The parse() method from the xml.dom.minidom >>> package will return a d

Re: dynamic class instantiation

2006-01-30 Thread Ognen Duzlevski
Larry Bates <[EMAIL PROTECTED]> wrote: > > Now I want to use something like xml.dom.minidom to "parse" the > > .xml file into a set of classes defined according to the "language > > definition" file. The parse() method from the xml.dom.minidom > > package will return a document instance and I ca

Re: dynamic class instantiation

2006-01-30 Thread Larry Bates
Ognen Duzlevski wrote: > Hi, I have a "language definition" file, something along the lines of: > > page :: > name : simple > caption : simple > function : complex > > function :: > name : simple > code : simple > > component :: > name : simple > type :

dynamic class instantiation

2006-01-30 Thread Ognen Duzlevski
Hi, I have a "language definition" file, something along the lines of: page :: name : simple caption : simple function : complex function :: name : simple code : simple component :: name : simple type : simple dataset : complex