1. markotibold
  2. django-tracking

Commits

ramusus  committed e75c7c6

fixed unicode errors in middleware

  • Participants
  • Parent commits 54a211d
  • Branches default

Comments (0)

Files changed (1)

File tracking/middleware.py

View file
         # see if the user agent is not supposed to be tracked
         for ua in UntrackedUserAgent.objects.all():
             # if the keyword is found in the user agent, stop tracking
-            if str(user_agent).find(ua.keyword) != -1:
+            if unicode(user_agent).find(ua.keyword) != -1:
                 return
 
         if hasattr(request, 'session'):
         visitor.url = request.path
         visitor.page_views += 1
         visitor.last_update = now
-        visitor.save()
+        try:
+            visitor.save()
+        except DatabaseError:
+            pass
 
 class VisitorCleanUpMiddleware:
     """