During preparations for 1.0 release Django signaling system was refactored. Details on Backwards Incompatible Changes Page, corresponding changeset is 8223.
Well, the main reason of changes is speeding up. Announced “90% improvement in the speed of signal handling“.
The main question is how to update own code to be compatible with new way. We need to replace old style dispatching with new way of signal object creation (django.dispatch.Signal). Let see post and pre save model signal dispatch example.
We have Item model and signal handler add_mime_type declared before. Old style connection:
dispatcher.connect(add_mime_type, signal=models.signals.pre_save, sender=Item)
New way to connect model signals with handlers:
models.signals.pre_save.connect(add_mime_type, sender=Item)
Looks pretty simple. Also we need to change one thing in handler. It must be declared as accepting kwargs. For example:
def add_mime_type(instance, **kwargs):
The main changes are done behind the scenes. Now models.signals.pre_save is instance of django.dispatch.Signal instead of plain object().
It is a short post-though about two popular Python frameworks. This is my personal experience and some analytics.
Well, if you building long-term project, for example some social network (oh again), usually you need rapid prototyping and then step-by-step (iteration) development. For prototyping you need more and more components, which you can replace or customize later. For iteration-based development you need to setup release deployment and testing automation (aka buildbot). Important thing that you have deployments on own infrastructure and you can build it once and then forget. So Django is number one solution for the component-based model (aka apps).
Other case is when you creating an application which would be highly redistributable, for example blog or e-shop engine. It is really hard (for today) to setup quickly django applications and lots of people is aware of hand-made installations (like terminal commands, etc). Pylons has a better deployment tool (paste) that helps with redistribution of projects and better project/app file layout.
It is main reason why there are still not so much complete django applications.
I thinking to use both for different cases, but anyway large projects is a Django way.
At last my top three django components:
1 Django’s cache framework;
2. User authentication in Django |;
3. Testing Django applications .
I still lack of time to finish my blog styling and programming, but here some progress:
All this stuff built on Django with few useful apps — Byteflow Blog Engine and django-template-utils. And of course my hand-made python code :-)
For styling I currently use blueprintcss framework. Later I’ll create some custom design and then will code own html/css style.
Today main focus on content!
My code (python/javascript) coming soon too.
I excited with GData API from Google. I just tried they Python version and it looks KISS.
Google GData API mixes CRUD actions with Atom XML format. This means that all client-server messaging uses Atom feeds as data format. Google guys extended Atom specification with ability to make complex queries and implemented Atom Publishing Protocol for posting data to server.
For example document list, contact list, etc looks like usual Atom feeds.
Main Google API enabled services:
Full list is on Google API page.
I checked GData Python API with simple script, see code below:
# Google Docs example
import gdata.docs.service
# authentication
gd_client = gdata.docs.service.DocsService()
gd_client.email = 'username@gmail.com' #change this
gd_client.password = '' #change this
gd_client.source = 'exampleCo-exampleApp-1'
gd_client.ProgrammaticLogin()
# querying full docs list (feed)
feed = gd_client.GetDocumentListFeed()
# selecting first document to work
d = feed.entry[0]
# document properties
print d.title.text # document name
print d.content.src # link to document content (URL)
# for changing document properties we need use atom python module
import atom
# creating new document name
document.title = atom.Title(text='my best friends')
Conclusion: it is really easy to integrate with Google services.