Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Django Unit Tests and Transactions
Coming to automated testing in Django from the Zope and Plone world, I was pleased to find full support for all the testing machinery that I've become used to: regular Python unit tests, and doctests. Of course, these being unit tests, they don't do any 'framework' management out of the box. Unit tests are supposed to test your code, and just your code. However, once you're in a framework environment (be that Zope and Plone, Django, or anything else) then testing how your code integrates with that framework is vital. Zope and Plone provide unittest.TestCase subclasses (ZopeTestCase and PloneTestCase respectively) which provide a lot of scaffolding for you to be able to run integration tests. Part of that scaffolding is automatic transaction management. This hooks into Zope's transaction API to roll back the transaction after each test runs. I wanted to do something similar for my Django test cases; I was finding 'state pollution' between my unit test runs, since data created by one test method isn't automatically cleaned out. Django's transaction handling is much simpler than Zope's: it cares only about the one database transaction that the current request has, and only if the transaction support middleware is installed. … -
Django Unit Tests and Transactions
Coming to automated testing in Django from the Zope and Plone world, I was pleased to find full support for all the testing machinery that I've become used to: regular Python unit tests, and doctests. Of course, these being unit tests, they don't do any 'framework' management out of the box. Unit tests are supposed to test your code, and just your code. However, once you're in a framework environment (be that Zope and Plone, Django, or anything else) then testing how your code integrates with that framework is vital. Zope and Plone provide unittest.TestCase subclasses (ZopeTestCase and PloneTestCase respectively) which provide a lot of scaffolding for you to be able to run integration tests. Part of that scaffolding is automatic transaction management. This hooks into Zope's transaction API to roll back the transaction after each test runs. I wanted to do something similar for my Django test cases; I was finding 'state pollution' between my unit test runs, since data created by one test method isn't automatically cleaned out. Django's transaction handling is much simpler than Zope's: it cares only about the one database transaction that the current request has, and only if the transaction support middleware is installed. … -
Django Unit Tests and Transactions
Coming to automated testing in Django from the Zope and Plone world, I was pleased to find full support for all the testing machinery that I've become used to: regular Python unit tests, and doctests. Of course, these being unit tests, they don't do any 'framework' management out of the box. Unit tests are supposed to test your code, and just your code. However, once you're in a framework environment (be that Zope and Plone, Django, or anything else) then testing how your code integrates with that framework is vital. Zope and Plone provide unittest.TestCase subclasses (ZopeTestCase and PloneTestCase respectively) which provide a lot of scaffolding for you to be able to run integration tests. Part of that scaffolding is automatic transaction management. This hooks into Zope's transaction API to roll back the transaction after each test runs. I wanted to do something similar for my Django test cases; I was finding 'state pollution' between my unit test runs, since data created by one test method isn't automatically cleaned out. Django's transaction handling is much simpler than Zope's: it cares only about the one database transaction that the current request has, and only if the transaction support middleware is installed. … -
Plugging a RSS feed into a Django template
As some of you may have noticed, I've added my latest notes at byNotes in the sidebar. I wanted to do it in the template side, because I like to keep my views as clean as possible, so I wrote a template tag for fetching a RSS feed and displaying it. Here is the code: from datetime import datetime import time from django.core.cache import cache from django import template import feedparser register = template.Library() @register.filter def todatetime(value): return datetime(*time.localtime(time.mktime(value))[:6]) @register.tag def rssplug(parser, token): try: tag_name, address, template = token.split_contents() except ValueError: raise template.TemplateSyntaxError('%s tag requires 2 arguments' % token.split_contents()[0]) return RssPlugNode(address, template) def resolve(var_or_value, ctx): if var_or_value[0] == '"': return var_or_value[1:-1] return ctx.resolve_variable(var_or_value) class RssPlugNode(template.Node): def __init__(self, address, templ): self.address = address self.templ = templ def rss(self, addr): ckey = 'rssplug_%s' % addr data = cache.get(ckey) if data: return data data = feedparser.parse(addr) cache.set(ckey, data) return data def render(self, context): address = resolve(self.address, context) tmpl = resolve(self.templ, context) t = template.loader.get_template(tmpl) return ''.join([t.render(template.Context({ 'item': item })) for item in self.rss(address).entries]) As you can see, this tag uses a template for rendering every feed item, making it very flexible. You can output any information you want, as long as feedparser supports … -
Using recursion combinators in JavaScript
In the previous post we explored “array extras” and how they can help us to write concise yet performant and clean code. In this post we take a look at generalizing recursive algorithms with recursion combinators — high-level functions that encapsulate all boilerplate code needed to set up the recursion. These functions were added to dojox.lang.functional and will be officially released with Dojo 1.2. In general the recursion is a form of iterative problem solving in the same category as loops. There are two major natural sources of recursive algorithms: recursive data structures (lists, trees, and so on), and recursive definitions (factorial, Fibonacci numbers, the GCD algorithm, etc.). The recursion plays a prominent role in the functional programming (FP), and one of the best articles on this topic is “Recursion Theory and Joy” by Manfred von Thun , the creator of Joy (a purely functional programming language with Forth-like syntax). Manfred’s article explains intricacies of recursion including the venerable Y combinator , recursion combinators in general, and introduces a practical set of recursion combinators, which will guide us in this post. -
Por: Juanjo
Creo que los dos enfoques tienen ventajas. -
Por: Gonzalo
¡Perdón! Confundí django-messages con django-notification, que no me gusta que la forma de usarlo sea inconsistente con la de una aplicación Django “normal” (qué se yo, pondría create_notice_type en un manager, y usaría get_or_create en vez del try/except que usa esa función), pero es solo gusto mío, nada para escandalizarse. Recién estuve viendo django-messages y ¡me parece genial! -
Por: Juanjo
Qué cositas? A mi, por ejemplo, me gustaría que se puedan mandar mensajes a muchos usuarios a la vez. No lo probé mucho aún como para encontrar otras cosas De todas formas, siempre se pueden enviar parches. -
Python and Django Setup for Mac OS X Leopard
Python and Django Setup for Mac OS X Leopard -
Por: Gonzalo
¡Qué bueno! No me gustan algunas cositas de esa aplicación en particular, pero es genial que se vayan traduciendo los ‘pluggables’ que hay para Django -
Edit Inline Support for Generic Relations
Introduction I've recently (past week or so) been digging into the newforms-admin branch of django. I am really looking forward to this code line getting merged into trunk as there are tons of great work in this branch. I especially like the separation of the admin code from the models. Well, I'll get to my point. The Problem I needed to be able to edit child records in the admin that were children through the use of GenericRelations. I was told about a solution on Google Code called django-genericadmin, but it seemed dead and I could not get it to work. The thing that seemed the closest to working was a patch on ticket 4667 by Honza Kral and a variation on this patch in the Django Snippet 765. Neither of these worked for r7771 of branches/newforms-admin. The Solution I put the 765 snippet in a file called generic.py in the root of the django project I was working on and fiddled with it until I got it working. I ended up needing to change an import, fix some variable names, and change the argument list order in one of the init methods. I also added the can_order and can_delete … -
Edit Inline Support for Generic Relations
Introduction I've recently (past week or so) been digging into the newforms-admin branch of django. I am really looking forward to this code line getting merged into trunk as there are tons of great work in this branch. I especially like the separation of the admin code from the models. Well, I'll get to my point. The Problem I needed to be able to edit child records in the admin that were children through the use of GenericRelations. I was told about a solution on Google Code called django-genericadmin, but it seemed dead and I could not get it to work. The thing that seemed the closest to working was a patch on ticket 4667 by Honza Kral and a variation on this patch in the Django Snippet 765. Neither of these worked for r7771 of branches/newforms-admin. The Solution I put the 765 snippet in a file called generic.py in the root of the django project I was working on and fiddled with it until I got it working. I ended up needing to change an import, fix some variable names, and change the argument list order in one of the init methods. I also added the can_order and can_delete … -
LaunchPad
I signed up with Launchpad today – don’t know why I hadn’t really done it earlier, other than I just didn’t think to or have any projects that drove me there. The project du jour that lured me in was … Continue reading → -
Reversed publishing with Django
>>> from django.core.template import * >>> c = Context( { 'ctnt': 'this is a test' } ) >>> t = Template( """ {{ ctnt|slice:"::-1" }} """ ) >>> t.render( c ) ' tset a si siht ' >>> badum-dum-chh. Post to Del.icio.us -
Introducing FRF, the Fiam's RSS Framework
I'm starting to notice a problematic pattern in Django: some components are not extensible at all. There's no problem when you are using it in the same way the framework developers intended, but when you want to do something which deviates from the Django standard, you're screwed. That's what happened to me yesterday. I wanted to add a RSS feed for public notes at byNotes, featuring GeoRSS information, but as far as I'm concerned Django Syndication Framework doesn't allow the framework user to define new fields. So I've choosen to write a simple but extensible RSS Framework. Each new field is a class, which can be plugged inside a channel or inside an item. In addition, I've also used a view-as-class approach without any templates, requiring the application feed class to return the field contents. However, every field also defines its own formatter, so the application feed class does not need to return the text, only the object the formatter expects (e.g, the pubDate field expects a datetime object, while the link field expects an URL). There are some things I like in the Django Syndication Framework, so I've kept them. For example, feeds can receive parameters via get_object() and … -
Immutable Django model fields
I wanted to make a field on a Django model read-only after it was assigned an initial value. Maybe I was having a slow day, or my Google-fu was especially lacking, but I couldn't find a documented way to do this. There's the editable Field option, but I wanted to ensure I couldn't mistakenly overwrite the initial value anywhere — not just in the admin interface or form processing. It turned out to be pretty easy. -
PyCon teraz w Polsce
Autorem poniższego tekstu jest Katharsis Rybnik pozazdrościł Pcimowi Pythona i organizuje po raz pierwszy polską edycję konferencji PyCon. PyCon PL, jedyna w Polsce konferencja poświęcona w całości językowi programowania Python odbędzie się w dniach 18-19 października 2008. Celem... -
Wersja 1.0 już niedługo!
Niedawno pojawiła się informacja, że już niedługo wyjdzie bardzo oczekiwana wersja 1.0 Django. Termin został ustalony na 2. września. Dokładna lista rzeczy, które będą dodane i te które zostaną być może dodane wraz z dokładnymi terminami znajduje się na stronie: VersionOneRoadmap -
group_required decorator
Here is a decorator that I came up with to augment the already available login_required and permission_required decorators. This one takes a group name and makes sure the logged in user is a part of it. def group_required(group_name, login_url='/accounts/login/'): def wrap(view_func): def in_group(request, *args, **kwargs): from django.contrib.auth.models import Group try: group = request.user.groups.get(name=group_name) except Group.DoesNotExist: [...] -
Django Developers Needed
Calling all Django developers looking for work! I’m looking for some people to rely on for freelance work, as well as scouting a full time position near San Diego. -
byNotes launched
I've just launched the new geomicroblogging site I mentioned a few days ago. It still isn't as powerful as FireEagle, since the web API is still not ready, but I expect to finish it by next week. However, there are also additional features not present in FireEagle (according to what I've read, since I can't try FireEagle): You can send messages. You can send events, and when people reply to them they can specify if they're attending. You can also send links, with oEmbed support. You can build a network of friends and send them private notes. You can become a fan of someone and you'll receive his public notes (like following someone on twitter, but you can also know where he is). You can update your position only for some of your friends, the rest of them will see your previous position. Registration with OpenID is supported. Registration is currently open to everyone, but I'm going to close it as soon as there are users enough for doing some real-world testing. Wanna try it? Go ahead and start geomicroblogging today. As for the source code, I'm not sure if I'll release all of it. However, there are some portions … -
Código do site disponível para baixar
Como prometido anteriormente, o acesso à leitura no sistema de controle de versões deste website foi liberado. Isso quer dizer que agora é possível baixá-lo. Para tal, você precisará do Bazaar instalado (provavelmente existe um pacote para seu sistema, verifique na página de download do mesmo). O site foi escrito em Python utilizando o framework de desenvolvimento web Django, portando será necessário tê-lo instalado também para caso queira testá-lo em seu computador. Siga as instruções no Guia de Instalação. Caso ainda não conheça o Django, talvez seja interessante o estudo de sua documentação para entendimento do código. Baixando Para obter o código do site, utilize a ferramenta de linha de comando bzr: bzr branch http://code.taurinus.org/sementeproject/mainline/ sementeproject O código em http://code.taurinus.org/ está sendo disponibilizado em um "dumb server", então não espere por uma boa performance. Executando Antes de mais nada, você precisará também dos seguintes pacotes instalados em seu PYTHONPATH: Diário Tagging Comment Utils Template Utils Será necessário também o uso da biblioteca CSS libcss-taurinus, seus arquivos deverão estar em media/css/lib/. Experimente fazer assim: bzr export http://code.taurinus.org/libcss-taurinus/mainline/ sementeproject/media/css/lib/ Enfim, para rodar o projeto localmente, execute o seguinte comando: sementeproject/sementeproject/manage.py runserver Mais informações no site do projeto. -
Django Software Foundation
The Django guys have scored another milestone today with the creation of the Django Software Foundation. Being a huge Open Source advocate I love hearing great news like this. You can read more about the foundation at: Announcing the Django Software Foundation New Foundation for Django On an unrelated note, an article I wrote for LinuxPro Magazine last November about using Perlbal was recently put online. You can read it at The Juggler -- Let the nimble Perlbal webserver keep your traffic in balance . -
Olá mundo!
É com muita satisfação que, enfim, coloco meu website pessoal no ar! Quem me conhece sabe que há vários anos estou pelejando por isso e, felizmente, hoje foi o dia. Devagar e sempre! Assim as coisas vão acontecendo(?). Como podem perceber, o formato do site é um weblog. Procurarei escrever sobre as coisas que estou envolvido no dia-a-dia, mais especificamente com Software Livre, GNU/Linux, Administração de Sistemas, Desenvolvimento de Software e, eventualmente, assuntos relacionados à música, vegetarianismo e movimentos sociais. O site foi desenvolvido apenas com ferramentas livres (Emacs, Gimp...) e com o auxílio do framework web Django. Algumas aplicações para Django também foram fundamentais para a conclusão do site: Diário Tagging Comment Utils Template Utils O código do site também está disponível como software livre (GPLv3) e você pode visualizá-lo através do site do projeto. Em breve liberarei o acesso ao controle de versões para que seja possível baixá-lo. A idéia é que o código sirva de referência àqueles que estão estudando Django e para quem possui interesse em um site pessoal utilizando este framework. Toda crítica é muito bem-vinda! Minha pretensão é deixar público o conhecimento que adquirir ao longo do tempo e também aprender com os outros. … -
A better(?) serialization framework: part 3
I think I've finally found the perfect syntax for defining new serializations in your application code. You no longer will need to return the element name. Instead, it'll be taken from the function name, but you can override it via decorator. However, there's an exception to this rule. The default function will always return the object class name into lowercase. In addition, there's a new decorator for extending a serilization. Let's see how it looks: from wapi import serializers class UserProfileSerializer(serializers.BaseSerializer): @serializers.objname(name='my_friend') def friend(self, obj, *args, **kwargs): return { 'username': obj.user.username, 'avatar': 'http://bynotes.com/_m/avatars/%s' % obj.avatar, } @serializers.objname('my_friend_location') @serializers.extends('friend') def friend_position(self, obj, *args, **kwargs): return { 'position': { 'latitude': 5, 'longitude': 9, } } from notes.models import UserProfile serializers.register(UserProfile, UserProfileSerializer) As you can see, now serializations can be extended in the same way they are created and you won't need to write the object name again if it matches the function name. On the other hand, I've finally decided to bundle this serializers as part of the (soon-to-be-released) wapi application, which provides a foundation for exposing web apis in an easy way.