Posted on October 15, 2008 by michaelangela
I have some data that I am pulling via Amara. I need to put that in a database. The app that uses that data is in PHP and would prefer the data to be serialized. Fortunately, there is help!
Scott Hurring: Code: Python: PHP Serialize implemented in Python: v0.4b
This is a python implementation of [...]
Filed under: dev, php, python, tool | Leave a Comment »
Posted on September 11, 2008 by michaelangela
Looking for a way to crank through files and search for specific text within matching files. Found this and it’s very neat.
Python: find files using Unix shell-style wildcards « Muharem Hrnjadovic
The download though was a little hard to find so I just got the source tar.gz file from here:
http://ppa.launchpad.net/al-maisan/ubuntu/pool/main/s/scriptutil/
[update]In the end I tried grep which [...]
Filed under: cool, python, tip, tool | Leave a Comment »
Posted on July 6, 2008 by michaelangela
So I was getting problems inserting data that has the ‘™’ symbol in it. Brutal stuff. Couldn’t find a way around it. Did it by hand in the end. Nasty. The problem was that I was getting
UnicodeEncodeError: ‘latin-1′ codec can’t encode character u’\u2122′ in position 12: ordinal not in range(256)
where the ‘\u2122′ is the ‘™’ [...]
Filed under: automation, cool, dev, mysql, python, sqlalchemy, sqlsoup, tip, xls | Leave a Comment »
Posted on July 6, 2008 by michaelangela
This thing is just brilliant! I am working on a project that uses PHP. But I still do my data mangling with Python because of tools like SqlSoup running under SqlAlchemy. Using those under iPython has saved incredible amounts of time. I actually like working with data in this way. It just makes it more [...]
Filed under: cool, python, tip, xls | Leave a Comment »
Posted on June 30, 2008 by michaelangela
Very useful. Sometimes some flv conversion tools don’t include info that is vital for playback. In this case, the seekbar wouldn’t show up in the player until after playback finished. I’ll be testing to see if this resolves it but either way, this is good to know. The first hint was this post stating that [...]
Filed under: cool, flash, flex, flv, linux, one-liner, python, shell, tip, tool | Leave a Comment »
Posted on May 13, 2008 by michaelangela
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 [...]
Filed under: cool, django, orm, search, tool | Leave a Comment »
Posted on May 8, 2008 by michaelangela
that are more or less ready to use. The list is at the following link.
Empty Thoughts: Django Blogging Apps
People ask about blogging apps for the Django platform all the time. I
have not investigated each and every one of these, but so far I still
feel pretty confident that not one of these is fully [...]
Filed under: blog, django, tip | Leave a Comment »
Posted on May 8, 2008 by michaelangela
A note… definitely something to come back to.
Talk Funnel » Blog Archive » Django bash shell shortcuts
SmileyChris had a post up recently on setting up bash aliases for Django. He uses the classic alias command which works for one-line shortcuts. I got inspired to put mine up too, but if you want to [...]
Filed under: bash, cool, django, shell, shortcuts, tool | Leave a Comment »
Posted on May 7, 2008 by michaelangela
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 [...]
Filed under: cool, django, orm, python, snippet, tip, tool | Leave a Comment »
Posted on May 7, 2008 by michaelangela
Just making a note…
Extending Django’s database API to include full-text search (Mercurytide)
Filed under: api, django, orm, tip | Leave a Comment »
Posted on April 25, 2008 by michaelangela
Doesn’t work:
ids=request.GET['ids[]‘]
Does work:
ids=request.GET.getlist(‘ids[]‘)
A typical Facebook friend invite sends the ids to be invited to your site as an array in ‘ids[]‘. Normally, you can pull values out with just request.GET['key']. But since the value of this particular key is an array and not just a string, you can’t (at least I wasn’t able to) just [...]
Filed under: dev, django, facebook, python, snippet, tip | Leave a Comment »
Posted on April 24, 2008 by michaelangela
I had heard about passing by reference vs. passing by value. Here is a case of passing by reference.
In [76]: a=[1,2]In [77]: b=aIn [78]: b.append(3)In [79]: aOut[79]: [1, 2, 3]
That’s not what I was looking for. I was hoping to get ‘b’ to be [1, 2, 3] leaving ‘a’ unchanged. Oops. It passed ‘a’ to [...]
Filed under: cool, dev, one-liner, python, tip, tool | Leave a Comment »
Posted on April 24, 2008 by michaelangela
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 [...]
Filed under: dev, django, orm, tip | Leave a Comment »
Posted on April 22, 2008 by michaelangela
Django snippets: Referer-checking view decorators
Here are a couple of Django decorators for limiting access to a view based on the request’s HTTP_REFERER. Both raise a Django PermissionDenied exception if the referer test fails (or a referer simply isn’t provided).
The first, referer_matches_hostname, takes a hostname
(and port, if specified) and matches it against the referer’s. [...]
Filed under: deep-linking, dev, django, snippet, tip | Leave a Comment »
Posted on April 22, 2008 by michaelangela
This might be useful but, buyer beware.
Django snippets: FieldLevelPermissionsAdmin
Have you ever needed to customize permissions, for example, allow only some fields for editing by some group of users, display some fields as read-only, and some to hide completely? FieldLevelPermissionsAdmin class does this for newforms-admin branch. Not tested well yet (>100 LOC!).
Filed under: dev, django, snippet | Leave a Comment »
Posted on April 18, 2008 by michaelangela
You can use this to set up a Facebook User within you Django app. This of course uses the middleware which is optional as described here.
Django snippets: Little middleware that create a facebook user
Install **PyFacebook** package.
After make all steps in tutorial above, put this code in your [...]
Filed under: dev, django, facebook, python, snippet, tip | Leave a Comment »
Posted on April 17, 2008 by michaelangela
So far I haven’t really used Django for “web sites”. It’s really been used as a data backend. Well the time has come for some web stuff. It’s set up to use a dev, staging, and production server. All is well and good. But each has a different media server. In Django, how do you [...]
Filed under: dev, django, tip, tool | Leave a Comment »
Posted on April 17, 2008 by michaelangela
So say you have a Facebook app and it runs on Django. Standard practice is to load the middleware. Middleware by default adds a bit of overhead. It’s needed for some bits but completely unnecessary for anything that doesn’t need it. This is one way to take it out if you feel the need for [...]
Filed under: dev, django, facebook, python, tip | Leave a Comment »
Posted on April 10, 2008 by michaelangela
I was so happy when I first found Amara. It was the easiest thing I had seen for creating XML with Python. It’s quite serious stuff because it can probably handle just about anything you throw at it. Then I heard about the wonderful web2py project. One of it’s beautiful aspects is XML generation, or [...]
Filed under: cool, dev, education, python, tip, tool, web2py | Leave a Comment »
Posted on April 7, 2008 by michaelangela
Just a note about another one.
TagPy | Andreas Klöckner’s web page
TagPy is a set of Python bindings for Scott Wheeler’s TagLib. It builds upon Boost.Python, a wrapper generation library which is part of the Boost set of C++ libraries [3].
Just like TagLib, TagPy can:
read and write ID3 tags of version 1 and [...]
Filed under: audio, automation, cool, dev, python, tip, tool | Leave a Comment »
Posted on April 7, 2008 by michaelangela
Kinda neat this library is. Even works on multilingual song files.
Development/Mutagen/Tutorial – Ex Falso / Quod Libet – Trac
from mutagen.flac import FLAC audio = FLAC(“example.flac”) audio["title"] = “An example” audio.pprint() [...]
Filed under: audio, automation, cool, dev, python, tip, tool | Leave a Comment »
Posted on March 31, 2008 by michaelangela
More python/Flex goodness in the works in the future perhaps? I really like Python… learning all the time with my web2py friends. I’d love to be able to combine this with Flex. Looks like it’s getting easier and easier. Now to combine this with Orbited…
Ted On Flex: The AMF Revolution
The growth [...]
Filed under: django, education, flex, pyamf, python, web2py | Leave a Comment »
Posted on March 30, 2008 by michaelangela
As noted in this post, you need to change a line in pg_hba.conf to “trust” instead of “md5″ (no quotes) to be able to batch create tables. Note this is only for testing purposes and not recommended for production. The only reason is because I am running some benchmarks for web2py. I want to be [...]
Filed under: dev, web2py | Tagged: benchmark, postgres | Leave a Comment »
Posted on March 29, 2008 by michaelangela
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=[]
[...]
Filed under: cool, dev, education, one-liner, orm, web2py | Leave a Comment »
Posted on March 28, 2008 by michaelangela
Web2py is humming along and just got a redesigned front page. Nice, clean, and accessible. Gotta love the “complex” tutorial. Fits in a page!
web2py Enterprise Web Framework
A taste of web2py
Consider the following complete application which consists a model (which describes the data representation): db.py
1.2.
db=SQLDB(’sqlite://images.db’)db.define_table(‘image’,SQLField(‘file’,'upload’))
a controller (which describes the application logic and [...]
Filed under: cool, dev, python, web2py | Leave a Comment »