Omer
unread,Mar 24, 2008, 4:18:33 PM3/24/08Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to django-gsoc
Hello! I am a potential GSoC student, and I have one question about
project ideas listed on Django's GSoC wiki and one idea about which I
hope to get comments:
Question: Are all of the ideas listed on the wiki still open for GSoC
students? I ask because the ideas link to issues, some of which are
already assigned (ORM aggregation support and multiple-column primary
keys), and the former of these issues already has a proposed patch.
Idea (Does this sound useful for Django? Is the scale correct for a
GSoC project? Is there a mentor who might want to work with me on
this?) :
I propose the creation of data manipulation and retrieval functions
for QuerySets. The idea is that it is often useful to modify a set of
tuples with a given property all at once: e.g., I give John all of my
movies, which is simple in SQL: "UPDATE movies SET owner='John' WHERE
owner='Omer'" Currently, to do this in Django (using the ORM), we need
to get all of the tuples, update them, and save them individually:
movies = Movie.objects.filter(owner='Omer')
for movie in movies:
movie.owner = 'John'
movie.save()
A much more efficient and intuitive way to do this would be something
like:
movies = Movie.objects.filter(owner='Omer')
movies.update(owner='John')
movies.save()
Similarly (though perhaps less usefully), data retrieval could be done
on datasets:
movies = Movie.objects.filter(owner='Omer')
titles = movies.get_attribute('title')
# titles is a list of strings
This is equivalent to: "SELECT title FROM movies WHERE owner='Omer'"
With these tools (and the already existent delete), a QuerySet becomes
similar in capabilities to the objects that it holds, but on a group
scale.
Implementing this proposal will require several steps:
1) Explore the Django ORM for Model objects to see its capabilities
and how these are turned into SQL, especially save().
2) Explore the Django ORM for QuerySet objects to see how delete is
implemented.
3) Compare delete in both Model objects and QuerySet objects and build
something similar for selecting an attribute and saving.
4) Add the "update" function, which modifies all objects in the
QuerySet. Experiment with ways of handling kwargs so that, although a
QuerySet is a generic object, update can still receive database
attributes (e.g., "owner") as named arguments.
5) Build a test suite to check the implementation of (3) and (4) and
to compare the execution times between the old and new methods for
selecting and updating.
Thank you for the help,
- Omer.