Making classes from Metaclasses globally available

Michele Simionato michele.simionato at poste.it
Thu Jun 17 04:17:13 EDT 2004


"Jean-François Doyon" <jfdoyon at methane.ca> wrote in message news:<5d6Ac.34929$7H1.1286929 at news20.bellglobal.com>...
> Why?
> 
> Well, basically I'm looking at writing an IDE of sorts.  It should allow the
> viewing editing of text files.
> 
> Catch is, said text files are structured much like XML, but they're NOT XML.
> 
> I want the application to be extensible, and not be stuck to a particular
> version/schema of this file.
> 
> So the idea is, create one or more "schemas" to describe what I'm going to
> be looking for and then parsing.
> 
> Because the format of said text file is structured in a very XML-like way, I
> thought it'd make sense to simply
> dynamically create a tree of objects, which are instances of relevant
> classes.  But because of my statement above
> I don't know in advance what classes there might be and so on.
> 
> So I figured I'd use something like MetaClasses to do it.  I've got the
> basic schema parsing and class creation
> in place already, the problem is that I want to keep the class creation and
> the parsing fairly seperate.
> 
> I'm thinking the parsing functionality will be extra polated from the schema
> also, but be part of the classes (The
> file structure is consistent enough to allow this I think ...).
> 
> Anyways, it's not all entirely clear in my mind yet ... But that's the basic
> idea.
> 
> But I just want classes created from the schema to be available  globally so
> that when the classes need to interact with each
> other (More precisely, one instance needs to instanciate another class and
> make it an attribute of self) I don't need to pass
> a list of classes or soemthing similar around everywhere.
> 
> Did that make any sense ? :)
> 
> Admitedly, I've kind of thought up a way to do it with a unique class ...
> But I don't like that design as much ... The model
> I describe above fits really well with the application in question.  I've
> even seen something similar done in PHP with a
> web interface, though it was much more restricted in it's flexibility and
> capability to adapt to any kind of schema.
> 
> Metaclasses seem to open the door to greater flexibility by not having to
> know ANYTHING in advance.
> 
> If you're familiar with the generateDS script, I've got something like that
> in mind, but not for XML.
> 
> If anyone has a better idea on how to go about this, or knows of
> tools/examples that implement this kind of scenario,
> I'd love to hear about it!
> 
> Thanks,
> J.F.
> 

Do you know about David Mertz's article on XML and declarative mini-languages?
It appeared some time ago on IBMdeveloperWorks. In the scenario you are
showing to us metaclasses could be indeed a sensible solution, but not
necessarely the best one.


               Michele Simionato



More information about the Python-list mailing list