Re: a seriously naughty thought...
Jonathan Hogg <[email protected]> Thu, 12 Sep 2002 14:57:29 +0100
| Newsgroups | gmane.comp.sysutils.ark.devel |
|---|---|
| Organization | One Good Idea Ltd. |
| Message-ID | <B9A65BD9.11194%[email protected]> |
On 12/9/2002 10:55, Will Partain wrote:
> Anybody got any thoughts re a pure Python ARK world?
Heh, many ;-) I'm sure you can guess them based on my past postings, but I
don't want to disappoint, so here they are:
My main concern with a pure Python ARK world is that Python isn't an
application-specific language. This is great because you get the arbitrary
logic of a complete programming language, but poor because what used to be
application-specific configuration files become arbitrary logic.
For instance, in true Arusha style, I like to break out all my sysadmin bits
into ARK "Things". So I have things for domains and websites. The prototypes
for these contain the necessary methods to spit out, for example, tinydns
config entries and Apache virtual server configs. The actual configs for the
domains and websites are fairly simple files looking something like
(simplifying for example's sake):
<domain name="onegoodidea.com">
<prototypes>
<prototype team="." name="REGISTRAR-opensrs"/>
<prototype team="." name="MAIL-standard"/>
<prototype team="." name="NS-standard"/>
<prototype team="." name="WEB-arran"/>
</prototypes>
<domain-name> onegoodidea.com </domain-name>
<contact> [email protected] </contact>
<addresses><table>
<entry name="jabber"> w.x.y.z </entry>
</table></addresses>
</domain>
What this might look like in Python would depend on the inheritance model,
but choosing for argument's sake to define each Ark object as a class with
one instance (or a never-instanced class with static methods?), it might
look like:
class onegoodidea_com( REGISTRAR_opensrs, MAIL_standard,
NS_standard, WEB_arran ):
__metaclass__ = domain
domain_name = 'onegoodidea.com'
contact = '[email protected]'
addresses = { 'jabber': 'w.x.y.z' }
Since we don't have the automagic table-merging from Arusha with normal
classes, I'm using a metaclass which is going to have to figure out how to
merge together the addresses dictionaries (with metaclasses you can do very
deep magic).
OK. So we've ditched all that ugly XML nonsense, which is great within the
Arusha world, but what about from the outside? The XML files I have can be
easily parsed and generated by other tools. For instance, I can have
a PHP front-end to this that allows staff to query the domains and websites
and even generate new ones. It's fairly simple stuff involving the
application of an XML parser, an XSLT translator, some XPath queries
perhaps. I'm already investigating the possibility of hooking Arusha up to
an XML:DB compliant XML database instead of using files.
For me the value in the XML is not as a config file format for Arusha, but
as a rich database of reusable configuration information. Switching to
Python files means:
* You have to be able to parse and generate Python syntax in order to
reuse the configuration information;
* The files become less easily read and written by non-programmers - XML
doesn't care about whitespace, is familiar to HTML users, and can be
easily validated.
* The files are no longer application-specific. In particular, meta-data
becomes more of a problem. How do I specify dependencies and method
scope?
I looked at SCons and I didn't like it - precisely for the same reasons. It
doesn't look like a buildfile, it looks like a Python program that just
happens to pull the right levers to build something. Same thing for Python
distutils. I much prefer the ant model - an application-specific XML schema
which can be interpreted by different tools. An implementation of ant has
now been done in Python. How much harder would that have been if the
buildfile syntax was Java instead of XML?
However, I know my More Document Less Program theories are unpopular, so I'm
open to being convinced otherwise ;-)
:-j
--
jonathan hogg, one good idea ltd, 131 queen margaret dr., glasgow g20 8pd
http://www.onegoodidea.com/ tel:+44-(0)7976-614338 fax:+44-(0)7970-537451