recently added:

ABC music

links (this site):

email me
show source

links (other sites):


Hippos Technical Systems BV - Larry Myerscough

These pages contain information about my family, my company, my hobbies and myself.
hide surround

python source of 'phileas_project/'

# -*- encoding: utf8 -*-
import sys, os, time
from phileas import _html40 as h

import cgi, cgitb, urlparse
# cgitb.enable()

def text2modulename(text):
    prefix = ('_','')[text[0].isalpha()]
    return prefix+text.replace(' ','_').replace("'","__")
def modulename2text(name):
    return (name.lstrip('_')).replace('__',"'").replace("_"," ")

class Page(object):
    topDir = os.path.split(__file__)[0]
    styleSheet = "/.style/papa.css"
    icon = "/.images/logo.jpg"
    errOutput = []
    dateTimeFormat = "%Y %b %d %a %H:%M"
    dateTime = None
    name = os.path.splitext(os.path.basename(__file__))[0]
    metaDict = {'http-equiv':"content-type", 'content':"text/html; charset=utf-8"}
    _title = None # => use basename of page as page title - unless overruled.

    def __init__(self, **kw):
        self.uri = os.environ.get('REQUEST_URI','(no uri context)') = kw
        if self.dateTime is None:
            pTime = os.stat(sys.argv[0]).st_ctime,
            self.dateTime = time.strftime('%Y %b %d %a %H:%M', time.gmtime(*pTime))
        self.nameToPrint = modulename2text(

    def resolveData(self, **kw): #just a 'hook' at this level

    def title(self, **kw):
        return self._title or self.nameToPrint

    def href(self, url, text=None):
        return h.a(href=url) | (text or os.path.split(url)[1])

    def head(self, **kw):
        return h.meta(**self.metaDict) | (
            (self.styleSheet and
      "text/css", rel="stylesheet",
      "image/x-icon", rel="icon",
            h.title | (h | self.title()),

    def write(self, s):
        """ We provide our own 'write' function so that we can handle
        our own standard error output.

    def body(self, **kw):
        print >>sys.stderr, \
"(gratuitous 'error' output) current directory is: '%s'" % os.getcwd()
        return ('€ default body of content',
                h.p | 'end of content'

    def html(self):
        return h.html | (
            h.head | self.head(),
            h.body | ( self.body(), h.pre | self.errOutput)

    def present(self, **kw):
        #sys.stderr = self
        print ("Content-type: text/html;charset=UTF-8\n\n") # the blank line really matters!
        print (self.html())

    def asFileName(self, path):
        if path[0] != '/':
            return path
        return self.topDir + path

    def asUrl(self, fileName):
        if fileName[0] != '/':
            return fileName
        return fileName
def main(pageClass,  **kw):
    uri = os.environ.get('REQUEST_URI')
    if uri:
        o = urlparse.urlparse(uri)
        path = os.environ['DOCUMENT_ROOT'] + o[2] # o.path # geturl()
        #print ("path=", path)
        if not os.path.isdir(path):
            path = os.path.split(path)[0]
        kw.update(cgi.parse_qs(o[4])) #o.query))
        for p in sys.argv[1:]:
            key_, val_ = p.split('=') 
            kw[key_] = val_.split(',')
    page = pageClass(**kw)
    if uri:
        sys.stderr = page
        print ("Content-type: text/html;charset=UTF-8\n\n") # the blank line really matters!
    print (page.html())

if __name__=="__main__":
This Panel on the Right is used for local navigation - not yet fully implemented as you can see!