Site-specific code

"Jonathan Hogg" <[email protected]>
Newsgroups gmane.comp.sysutils.ark.devel
Message-ID <[email protected]>

Hi all,

Not been making much of a contribution lately, been pretty busy.

This is a random thought that I had a while ago but didn't voice (or I
hope I didn't, if I'm repeating myself then put it down to my
advancing decrepitude).

The ark base code contains quite a lot of "sidai" functions at the
moment. This somehow doesn't sit easy with me as it blurs the boundary
between mechanism and policy and makes the sidai team "special" in
some way. I can also foresee others wanting to paste functions they
see as being "essential" into the ark codebase and hard decisions
having to be made.

So I was wondering if ark2 could get around some of this by breaking
up the codebase and providing a mechanism for demand loading team
code. The sort of thing I'm envisaging would look like:

    /item/ark-teams/sidai/arkbase-py/utils.py:
        from ark import *
        def diff_deploy( pkg ):
          name = pkg.getName()
          ...

    /item/ark-teams/sidai/packages/foo--1.3.xml
        <package name="foo">
          <deploy>
            <code language="python">
              from sidai.utils import diff_deploy
              diff_deploy( self )
            </code>
          </deploy>
        </package>

There's plenty of wacky things you can do with the Python module
loader that would make this possible. Combined with the ability to
place arbitrary information in packages via the new flexml (pronounced
like "flexible"), you could do neat things like:

    <package name="template">
      <deploy>
        <code language="python">
          from sidai.templates import generate_file
          generate_file( self.template, @@filename@@, ark=ark )
        </code>
      </deploy>
    </package>


    <package name="etc-hosts">
      <prototype name="template"/>
      <deploy>
        <param name="filename" value="/etc/hosts"/>
      </deploy>
      <template><![CDATA[
    # /etc/hosts
    # Generated from ark template package etc-hosts

    127.0.0.1 localhost localhost.localdomain
    <%
      for host in ark.getHosts():
        print "%s %s %s" % ( host.ip, host.name, host.fqdn )
    %>
    ]]></template>
    </package>

As usual, take all syntax with a large pinch of salt.

Jonathan

--
Jonathan Hogg
DB London Web Development and Support
+44 20 7547 1543 / +44 7976 614338


--

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorised copying, disclosure or distribution of the material in this e-mail is strictly forbidden.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.