Python Programming, news on the Voidspace Python Projects and all things techie.

Gentoo

Pythonutils at Gentoo

Cool Hey !

Shame it's an old version of course....

Note

I've had a very pleasant email from the gentleman who added this package to gentoo portage.

It's now updated to the current version.

Like this post? Digg it or Del.icio.us it.

Posted by Fuzzyman on 2005-09-16 11:52:44 | |

Categories:


On the Sillyness of Sourceforge Statistics

emoticon:file1 Sorry to bang on about ConfigObj - but the Sourceforge Statistics for it illustrate the Sillyness of Sourceforge Statistics - specifically the Activity Percentile.

For ConfigObj the activity percentile is shown as : (last week): 98.51

Presumably this means that ConfigObj is within the top 2% of active projects - yet if you look at the statistics page you will see that ConfigObj is ranked about position 2000 [1].

Most projects on sourceforge are dormant (numerically speaking anyway) - these are good ideas that died, or were still born and never produced any (or much) code. This means they skew the 'activity percentile' statistics horribly and that figure is useless. Now if they excluded the dormant projects - it might be an interesting figure......

[1]Most of the downloads for ConfigObj (in fact almost all) are direct from Voidspace - which is why the shown quantity is so low.

Like this post? Digg it or Del.icio.us it.

Posted by Fuzzyman on 2005-09-14 10:06:56 | |

Categories:


Patching CGIHTTPServer

emoticon:torch I've been playing with CGIHTTPServer.py again. It's basically a toy server - but very handy for local testing. This is especially true because sub-classing it to implement customer behaviour is joyously easy.

I've created my own sub-class that does some SSI processing, can serve from two folders [1], and runs in proxy mode [2]. You can see the current state over at CGIHTTPServerWithSSI.

Unfortunately I have a problem sigh. Actually I have lots of problems - but this one is specific Very Happy . Under Python 2.4 [3] the CGI environment variables aren't getting passed to CGI scripts that it runs using os.popen3 (under Windoze).

See the following code (from line 242 in the version shipped with Python 2.3) :

# here the environment variable exist in os.environ
# but they aren't passed to the subprocess
files = popenx(cmdline, 'b')
fi = files[0]
fo = files[1]
if self.have_popen3:
    fe = files[2]

The truly weird thing is that when I do my own test script calling the same command line - environment variables are passed on. Odd and frustrating. Further investigation needed.

In the process I've also edited CGIHTTPServer to allow two things (although my tests were on the un-fiddled-with version) :

  1. Paths with spaces in.
  2. CGI scripts from sub-directories of cgi-bin.

Note

These fixes are specific to the windoze code in CGIHTTPServer. They aren't going to get touched by a Lunix computer which uses fork in another branch of the code.

First, line 234 (again, the Python 2.3 version) changes from :

cmdline = "%s -u %s" % (interp, cmdline)

to :

cmdline = '%s -u "%s"' % (interp, cmdline)

Secondly, lines 86-90 change from :

for x in self.cgi_directories:
         i = len(x)
         if path[:i] == x and (not path[i:] or path[i] == '/'):
             self.cgi_info = path[:i], path[i+1:]
             return True

to :

for x in self.cgi_directories:
        i = len(x)
        # FIXME: What if this is -1 ?
        j = path.rfind('/')
        if path[:i] == x:
            self.cgi_info = path[:j], path[j+1:]
            return True

I wonder if there is an issue with 'PATH_INFO' and this second 'fix' ?.... hmmm...

Anyway - simple stuff, but it's helped me.

[1]A development folder and a backup folder with the rest of the site that I'm not editing. Very useful - I can edit a few files from one folder 'live', whilst serving the rest of the site from the backup folder.
[2]Probably only useful for me. It drops all requests other than ones to localhost. Our home LAN isn't on the internet - so fetches to external domains take annoying seconds to timeout. In proxy mode they are simply forgotten...
[3]And not Python 2.3

Like this post? Digg it or Del.icio.us it.

Posted by Fuzzyman on 2005-09-14 09:35:01 | |

Categories:


Rolling, Rolling, Rolling

emoticon:python The response to pythonutils was very good. Especially the odict module (ordered dictionary) - it's had over one hundred and fifty downloads already. Thanks to some useful user feedback, Nicola has updated and improved it.

More embarassingly I've done a bugfix release of ConfigObj - now up to beta 5. Embarassed

All this is my way of saying that odict 0.1.2, pythonutils 0.2.2, and ConfigObj beta 5, are all available from the Voidspace Modules page.

Like this post? Digg it or Del.icio.us it.

Posted by Fuzzyman on 2005-09-13 16:16:41 | |

Categories:


#99

Login and On

emoticon:target One of my 'projects' that has languished a bit is logintools.

logintools is a CGI authentication and user account management system. I created it for Jalopy [1]. Unfortunately, the project that Jalopy was for got shelved (much to my annoyance).

Thankfully I'm now in the progress of a simple CGI CRM system that will use logintools. I've just converted it over to use the new pythonutils stuff [2].

I was again struck by how easy protecting a CGI application with logintools is Smile . It was just a case of adding add a few lines to the start of the application - and authentication/account management is fully handled :

from logintools import login

userdir = 'users/'

def main(theform, userdir):
     # this function displays login and exits if it fails, otherwise it prints
     # the new/updated cookie.
     action, userconfig = login(theform, userdir)
     username = userconfig['realname']
     loginname = userconfig['username']

     # rest of application from here

if __name__ == '__main__':
     theform = cgi.FieldStorage()
     main(theform, userdir)

The CRM probably won't be open source [3] - but logintools should get some work at last.

[1]Since I moved server the demo has stopped working. The code is also fairly horrible. I will fix the demo - but I don't know if I have the time to refactor Jalopy unless I can use it for my current project.
[2]I haven't yet released this - but if anyone wants it they can contact me on fuzzyman@voidspace.org.uk.
[3]Or at least probably not very useful to anyone else....

Like this post? Digg it or Del.icio.us it.

Posted by Fuzzyman on 2005-09-13 09:23:14 | |

Categories:


#98

Aaaargh (again)

emoticon:bugs I've been porting all my apps and tools to use the new version of ConfigObj. In the process I've uncovered two more moderately serious bugs.

We weren't unquoting keys and a comma in an inline comment could be wrongly recognised as a list (a failing in the regular expression we used).

These are now both in SVN, along with an update to odict.py. These include a barrage of improvements suggested by a gentleman called Tim Wegener (although it was pretty good in the first place). Razz

This means I'll be doing a ConfigObj Beta 5 release, along with a Pythonutils 0.2.2 very soon. sigh

Like this post? Digg it or Del.icio.us it.

Posted by Fuzzyman on 2005-09-13 08:38:23 | |

Categories:


Hosted by Webfaction

Counter...