Re: dynamic class instantiation



Larry Bates <larry.bates@xxxxxxxxxxx> 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 can get the node
> > name from it. 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? I want to make this generic so for me the language
> > definition file will contain pages, functions, datasets etc. but
> > for someone else mileage will vary.
> >
> > Thanks,
> > Ognen

> I think you should rethink this approach. Why have 3 different
> files instead of just defining everything as Python classes?
> Get good baseclass definitions and use OOP inheritance to
> create your specific class instances. I think mixing XML,
> language definition file (LDF), LDF to python parser is a LOT
> harder (and slower) than just writing the classes outright.

Hi Larry,

here is the whole story. I have a database (postgres) xml "transformer"
and substitution engine. It is written entirely in plpgsql and the whole
environment works something like this. Someone writes an xml file that
defines a web page. This xml file is then fed into the database at the
time of development. Now at runtime a mod_python apache webapp makes a
request for a certain page. Its xml form is retrieved from the database
and a lot of data substitution goes on. Also parts of the page are "masked"
out by the database engine based on the "level" of the person requesting
the page. The "transformed and substituted" xml is then spit back to the
webapp which now applies an xml->html transformation and presents the
final result to the user. So, I want people to be able to "define" their
own "language" when it comes to page definitions. And instead of rewriting
the xml file parser I want to be able to generate the parser.

Thanks,
Ognen
.



Relevant Pages

  • Re: DISCOVER_XML_METADATA
    ... expansion of ASSL XML returned by the server. ... You could do ExpandObject for the server in step 1. ... you could request ExpandObject for that database -- this is step ... all cubes and nothing else. ...
    (microsoft.public.sqlserver.olap)
  • Re: Preservation of namespace prefixes in XML datatype
    ... representation well beyond merely preserving the logical meaning. ... > Now the ANSI/ISO SQL-2003 standard makes it pretty clear that the XML ... all the guarantee the database gives you is that we preserve the ... >> makes changes in namespace prefixes, will I the user/developer have the ...
    (microsoft.public.sqlserver.xml)
  • Re: Wanted:MAIL.MAI structure definition
    ... a relational database is more flexible in the retrival of data. ... Perhaps this impact has been softened as hardware has gotten faster, but, overhead is overhead, and if you weren't using the advances in hardware for overhead, those designs that have less overhead would also gain from the faster hardware. ... RFC822 header because your XML parser wouldn't be able to understand new ...
    (comp.os.vms)
  • Re: Rework [Was: Static vs. Dynamic typing...]
    ... Agile projects have an extraordinarily low chance of a big change. ... Suppose you start with XML files, and by Iteration 6 the ... Switching to a database is now cheaper than morphing XML files into a ...
    (comp.programming)
  • Re: Data source options
    ... > customer to access the app and own the data. ... and by keeping the "main database" closer to the "web application ... I've been watching the "maturation" of the XML space. ... Visage ISN'T free - but it is cheap as chips ...
    (comp.databases.pick)