On Wed, Dec 9, 2009 at 3:09 PM, Maksymus007 <maksymus...@gmail.com> wrote:

> For a few weeks I observe strange django behaviour - from time to time
> I get mails about
>
> AttributeError: 'NoneType' object has no attribute 'company'
>
> in line 121, which is:
>
> cursor.execute("SELECT * FROM interface.stats_sms_errors(%d,
> '%s'::timestamp with time zone, '%s'::timestamp with time zone, '%s')"
> % (request.account.company.company_id, stats_time_start,
> stats_time_end, stats_truncate))
>
> looks like request.account is None.
>
> But one line above,line 120 is
>
> cursor.execute("SELECT * FROM interface.stats_sms_mms(%d,
> '%s'::timestamp with time zone, '%s'::timestamp with time zone, '%s')"
> % (request.account.company.company_id, stats_time_start,
> stats_time_end, stats_truncate))
>
> which uses the same request.account which, one line later is empty.
>
> This view is called about 500 times a day and it works, but one or two
> times a day it generates aboved message.
>
> Looks like something "wipes" by request objects in the middle of a
> view. This additional member of request is initialized in my own
> middleware - however its not possible to have this a None value (this
> would display user login form, not executing views).
>
> Same situations can be spoted in few other places in code - every time
> situations is similar - in line n request.account is object, in line
> n+1 its None. What may be important - this always happen in the same
> lines.
>
>
Are all of these places where you are calling cursor.execute on line n?

The description is very reminiscent of rogue pointer use causing
quasi-random memory corruption in C programs.  If it's always popping up
after a cursor.execute, and your database adapter is a C extension, I would
begin to suspect the database adapter.

Karen

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.


Reply via email to