Done, and gets things smart.
16Sep
Posted by Elf Sternberg as django, python, web development
Today’s little snippet: Filtering a loosely coupled many-to-many relationship. As revealed earlier, I don’t really “get” the difficulty with many-to-many relationships. I don’t even get the difficulty with signals; if you define the many-to-many manually, handling signals on it is trivial compared to trying to do it manually in one of the referring classes. Today, [...]
Repeat after me: Registration is not Authentication is not Authorization is not Utilization. Registration is not Authentication is not Authorization is not Utilization. Registration is not Authentication is not Authorization is not Utilization. I’ll keep reminding myself of that until I figure out how to disentangle the four from this damned Facebook app. Registering to [...]
31Aug
Posted by Elf Sternberg as django, javascript, python
The correct call for posting to a user’s facebook wall with Python and pyfacebook, after you’ve established both user authentication via FacebookConnect and gotten stream_publish permission, is: request.facebook.stream.publish( message = render_to_string(template_path, fb_context), action_links = simplejson.dumps( [{'text': "Check Us Out!", 'href': "http://someurl.com"}]), target_id = ‘nf’) See that ‘nf’ down there in target_id? It’s not on any [...]
So, while working my way through my current project, I came across the notion of a ‘slot’ as discussed here. And I wondered, what the Hell is a slot? A slot is nothing more than a memory management nicety: when you define __slots__ on a class, you’re telling the Python interpreter that the list of [...]
29Jun
Posted by Elf Sternberg as django, programming, python, web development
One thing I see a lot of in professional Django is the importation of ugettext, Django’s internationalization library that leverages the GNU gettext project’s toolkit for generating translation catalogs. Laying the groundwork for translation is important to larger projects intended for universal appeal. Because the underscore is a valid leading character in a function name [...]
26Jun
Posted by Elf Sternberg as django, programming, python, web development
At del.icio.us (and some other sites, but I’ll use del.icio.us as my example), one of the most interesting features is that your username is one of the first-level “commands” you can send to the application: “http://del.icio.us/elfsternberg” is a valid URL, and points to my collection of bookmarks. At the same, there are other first-level commands [...]
20May
Posted by Elf Sternberg as javascript, programming, python, Uncategorized
Most people encountering the Ajax components of Django for the first time usually encounter this pairing: from django.utils import simplejson … return HttpResponse(simplejson.dumps(some_python_obj)) For most applications, this is enough. But I’m especially fond of iterators, generators, functors and closures, dense components that express one thought well: the structure of a tree, or the rows of [...]
18May
Posted by Elf Sternberg as django, programming, python
This was probably just about the gnarliest little problem I’ve ever wrocked my brains over in a long time. I was using the Treebeard library for a materialized path tree, and the problem came down to how to render it. The obvious solution was lists of lists, but… how? I’m not going to explain Treebeard [...]
I was reading through the WordPress source code, trying to figure out a problem for a contractor, when I saw the function compact(). When I saw it I boggled, read the description, and shook my head. Compact() takes a list of variable names as strings, and returns a hash of those variable names and their [...]