On Sun, 2003-06-29 at 06:00, deelan wrote:
> Ian Sparks wrote:
> > Its a slow Friday afternoon, I hope folks will forgive my public musings.
> >
> > I was looking at Zope 3's configuration XML scheme, ZCML (1) and thought to
> > myself how horrible using XML files is for web-site configuration tasks.
> same here, i worked with a .NET MVC framework with
> an XML configuration file and i've found it too verbose and
> a pain to maintain.
>
> you may want to take a look at YAML for this purpose:
I've been doing more and more declarative programming of this style
directly in Python, and it works quite well, while still allowing clever
tricks that a static declaration (like XML or YAML) doesn't allow. For
the most part I've been using a general style like:
class Declarative(object):
def __init__(self, **kw):
for key, value in kw.items():
setattr(self, key, value)
def __call__(self, **kw):
if not kw: return self
new = self.__dict__.copy()
new.update(kw)
return self.__class__(**new)
Then, accept either an instance or a class anywhere you want
configuration (just call it with no arguments to force it to be an
instance). A site might look like:
class MySite(Site):
root = '/www/mysite'
serveOnly = ['*.py']
# and so on...
Inheritance works nicely for configuration -- it's a natural way to
express it. You can also create the configuration dynamically, or if
you want to create it from XML or YAML it would still be fairly easy.
It's nice to also have the possibility of including methods in the
configuration, as static configuration values often aren't fully
expressive.
Ian
-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100006ave/direct;at.asp_061203_01/01
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss