'NoneType' object has no attribute 'delete'

1,133 views
Skip to first unread message

Chris Curvey

unread,
Apr 29, 2008, 3:29:20 PM4/29/08
to SQLElixir
Anyone seen this message before? I have to believe it's a usage error
on my part, but I can't figure out what the practical meaning is

Module elixir.entity:826 in delete

def delete(self, *args, **kwargs):
return object_session(self).delete(self, *args, **kwargs)

<type 'exceptions.AttributeError'>: 'NoneType' object has no attribute
'delete'

alex23

unread,
Apr 29, 2008, 7:33:56 PM4/29/08
to SQLElixir
Hey Chris,

You didn't provide any context for where the error is occuring but
basically, this is a standard Python exception for trying to access a
non-existent attribute - in this case the method 'delete' - on an
object.

ActivePython 2.5.1.1 (ActiveState Software Inc.) based on
Python 2.5.1 (r251:54863, May 1 2007, 17:47:05) [MSC v.1310 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> a = None
>>> a.delete()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'NoneType' object has no attribute 'delete'

My guess is you're trying to delete an object you think you've
retrieved from a db when the actual object itself is None.

- alex23

Chris Curvey

unread,
Apr 29, 2008, 10:44:35 PM4/29/08
to SQLElixir


On Apr 29, 7:33 pm, alex23 <wuwe...@gmail.com> wrote:
> On Apr 30, 5:29 am, Chris Curvey <ccur...@gmail.com> wrote:
>
> > Anyone seen this message before? I have to believe it's a usage error
> > on my part, but I can't figure out what the practical meaning is
>
> > Module elixir.entity:826 in delete
>
> > def delete(self, *args, **kwargs):
> > return object_session(self).delete(self, *args, **kwargs)
>
> > <type 'exceptions.AttributeError'>: 'NoneType' object has no attribute
> > 'delete'
>
> Hey Chris,
>
> You didn't provide any context for where the error is occuring but
> basically, this is a standard Python exception for trying to access a
> non-existent attribute - in this case the method 'delete' - on an
> object.
>

oh yeah, I got that. I guess I'm asking if anyone can think of a
reason why object_session(self) would return None. To hack around the
problem, I put the session.flush() statements in my code into try/
catch blocks, and I just pass on the error, but I'm wondering what
other problems I'm hiding by doing that.

Erik Janssens

unread,
Apr 30, 2008, 2:01:03 AM4/30/08
to sqle...@googlegroups.com
I've had that problem as well, and it was fixed by making sure all
my objects were connected to the same session. I did not investigate
what the underlying reason was, I suspect it was because of a relation
between objects in a different session.
Reply all
Reply to author
Forward
0 new messages