Django, Sphinx, and full-text search

This makes some interesting things possible. And it makes sense just looking at it. That’s even better.

Announcing django-sphinx 2.0.0 Full-text Search | David Cramer’s Blog

One of my tasks lately has been updating the django-sphinx
library to work with Sphinx 0.98, as it includes GIS components which
we have been wanting to possibly utilize [...]

Snippet to update Django tables to utf8

So you get the dreaded illegal mix of collations:
Pythoneer » Convert MySQL table to utf8
Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE)
What do you do? Not too bad fortunately. And if you’re working with Django, it’s a little bit easier. Launch the shell with python manage.py shell. Then in the shell do something like [...]

Full-text search for Django

Just making a note…
Extending Django’s database API to include full-text search (Mercurytide)

Concat Django Querysets

Here is a good discussion on concatenating Django Querysets. Very helpful! It also introduced me to itertools. This leads to some other talk about itertools. Very interesting!
The jist though is like this:
How do you concatenate two querysets? - Django users | Google Groups
import itertoolsq1 = Model1.objects.all()q2 = Model2.objects.all()for thing in [...]

Exporting a web2py table in XML

I recently wrote about exporting a Django database to xml. As a courtesy, Massimo, creator of web2py, put together a great little example for web2py
exporting in XML - web2py Web Framework | Google Groups

def export_xml(rows):
idx=range(len(rows.colnames))
colnames=[item.replace('.','_') for item in rows.colnames]
records=[]
[...]

Python Time Object Diffs

(Python) PyProgram #7 - Time Object Diffs « the minds of a tuxian
I had two time objects and needed to find the difference of time between them. Upon Googling, querying in #python and checking the documentation, found that there is not built-in function available for this. Though there were some cookbook recipes, I [...]

Storm and OpenID

OpenID as a WSGI filter, part 2 - Damian’s archive - Alleged Literature
Programmers learn through programming, and my research into OpenID has got as far as a web application that lets you do nothing at all except log in with OpenID. Along the way I have played a bit with Canonical’s own object-relational [...]

Formencode example

A full example, albeit with SQLObject, but the concept is pretty clear. With web2py, the form.validate would be followed with an explicit data insert. From the looks of the **form_result insert, form.validate returns a list of fields that can be directly inserted. The same format should be able to be used with Storm.
Handling Form data [...]

Simple web2py and Elixir

So I have a sample data set in a database created by web2py. After some experimentation I can access, modify and create data with Elixir/SQLAlchemy. Just some notes, like remember to encode web2py blobs with utf8 if you’re not going through web2py’s functions.
r=Recipe.query.all() r[0].instructions=u’some text to submit’.encode(’utf8′ ;) cb.session.flush()

And then something happend before this got pulished [...]

Elixir or straight SQLAlchemy

Or “When not to use something that looks like it’s obviously going to make your life so much easier”
SQLAlchemy, Declarative layers, and the ORM ‘Problem’
On first glance, its pretty obvious that everyone should love Elixir vs the obviously more tedious SA approach of layout out your tables, then mapping them to the class [...]