[Web-SIG] cusom config files. was (PasteDeploy 0.1)

Michal Wallace michal at sabren.com
Wed Aug 24 09:05:36 CEST 2005

On Wed, 24 Aug 2005, Phillip J. Eby wrote:

> At 11:46 PM 8/23/2005 -0400, Michal Wallace wrote:
> > On Tue, 23 Aug 2005, Phillip J. Eby wrote:
> > > I would say that there is definitely a real need for a
> > > declarative Python object definition syntax that supports
> > > nesting and internal references, and so if we can come up
> > > with something good, it can and should *become* a standard for
> > > such purposes, well beyond the scope of its initial mission
> > > of being a WSGI deployment syntax.
> > Well, if that's all you want to do, then
> > why not just add some syntactic sugar
> > to pickle?
> pickles aren't a declarative format; they're procedural.

Huh. So it is. I didn't know that. :)

I guess my real point is that it seems like 
a huge leap to come up with a whole new language, 
when python itself can do the job just fine. 

For example, if you set up a coding standard 
where data classes have an empty constructor,
then you can do something like this:

class Instance(Class, **kwargs):
    def __init__(self):
        self.class_ = Class
        self.kwargs = kwargs

    def eval(self):
        obj = self.class_()
        for k, v in kw.items():
            setattr(obj, kw)
        return obj

and maybe this for forward references:

class Promise(thunk):
    def __init__(self, thunk):
        self.thunk = thunk

    def eval(self):
        return self.thunk()

Then you can make all kinds of complicated things

class Node:

def aComplicatedStructure():
   loop = Instance(Node, next=Promise(lambda: loop))
   return Instance(Node, child=loop, other={"a":"b"})

The only thing missing is to walk the tree and replace 
any Promise or Instance node with the result of its 

I'm sure there's a way to do all that without the 
restriction on __init__, too... Just add another 
class along those lines that handles parameters to
the constructor.

Now, I'm *not* saying this is the way to go for WSGI.
But if you're going to shoot for the moon and propose 
a standard to use for *everything*, I think plain old 
python is more than adequate.

Michal J Wallace
Sabren Enterprises, Inc.
contact: michal at sabren.com
hosting: http://www.cornerhost.com/
my site: http://www.withoutane.com/

More information about the Web-SIG mailing list