Peter's Blog

Redefining the Impossible

Posts made during March 2004


To investigate: http://www.nedstat.com/uk/

Hit counter with all kinds of cool statistics. This is assuming I get any hits.


Filed under: untagged

Add a comment

On a new whim, installing plone on oldlap server. This is a 'content management system' running on top of Zope. I played zope once but found it mind-bogglingly complex and underdocumented. Plone may be better: Nasa use it for their mars rover website.

I like the idea of it being all in python: ultimately I could hack it in any direction. Also zope allows web-based development so I can centralise my efforts.

Using apt-get to install. I had to point it at an unstable woody archive. I told it to apt-get install plone and its decided to upgrade loads of stuff.

Had a problem with a cache overflowing that I had to fix by creating a apt.conf file and adding::

APT::Cache-Limit 10000000;


Filed under: python

Add a comment

Dell laptop has no reset button. In Ulead Photo Impact, if you alter an object size from 50 to, say, 50000 it tries to make the object that size in the background. This involves burning 200% CPU time at real time priority for the rest of eternity. The laptop refuses to log off, hibernate or switch off the laptop is brought to it's knees (ha ha). A windows pc needs a reset button like it needs a hard disk.

Had to pull the power and the battery.


Filed under: dell windows

3 Comments

I have been negligent in my blogging. I have been working on a new look for the blog based on CSS. I have created a vision in khaki. Assorted notes:

I have been negligent in my blogging. I have been working on a new look for the blog based on CSS. I have created a vision in khaki. Assorted notes:

  • I don't quite understand how the float thing works . I drop into tables if I just want, for example, one thing to the left and another to the right. This should work on old browsers.

System Message: WARNING/2 (<string>, line 5)

Block quote ends without a blank line; unexpected unindent.

  • Block Quotes and preformatting look good if put in a box with a different background colour.

  • I got gecko (i.e. Mozilla engine) preview working in HTML-Kit by unzipping the entire mozilla .zip file and registerins mozctl.dll and mozctlx.dll. Moz seems to use smaller fonts than IE.

  • I takes thought, experimentation and inspiration from other websites (not total plagiarism) to make it look at all acceptable.


Filed under: blog

Add a comment

Discovered the DadNotez->Blog script was adding blank lines within table definitions which broke them. Tables are working.


Filed under: blog

Add a comment

Rejigged website generation. Decided to try using Cheetah (www.cheetahtemplate.org), a python templating library. This allows me to modify my html template, putting in variable names to be replaced by code. It was very easy to get going and it looks very powerful: you can virtually embed python code in your html.

Example:

#
from Cheetah.Template import Template

strTemplate = """<body>
                A $simple example.<br/>
                 Hello $names['wibble'], how are you today?<br/>
                 $MYGOD( 'software')
                 <table>
                 #for oEntry in $ENTRIES
                 <tr><td>$oEntry['Title']</td><td>$oEntry['Date']</td></tr>
                 #end for
                 </table>
        </body>"""

def MyGod( strPara):
        return "Now that's what I call " + strPara

oEntries = [ { 'Title': 'Fred', 'Date': 'Now'},
                                { 'Title': 'Noreen', 'Date': 'blub'}
                        ]

oNames = { 'wibble': 'Peter' }

oSearchList = {
                'simple': "Simple",
                'names': oNames,
                'MYGOD': MyGod,
                'ENTRIES': oEntries
                }

strHTML = Template( strTemplate, searchList=[oSearchList])

print strHTM

Generates:

<body>
        A Simple example.<br/>
         Hello Peter, how are you today?<br/>
         Now that's what I call software
         <table>
         <tr><td>Fred</td><td>Now</td></tr>
         <tr><td>Noreen</td><td>blub</td></tr>
         </table>
</body>

The advantage of all this complexity over strHTML.replace( '$simple', strSimple) is in the way that it allows loops to be expanded. The system as it stands allows me to create the HTML and make it pretty using HTML-Kit, then use python to populate it up. My python script has no layout HTML in it. The only other HTML involved is that generated from the DayNotez entries using DocUtils.


Filed under: cheetah daynotez python

Add a comment

ISilo'd the blog and it looks good to me. My biggest dislike is the way long lines of preformatted text overflow the boxes. I think there are two solutions:

  1. Wrap the long lines in python

  2. Remove the boxes, go for horizontal bars instead.

0ption 1 is a bodge, 2 is the way to go but it's a shame as I like the boxes.


Filed under: blog python

Add a comment

Python logging module: a good reference is http://www.red-dove.com/python_logging.html.

It looks to me to be horribly over engineered.

It is kinda cool:

   1  #
   2  import logging
   3  import logging.handlers
   4  
   5  #
   6  # Set up basic handling.
   7  #
   8  logging.basicConfig()
   9  log = logging.getLogger( "Test")
  10  
  11  #
  12  # Log info messages and higher.
  13  #
  14  log.setLevel( logging.INFO)
  15  
  16  #
  17  # An info message
  18  #
  19  log.info( "Blah")
  20  
  21  #
  22  # Add a handler that will send email
  23  #
  24  log.addHandler( logging.handlers.SMTPHandler( "emailserver", "fromname", "toname", "subject"))
  25  
  26  try:
  27          h = wang
  28  except:
  29          log.exception( "oopsy daisy")

The output looks like this:

INFO:Test:Blah
ERROR:Test:oopsy daisy
Traceback (most recent call last):
  File "\Tmp\try.py", line 13, in ?
    h = wang
NameError: name 'wang' is not defined

I like putting prints in my scripts and I never get round to tidying them up. Maybe I could get into the habit of using this.


Filed under: python

Add a comment

Written KLog module. This allows me to go:

 # import KLog 

KLog.HookError() KLog.SendEmail()

print "Wifffle"

wang()

HookError

hooks the global exception handler so errors are written to log output.

SendEmail

cause it to email me error logs

There is also:

 KLog.SetLogFile( "c:\\tmp\\log.txt") 

which writes log output to a log file.


Filed under: untagged

Add a comment

More modifications to website generation. The Archive page is now a table with entries arranged by month + year. Only took an hour or so to do this. Python is a very productive language, Cheetah works nicely and HTML-Kit does not get in the way.

HTML-Kit annoyances:

  • Tabbing has a mind of it's own.

  • HTML-Tidy always moans about tables not having summarys (even tables used for layout) and document appearing to be HTML 4.01 Transitional.

  • The beautifier breaks the Cheetah markup

  • Some Cheetah markup is long enough to stop preview being laid out properly because the sidebar is too wide. I have to shorten variable names.

  • Have to save .css file and switch to html file to preview

There may be workarounds for these, I can live with them. Overall I am happy with the tool set.


Filed under: cheetah python

Add a comment