All Unkept
Posted in: Django, Software development  —  19 November 2005

Django validator app. And fuse/webdav/bazaar

I wrote a quick Django application to ensure I have immaculate HTML in my Django web sites, and put it together so it's easy to distribute. Get Django Validator here.

I'm using Bazaar-NG for source control (and probably will move some other projects to Bazaar), which allows me to put the repository on a simple web server. This coincided with finding I have some web space with a WebDAV interface with my fastmail email account. KDE has a nice support for WebDAV via webdav://, but to make it even easier you can use fuse and wdfs so updating the repository can be done from shell commands.

The fastmail space also has a nice interface for browsing the files, and it handles downloads better than my home page host (which often gets mimetypes wrong and stuff), which is why I'm using it instead of lukeplant.me.uk.


If anyone's interested in any of the fuse/wdfs stuff, the steps required from a Debian box are something like this:

# install module-assistant
sudo apt-get install module-assistant
# use it to install 'fuse'
sudo module-assistant
# install fuse utilities and development files
sudo apt-get install fuse-utils libfuse-dev

Then download and install wdfs. Tip: when installing from source, always use 'checkinstall' so it's easy to uninstall.

Comments §

§ On 29 November 2005, nesh wrote: 41
Your validator only works with WSCGI requests it will need modification to work with mod_python:

from django.core.handlers.modpython import ModPythonRequest
if isinstance(request, ModPythonRequest):
# prepopulate vars
request._get_get()
request._get_post()
request._get_cookies()
request._get_files()
request._get_meta()
request._get_request()
request._get_raw_post_data()
request._get_user()
mp = request._req
del request._req # get rid of mp_request
req = copy.deepcopy(request)
request._req = mp # restore mp_request
else:
req = copy.deepcopy(request)
# remove the stuff we can't serialize
req.META['wsgi.errors'] = None
req.META['wsgi.file_wrapper'] = None
req.META['wsgi.input'] = None

§ On 29 November 2005, nesh wrote: 42
Also I added support to define URL prefix to ignore (i.e. validation status url):

in model file:
try:
content_type = response['Content-Type'].split(';')[0]
validator = VALIDATOR_APP_VALIDATORS[content_type]
except KeyError, IndexError:
# no content type, or no validator for that content type
return
==== add this ===
if ('ignore_path' in VALIDATOR_APP_VALIDATORS ) and request.path.startswith(VALIDATOR_APP_VALIDATORS['ignore_path']):
return # ignore path


§ On 1 December 2005, luke wrote: 43
Cheers, I'll add these in and do a release soon.

Luke

Add comment

Format:

  • Javascript has to be on to get past my spam protection, and cookies, and there is a delay, sorry for any inconvenience!
  • I reserve the right to moderate comments.