Kieran
Have you restarted your server lately? I find that bug turns up from
time to time when the auto reloader doesn't reload properly.
I am overriding a save function of a model with the following code:
def save(self, *args, **kwargs):if (not self.id) and self.email != '':self.create_user()if hasattr(self, 'user'):self.user.email = self.emailself.user.first_name = self.voornaamself.user.last_name = " ".join((self.tussenvoegsel, self.achternaam))self.user.save()super(Lid, self).save(*args, **kwargs)where Lid is the name of the Model. However, for some reason it throws the following error since a while (don't know since when, don't know what changed, can't find anything suspicious in hg log...) "super() argument 1 must be type, not None". When I run with pdb.set_trace as the first line of the save method in the dev server, I can see that Lid is indeed None. What is surprising is that ALL my imports are None (User, datetime, models, etc.). I vaguely remember encountering this error before, but I don't remember what I did to fix it. What could have overridden all those things with None?Does anybody have any clues? I can post my whole models.py if necessary, but it's rather large.
import pdb;pdb.set_trace()
before the super and check.
> --
>
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
Are you sure that Lid is defined in this context? Try putting:
import pdb;pdb.set_trace()
before the super and check.
Perhaps this is a cyclic Python import issue. I think Python will go
through a file twice, the first time getting names into the scope, and
then a second time to fill in the details. Perhaps you are still in
the middle of importing when you are attempting to use the partially
loaded items.
Another way of looking at this is that an import statement is
atomic... no code will (should) run until all imports have completed,
then the code runs. I would try importing just some parts, or maybe
changing the import order.
Just some ideas. Good luck!
-Doug
I have no idea how to fix it but I might have seen a similar problem;
Have you inspected globals()? What happened to me was that the
imported names existed in globals but they all pointed to None, hence,
useless. I could reimport something in the scope it were to be used,
but a function couldn't see other functions/symbols in the same
module!
HM
Perhaps this is a cyclic Python import issue. I think Python will go
through a file twice, the first time getting names into the scope, and
then a second time to fill in the details. Perhaps you are still in
the middle of importing when you are attempting to use the partially
loaded items.