Showing posts from June, 2007

php 5.x is four years old. php 4 is still used. Pygame with py3k?

A cautionary tale for py3k planners from the php situation with php 4, and php 5.

php4 is still so popular and widely used, even after four years.

py3k should really study the php situation in order to avoid repeating those mistakes.

I don't think python has that much legacy code out there compared to php, but I still think there is enough that python2.4, 2.5, and 2.6 will be around with us for ages.

This page lists the reasons for php4 still hanging around. php is often installed by the web hosts, not by individuals. This is the main benefit for php versus python. Php is already installed. However as it is hard to run both php4 and php5 at the same time guess which one gets installed? Php 4 gets installed, because of all the legacy applications which require php 4. Since there are 20-1000 web pages on a single host, if only 5% require php4 then that's what will be installed. Some major webhosts have just upgraded to php4 this year!!! (Media temple) Many open source proj…

qhtml, qurl, qsql, qjs

These are some easily remembered functions for quoting used in website programming.

Using the idea of consistency allows you to remember how to quote things. Just use the function with a q in front of it.

url quoting, html quoting, sql quoting, and javascript quoting are things that web developers do almost every day in some frameworks.

Please consider using these short cut functions in your web frame work. Maybe if quoting was easier to use then people would use it more often.

It's probably the next best step compared to quoting by default, and not needing to quote at all.

They should be top level functions as well so they are easy to use.

* Note, I also use qhtm as a shortcut for qhtml. Just like how htm and html are used for webservers. qjavascript would probably be another good alias - but not one I use. I don't use a qxml, since when writing xml I use more verbose forms for constructing xml - but maybe it would make sense too?

Abstract Base Class - a poor name. Role is better.

For someone new to programming, or maybe from a non-maths background 'Abstract Base Class' sounds foreign, and weird. Whereas Role rolls off the tongue - giving me language elegance goose bumps.

How many people can guess what an Abstract Base Class is from the name? Even given it's context of 'relating to objects'. I think more people could guess from the name Role.

Reading about Abstract Base Classes over time always gave me troubles. Even reading the PEP now I find it hard to answer the question 'What is an Abstract Base Class'. A simple question don't you think?

Maybe the name is too abstract.

When discussing objects to people I could talk about classes, then about instances, inheritance, and interfaces. When I begin to talk about Abstract Base Classes then blank looks jump out. Maybe it's that the name is so long. The abbreviation into the acronym ABC makes even less sense - as it is using an existing term and changing its meaning. Not that…

Pygame weekly mini sprint 2007/06/20

I spent some time looking at the FastRenderGroups code by DR0ID.

I sent a first review to the mailing list about FastRenderGroup. So we can discuss some of the things we need to do to it before getting into pygame. It has a number of features missing from the current pygame sprite code. Including being adaptable when updating the whole screen, or just parts of the screen is quicker, as well as layers and support for the new pygame blending modes (like additive blending).

ideasman_42 came along and noted a few reference counting bugs in pygame. He also plans to send in a patch with a few speed ups - by avoiding PyArg_ParseTuple when not needed, and using METH_NOARGS when appropriate.

I started on a mask.from_surface() function, but got caught up finding a bug when printing a surface. I think that was caused by the last set of changes to surface. I wrote a unittest for it, and submitted the bug to the mailing list.

Richard Goedeken submitted a patch for a smooth scaling function for p…

Webserver DOS, with linux move file - and broken file move semantics with webservers.

When a file is moved or removed on linux any processes with that file open still see the old file. So this means if you move a new 2 gig file over the top of an old 2 gig file, and some processes still have that file open there will be about 4 gigs of space used up - until the old file is closed.

Some webservers keep a file open for as long as the client is downloading it. Apache is one web server that does this. Some other webservers do not do this - like lighttpd.

The problem with reopening a file for smaller parts of a file as it is served to a web client - is that it breaks unix move semantics. The webclient will get a combination of both files, not one file or the other. This can be a problem in many cases. Consider a client downloading a html file that changes mid file. html tags won't balance up, and the client will download a syntactically invalid file.

So here is how a DOS can happen...

Say you have a big file mirror or something with lots of files that change fairly r…