def make_le(request, obj, change_message, action_flag=2): from django.contrib.admin.models import LogEntry from day.models import User '''make logentry.''' try: if request is None: user = User.objects.filter(username='******')[0] ip='' if not obj: class Bag(): pass obj=Bag() obj.id=None if obj.__class__ == user.__class__: user = obj #just user ernie content_type=None else: user = request.user ip = request.META['REMOTE_ADDR'] content_type = get_contenttype(obj.__class__) if user.is_anonymous(): log.info('anon user did an action, saving as ernie.') user = User.objects.get(username='******') object_id = obj.id object_repr = str(obj) le = LogEntry(user=user, content_type=content_type, object_id=object_id, object_repr=object_repr, action_flag=action_flag, change_message=change_message) le.save() except Exception, e: log.error(e) ipdb()
def ipdb(): import inspect try: par = inspect.stack()[1] desc = '%s line:%s' % (par[1], [par[2]]) except: log.error('failed to inspect stack.') from util import ipdb;ipdb() desc='failed to inspect stack.' if settings.LOCAL: log.error('missed ipdb call. %s', desc) import ipdb;ipdb.set_trace() else: log.error('missed ipdb call. %s', desc)