开发者

Django: debugging entries just disapearing

So, I'm pulling my hair out here, and maybe someone has an insight.

I have a cronjob that loops over all my Link objects, does some stuff, might change properties on the object and does a save(). That's it.

Every so often (around once an hour), one of my rows just disappears. Poof. Nothing in the logs.

So, I'm trying to add debugging statements everywhere, but are there any glaring reasons for an entry to disapear? Is the only way to remove a开发者_JAVA技巧n entry by calling delete()?

Just any general directions to go would be wonderful, thank you.

Some ideas I've had:

  • git push while the cronjob is running
  • some cascading delete is wiping them out
  • some django method is calling delete on an exception


You could override the delete method on your Link class and dump a stack trace or log a message to see if it's indeed happening from within your Django application.

import sys, traceback

def delete(self):
   super(Link, self).delete()

   try:
      assert False
   except AssertionError, e
      traceback.print_tb(file=sys.stdout)

There may be a better way to get and log a stack trace, but that's the first thing that came to mind.


You could use django-logging with LOGGING_LOG_SQL = True to log all the SQL, so you can see if any DELETE's are occurring.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜