On Thu, Jul 10, 2008 at 5:25 AM, vcc <[EMAIL PROTECTED]> wrote:
>
> 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):

You may want to look at #7570 for this kind of situations. Basically,
I'm proposing to let backends take care of this problems (no
microseconds support in this case) to avoid polluting higher level
code.

> 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)

As this is also needed for JDBC backends, I filled #7751 for this one.

-- 
Leo Soto M.
http://blog.leosoto.com

--~--~---------~--~----~------------~-------~--~----~
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