Wednesday, January 31, 2007

Yolk - a tool for querying python packages.

Yolk is an interesting little tool useful for listing packages on the pypi python package repository, and those 'eggs' installed with setup tools.

I've found it quite useful for seeing what stuff is installed on a machine, and to quickly look up packages from pypi.

Here's some of the things you can do with it:

yolk -H twisded
Launches your web browser at Twisted's home page

yolk -M Paste 1.0
Show all the metadata for Paste version 1.0

yolk -M Paste
Show all the metadata for each version of Paste listed on PyPi?

yolk -D cheesecake
Show all URL's for cheesecake packages you can download

yolk -T source -D cheesecake
Show only source code releases for cheesecake





Melbourne Web Developer Written by a Melbourne web developer. Available for your projects - php, mysql, e commerce, javascript, CMS, css, flash, actionscript, python, games, postgresql, xml.

Monday, January 22, 2007

A better python cheese shop. What would you change?

Often whilst visiting bars, or night clubs I play a game with whomever I am with. It's called 'the perfect night club'. What we would do if we ran a night club? I'd add in vending machines for non-alcaholic drinks, I'd add in plenty of couches, I'd add in twice as many girls toilets... etc etc.

Looking through the cheese shop today I started playing the same game. Here's my top three changes I'd like to see:

1. What's changed? What has changed in this release of software? This is probably the most useful information missing for people tracking the cheese shop. Freshmeat has another useful piece of change information - a change summary. So you can quickly tell the focus of the release: bug fixes, security fixes, feature changes, etc. Other people don't find the cheese shop release information as useful as it could be too... planetpy blog

2. Faster browsing. The website is a bit slow. Mainly when browsing through the categories. I think caching would help a lot here. Since there seems to be only five changes a day - caching should be quite useful.

3. Screen shots. Not all packages need screen shots, however it would be very useful for some packages. Any package with a GUI, or that produces graphics. Even IPython has screen shots. One step further would be screen casts.


Those are my top three changes I'd like to see. Pygame.org has a nice project listing section which could also be inspirational. One of the better parts of it, is that you can comment on releases. This gives authors more feedback than they would otherwise get. Freshmeat is probably the best place to look for inspiration.

What would you do if you made a better cheese shop?





Melbourne Web Developer Written by a Melbourne web developer. Available for your projects - php, mysql, e commerce, javascript, CMS, css, flash, actionscript, python, games, postgresql, xml.

Tuesday, January 16, 2007

sqlobject versions

It looks like SQLObject has versioning now.

"So, a version is a special attribute that catches updates and stores older values in a special additional table."

This is a very useful thing that I've been using on some projects myself. With it you can more easily recover from errors, and it also can allow your users to search through changes.

If SQL had versioning built in, it'd be much nicer. Temporal SQL is the name for this. However I think Oracle is the only major database to support it. No free ones do. So storing it in another table is an ok compromise.

I'm looking forward to the next SQLObject release - with versioning support, and other goodies.





Melbourne Web Developer Written by a Melbourne web developer. Available for your projects - php, mysql, e commerce, javascript, CMS, css, flash, actionscript, python, games, postgresql, xml.

Saturday, January 13, 2007

I Am A Drum Machine

Here's a song I made the other night - I thought some of you might find it funny.

http://rene.f0o.com/~rene/stuff/I-am-a-drum-machine.mp3

If you just want to play it in your browser, there is a flash based player here with it:http://www.pretendpaper.com



Melbourne Web Developer Written by a Melbourne web developer. Available for your projects - php, mysql, e commerce, javascript, CMS, css, flash, actionscript, python, games, postgresql, xml.

Python CSS parsing.

So you want to parse a website?

Python has some pretty cool html, rss, and atom parsing modules. There is also a promising CSS parser. This parser is cssutils.

http://cthedot.de/cssutils/

Parsing CSS is one part which can occasionally come in handy. Say you want to figure out how big a piece of text will display on a page? Without CSS parsing you can not test this.

You want to check to see if a piece of html is displayed at all? Well assuming we ignore javascript, CSS can be used to disable parts of a website with display:none or by setting the visibility or transparency. So this is another reason why you might want to parse CSS.

It's also handy if you are using CSS in your own non web based GUI engine. CSS is a fairly well understood language. So using it instead of your own format might be a good idea.


Above are some reasons why you might want to parse CSS with python. However I'm sure there are others which might pop into your head if you are a web developer.

Thanks to Christof Hoeke for providing one of the missing batteries for a modern WWW (cssutils).



Melbourne Web Developer Written by a Melbourne web developer. Available for your projects - php, mysql, e commerce, javascript, CMS, css, flash, actionscript, python, games, postgresql, xml.

Saturday, January 06, 2007

Python WSGI server - CherryPy 3.0

Today I noticed that CherryPy 3.0 has been released.

CherryPy is a multi-threaded production web server written in python.

The part I am interested in is the Web Server Gateway Interface(WSGI) component. WSGI is the glue which allows lots of python web code to talk to each other. A python WSGI server allows you to run python applications.

Up until now I have mostly been using the twisted.web2 wsgi code. This is fairly nice, and I can use other parts of twisted with it. However twisted.web2 is not finished.

CherryPy on the other hand has had a lot of work done on it polishing it up. It is used by quite a lot of people on real websites. A nice part of this work is the optimization work that has been done on it. Apparently CherryPy 3.0 is three times faster than the previous 2.x release. One of the authors also claims that it is the fastest WSGI server around.

For my simple benchmarks on my application it goes from 38 req/second with twisted, to 54 req/second with a slow AMD Duron 850mhz linux computer. So not amazingly faster, but still a worthwhile speedup.

The WSGI server in CherryPy comes as a stand alone module. So you can just download one .py file and use it. Pretty easy. CherryPy comes with lots of other goodies, but I'm not interested in those. Maybe I'll play with them later, but for now I just want a python WSGI server.

The single file WSGI server is less than 1000 lines of code, many of which are comments and documentation. So it's pretty simple to read, debug, and modify.

It took me about 20 minutes to convert my application to use the cherrypy WSGI server instead of twisted. It was much easier to figure out, and well documented compared to twisted.

One problem I have is that of memory consumption. The cherrypy server seems to use more memory than the twisted one. I managed to reduce it to 25MB using one thread. The default of 10 threads uses up 96MB. It would be great if the server could be enhanced for low memory usage. So when there's not much traffic it could use 1 thread, and when there is a lot of traffic increase the number of worker threads. Much like how apache has settings for how many threads or processes are used.

Another difference between the twisted.web2 WSGI server, and the cherrypy one is that the cherrypy one prints tracebacks to the browser. Which is fine for development, but is not something you'd want for production.

One problem I had was stopping the server. Using ctrl+C gives a traceback and makes it non responsive. Meaning I have to kill it another way. This is kind of annoying, and slows my development a little. Since I need to restart the server often some times.

At this stage, because of the less memory usage, and how it does not display errors to the user, and the ctrl+c problem I have - I think I will stay with the twisted WSGI server. However I am keeping an eye on the cherrypy server because of its better performance.





Melbourne Web Developer Written by a Melbourne web developer. Available for your projects - python, php, mysql, e commerce, javascript, CMS, css, flash, actionscript, games, postgresql, xml.