Thanks Malcolm tredinick, your greate Queryset-refactor work make
write a backend very clear, thanks again!
Yes, make a external database backend is better now, I clean the code
and get it done! I just upload source code to django-pyodbc <http://
code.google.com/p/django-pyodbc> code.google project, and I join this
project to continue improve this backend, thanks, peter hausel!

Now django core only need follow patch:
Index: contrib/sessions/backends/db.py
===================================================================
--- contrib/sessions/backends/db.py     (revision 7671)
+++ contrib/sessions/backends/db.py     (working copy)
@@ -13,9 +13,12 @@

     def load(self):
         try:
+            date_now = datetime.datetime.now()
+            if hasattr(date_now, 'microsecond'):
+                date_now = date_now.replace(microsecond=0)
             s = Session.objects.get(
                 session_key = self.session_key,
-                expire_date__gt=datetime.datetime.now()
+                expire_date__gt=date_now
             )
             return self.decode(s.session_data)
         except (Session.DoesNotExist, SuspiciousOperation):

Index: test/utils.py
===================================================================
--- test/utils.py       (revision 7671)
+++ test/utils.py       (working copy)
@@ -74,7 +74,10 @@
 def _set_autocommit(connection):
     "Make sure a connection is in autocommit mode."
     if hasattr(connection.connection, "autocommit"):
-        connection.connection.autocommit(True)
+        if callable(connection.connection.autocommit):
+            connection.connection.autocommit(True)
+        else:
+            connection.connection.autocommit = True
     elif hasattr(connection.connection, "set_isolation_level"):
         connection.connection.set_isolation_level(0)

For contrib/sessions/backends/db.py, we see that we have
supports_usecs feature in DatabaseFeatures, but in
<model>.objects.get()'s query don't use it. Maybe use one function
like 'sql_date_now()' in db.connection is better to get right datetime
now?
code like this:
from djang.db import connection
s = Session.objects.get(
                 session_key = self.session_key,
                 expire_date__gt= connection.sql_date_now()
             )

Any idea?

Regards,

Wei guangjing

On 7月8日, 下午9时36分, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:
> On Tue, 2008-07-08 at 21:26 +0800, vcc wrote:
> > Thanks for Russ Magee, I see.
>
> > I just updated this backend, it's look like everything work fine for me. I 
> > have some projects working with this backend, I'll keep improve it. Please 
> > check the patch in the attachments.
>
> So the best thing to do with a patch like this, rather than keep posting
> it here (since, as Russell mentioned, it's not up for consideration of
> committing to core at the moment), is to make it a proper external
> database backend.
>
> That means something that people can install anywhere on their Python
> path and then just put it into the DATABASE_ENGINE setting. It's a bit
> hard to read the patch you've attached, but it seems like you've made
> some changes to core pieces of code (e.g. models/fields/__init__.py).
> You should try to work out is the feature that is really needed there
> and then open a ticket with a general solution that can be used by all
> backends (and addition to DatabaseOperations, for example). For example,
> think about whether it's really necessary to add a tablespace option to
> the Field class or whether that can be part of the field column name
> (e.g. as a tuple).
>
> Ultimately, there should be no changes required to core for this after a
> few tickets for missing features are opened and discussed. Remember that
> we our goal is not to support every single feature of every database
> backend, so don't go crazy with feature requests. We just support the
> common stuff. But that's the right way forwards from here.
>
> Regards,
> Malcolm
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to