Issue Details (XML | Word | Printable)

Key: FLM-15
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Critical Critical
Assignee: Marcin Mościcki
Reporter: Borys Musielak
Votes: 0
Watchers: 0
Operations

Clone this issue
Create sub-task
If you were logged in you would be able to see more operations.
Filmaster

DoesNotExist exception on film page

Created: 26/Mar/09 03:11 PM   Updated: 25/Sep/11 02:19 PM
Component/s: Movie Database
Affects Version/s: 1.0
Fix Version/s: 1.0

Time Tracking:
Not Specified


 Description  « Hide
DoesNotExist exception occurs at http://dev.filmaster.pl/film/bienvenue-chez-les-chtis/

The film exists, it looks like the DoesNotExist is thrown when retrieving the related films (basing on tags)

Top Priority: catch the exception so that the film site is displayed (even if no related films show up
General fix: Analyze why on earth the exception occurs (might be coding error but might be as well some data inconsistency which would pretty much suck)

First reported on Polish Filmaster forum by Habdank: http://filmaster.pl/forum/forum-filmastera/bledy-mniejsze-i-wieksze#2985

Traceback below:

/home/filmaster/django-trunk/django/core/handlers/base.py in get_response
# Apply view middleware
for middleware_method in self._view_middleware:
response = middleware_method(request, callback, callback_args, callback_kwargs)
if response:
return response
try:
response = callback(request, *callback_args, **callback_kwargs) ...
except Exception, e:
# If the view raised an exception, run it through exception
# middleware, and if the exception middleware returns a
# response, use that. Otherwise, reraise the exception.
for middleware_method in self._exception_middleware:
response = middleware_method(request, e)
▶ Local vars Variable Value
callback <function show_film at 0x8fae2cc>
callback_args ()
callback_kwargs {'permalink': u'bienvenue-chez-les-chtis'}
e DoesNotExist('Film matching query does not exist.',)
exc_info (<class 'film20.core.models.DoesNotExist'>, DoesNotExist('Film matching query does not exist.',), <traceback object at 0x90f1144>)
exceptions <module 'django.core.exceptions' from '/home/filmaster/django-trunk/django/core/exceptions.pyc'>
middleware_method <bound method SubdomainMiddleware.process_view of <film20.core.middleware.SubdomainMiddleware instance at 0x89b170c>>
receivers [(<function _rollback_on_exception at 0x8828aac>, None)]
request <ModPythonRequest path:/film/bienvenue-chez-les-chtis/, GET:<QueryDict: {}>, POST:<QueryDict: {}>, COOKIES:{'__utma': '161683627.2288235355926502400.1233567513.1238066176.1238075119.138', '__utmb': '161683627.2.10.1238075119', '__utmc': '161683627', '__utmz': '161683627.1237301606.107.4.utmcsr=google.com|utmccn=(referral)|utmcmd=referral|utmcct=/reader/view/', 'sessionid': '691448a1a48c85b7e558a34822239dc0'}, META:{'AUTH_TYPE': 'Basic', 'CONTENT_LENGTH': 0L, 'CONTENT_TYPE': None, 'GATEWAY_INTERFACE': 'CGI/1.1', 'HTTP_ACCEPT': 'text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1', 'HTTP_ACCEPT_CHARSET': 'iso-8859-1, utf-8, utf-16, *;q=0.1', 'HTTP_ACCEPT_ENCODING': 'deflate, gzip, x-gzip', 'HTTP_ACCEPT_LANGUAGE': 'en-GB,en;q=0.9', 'HTTP_AUTHORIZATION': 'Basic bWljaHVrOmtueXBlazEzMDQxMjM=', 'HTTP_CACHE_CONTROL': 'no-cache', 'HTTP_CONNECTION': 'keep-alive', 'HTTP_COOKIE': '__utmz=151928108.1233665733.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __utma=151928108.1460347738191797000.1233665733.1237802587.1238075509.9; __utmc=151928108; __utmb=151928108.2.10.1238075509; __utmz=161683627.1237301606.107.4.utmcsr=google.com|utmccn=(referral)|utmcmd=referral|utmcct=/reader/view/; sessionid=691448a1a48c85b7e558a34822239dc0; __utma=161683627.2288235355926502400.1233567513.1238066176.1238075119.138; __utmc=161683627; __utmb=161683627.2.10.1238075119', 'HTTP_COOKIE2': '$Version=1', 'HTTP_HOST': 'dev.filmaster.pl', 'HTTP_PRAGMA': 'no-cache', 'HTTP_USER_AGENT': 'Opera/9.62 (Windows NT 5.1; U; en) Presto/2.1.1', 'HTTP_VIA': '1.0 lonhhsgdpx01 (NetCache NetApp/6.0.4P1D1), 1.1 webwasher (Webwasher 6.7.5.3601)', 'PATH_INFO': u'/film/bienvenue-chez-les-chtis/', 'PATH_TRANSLATED': None, 'QUERY_STRING': None, 'REMOTE_ADDR': '160.83.32.14', 'REMOTE_HOST': None, 'REMOTE_IDENT': None, 'REMOTE_USER': 'michuk', 'REQUEST_METHOD': 'GET', 'SCRIPT_NAME': '', 'SERVER_NAME': 'dev.filmaster.pl', 'SERVER_PORT': 0, 'SERVER_PROTOCOL': 'HTTP/1.1', 'SERVER_SOFTWARE': 'mod_python'}>
resolver <RegexURLResolver film20.urls ^/>
response None
self <django.core.handlers.modpython.ModPythonHandler object at 0x859b1cc>
settings <django.conf.LazySettings object at 0x85d7b8c>
urlconf 'film20.urls'
urlresolvers <module 'django.core.urlresolvers' from '/home/filmaster/django-trunk/django/core/urlresolvers.pyc'>

/home/filmaster/film20-dev/film20/core/film_views.py in show_film
workflow.check_if_supported_ajax()
workflow.check_if_edit_tags()
workflow.check_if_edit_film_localized()
workflow.check_if_edit_film_description()
workflow.get_film_for_permalink()
workflow.get_film_details()
workflow.get_related_films() ...
# workflow.get_other_films_directed_by()
workflow.vote_check_if_logged()
workflow.load_rating_forms()
▶ Local vars Variable Value
ajax None
permalink u'bienvenue-chez-les-chtis'
request <ModPythonRequest path:/film/bienvenue-chez-les-chtis/, GET:<QueryDict: {}>, POST:<QueryDict: {}>, COOKIES:{'__utma': '161683627.2288235355926502400.1233567513.1238066176.1238075119.138', '__utmb': '161683627.2.10.1238075119', '__utmc': '161683627', '__utmz': '161683627.1237301606.107.4.utmcsr=google.com|utmccn=(referral)|utmcmd=referral|utmcct=/reader/view/', 'sessionid': '691448a1a48c85b7e558a34822239dc0'}, META:{'AUTH_TYPE': 'Basic', 'CONTENT_LENGTH': 0L, 'CONTENT_TYPE': None, 'GATEWAY_INTERFACE': 'CGI/1.1', 'HTTP_ACCEPT': 'text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1', 'HTTP_ACCEPT_CHARSET': 'iso-8859-1, utf-8, utf-16, *;q=0.1', 'HTTP_ACCEPT_ENCODING': 'deflate, gzip, x-gzip', 'HTTP_ACCEPT_LANGUAGE': 'en-GB,en;q=0.9', 'HTTP_AUTHORIZATION': 'Basic bWljaHVrOmtueXBlazEzMDQxMjM=', 'HTTP_CACHE_CONTROL': 'no-cache', 'HTTP_CONNECTION': 'keep-alive', 'HTTP_COOKIE': '__utmz=151928108.1233665733.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __utma=151928108.1460347738191797000.1233665733.1237802587.1238075509.9; __utmc=151928108; __utmb=151928108.2.10.1238075509; __utmz=161683627.1237301606.107.4.utmcsr=google.com|utmccn=(referral)|utmcmd=referral|utmcct=/reader/view/; sessionid=691448a1a48c85b7e558a34822239dc0; __utma=161683627.2288235355926502400.1233567513.1238066176.1238075119.138; __utmc=161683627; __utmb=161683627.2.10.1238075119', 'HTTP_COOKIE2': '$Version=1', 'HTTP_HOST': 'dev.filmaster.pl', 'HTTP_PRAGMA': 'no-cache', 'HTTP_USER_AGENT': 'Opera/9.62 (Windows NT 5.1; U; en) Presto/2.1.1', 'HTTP_VIA': '1.0 lonhhsgdpx01 (NetCache NetApp/6.0.4P1D1), 1.1 webwasher (Webwasher 6.7.5.3601)', 'PATH_INFO': u'/film/bienvenue-chez-les-chtis/', 'PATH_TRANSLATED': None, 'QUERY_STRING': None, 'REMOTE_ADDR': '160.83.32.14', 'REMOTE_HOST': None, 'REMOTE_IDENT': None, 'REMOTE_USER': 'michuk', 'REQUEST_METHOD': 'GET', 'SCRIPT_NAME': '', 'SERVER_NAME': 'dev.filmaster.pl', 'SERVER_PORT': 0, 'SERVER_PROTOCOL': 'HTTP/1.1', 'SERVER_SOFTWARE': 'mod_python'}>
workflow <film20.core.film_views.FilmViewWorkflowHelper instance at 0x8ea004c>

/home/filmaster/film20-dev/film20/core/film_views.py in get_related_films
return self.related_films_already_rated
def get_related_films(self):
# no film, no related object
if self.the_film==None:
return None
if self.related_films == None:
self.related_films = self.film_helper.get_related_localized_objects(self.the_film, NUMBER_OF_RELATED_FILMS) ...
return self.related_films
# not used -- TODO: remove?
def get_other_films_directed_by(self):
# no film, no related object
▼ Local vars Variable Value
self <film20.core.film_views.FilmViewWorkflowHelper instance at 0x8ea004c>

/home/filmaster/film20-dev/film20/core/film_helper.py in get_related_localized_objects
related = TaggedItem.objects.get_related(localized_obj, directors_q, count)
for o in related:
o.similarity += Tag.objects.get_base_weight()
related_by_tags = TaggedItem.objects.get_related(localized_obj, ObjectLocalized, count)
for o in related_by_tags:
if not o in related:
related.append(o)
related.sort(lambda x,y: int(y.similarity-x.similarity or y.parent.film.popularity-x.parent.film.popularity)) ...
return related[:count]
def get_recommended_films(self, user_id):
"""
Fetch recommended films for a user
▶ Local vars Variable Value
count 6
directors_q []
film <Film: Bienvenue chez les Ch'tis>
localized_obj <ObjectLocalized: ObjectLocalized object>
o <ObjectLocalized: ObjectLocalized object>
related [<ObjectLocalized: ObjectLocalized object>, <ObjectLocalized: ObjectLocalized object>, <ObjectLocalized: ObjectLocalized object>, <ObjectLocalized: ObjectLocalized object>, <ObjectLocalized: ObjectLocalized object>, <ObjectLocalized: ObjectLocalized object>]
related_by_tags [<ObjectLocalized: ObjectLocalized object>, <ObjectLocalized: ObjectLocalized object>, <ObjectLocalized: ObjectLocalized object>, <ObjectLocalized: ObjectLocalized object>, <ObjectLocalized: ObjectLocalized object>, <ObjectLocalized: ObjectLocalized object>]
self <film20.core.film_helper.FilmHelper instance at 0x90e4c0c>

/home/filmaster/film20-dev/film20/core/film_helper.py in <lambda>
related = TaggedItem.objects.get_related(localized_obj, directors_q, count)
for o in related:
o.similarity += Tag.objects.get_base_weight()
related_by_tags = TaggedItem.objects.get_related(localized_obj, ObjectLocalized, count)
for o in related_by_tags:
if not o in related:
related.append(o)
related.sort(lambda x,y: int(y.similarity-x.similarity or y.parent.film.popularity-x.parent.film.popularity)) ...
return related[:count]
def get_recommended_films(self, user_id):
"""
Fetch recommended films for a user
▶ Local vars Variable Value
x <ObjectLocalized: ObjectLocalized object>
y <ObjectLocalized: ObjectLocalized object>

/home/filmaster/django-trunk/django/db/models/fields/related.py in __get__
if instance is None:
raise AttributeError, "%s must be accessed via instance" % self.related.opts.object_name
try:
return getattr(instance, self.cache_name)
except AttributeError:
params = {'%s__pk' % self.related.field.name: instance._get_pk_val()}
rel_obj = self.related.model._default_manager.get(**params) ...
setattr(instance, self.cache_name, rel_obj)
return rel_obj
def __set__(self, instance, value):
if instance is None:
raise AttributeError, "%s must be accessed via instance" % self.related.opts.object_name
▶ Local vars Variable Value
instance <Object: 72480 [francois-ozon]>
instance_type <class 'film20.core.models.Object'>
params {'parent__pk': 72480}
self <django.db.models.fields.related.SingleRelatedObjectDescriptor object at 0x8b62bac>

/home/filmaster/django-trunk/django/db/models/manager.py in get
def distinct(self, *args, **kwargs):
return self.get_query_set().distinct(*args, **kwargs)
def extra(self, *args, **kwargs):
return self.get_query_set().extra(*args, **kwargs)
def get(self, *args, **kwargs):
return self.get_query_set().get(*args, **kwargs) ...
def get_or_create(self, **kwargs):
return self.get_query_set().get_or_create(**kwargs)
def create(self, **kwargs):
return self.get_query_set().create(**kwargs)
▶ Local vars Variable Value
args ()
kwargs {'parent__pk': 72480}
self <film20.core.models.FilmManager object at 0x8b5ecac>

/home/filmaster/django-trunk/django/db/models/query.py in get
"""
clone = self.filter(*args, **kwargs)
num = len(clone)
if num == 1:
return clone._result_cache[0]
if not num:
raise self.model.DoesNotExist("%s matching query does not exist."
% self.model._meta.object_name) ...
raise self.model.MultipleObjectsReturned("get() returned more than one %s -- it returned %s! Lookup parameters were %s"
% (self.model._meta.object_name, num, kwargs))
def create(self, **kwargs):
"""
Creates a new object with the given kwargs, saving it to the database
▶ Local vars Variable Value
args ()
clone []
kwargs {'parent__pk': 72480}
num 0

 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Marcin Mościcki added a comment - 26/Mar/09 06:59 PM
Zabiorę się za to jutro.

Marcin Mościcki added a comment - 27/Mar/09 06:44 PM
Ok, there problem was again the fact that we tag localized objects and thus can't automatically narrow the search for related objects to films or people - content_type_id on tagging_taggeditem is always object_localized (and sometimes filmlocalized - when filmlocalized exists, we associate film tags to both).

I added a 'where parent_id in select parent_id from core_film' restriction.

Borys Musielak added a comment - 27/Mar/09 07:46 PM
Wouldn't it be better to check for *type* field in Object instead? I think the additional query might make the already not-so-good performance a disaster.

Marcin Mościcki added a comment - 27/Mar/09 07:59 PM
The faulty query didn't use core_object table at all, so it doesn't matter whether we add another join to core_object to check the type or core_film to check existance - if anything, the latter should be faster and more robust. We will really need caching and tag 2.0 library when more pressing functionality is done. BTW: can you think of a film title related to tagging? I thought it would be nice to name modules after films, for example search 2.0 implementation becoming thesearchers :)

Borys Musielak added a comment - 27/Mar/09 08:18 PM
OK you're right I guess.

The subquery 'where parent_id in select parent_id from core_film' seemed to me a bit awkward compared to adding another join but I guess postgresql nowadays is smarter than it used to be some time ago when you had to be more explicit, otherwise it would be coming up with bizarre query planes at times.

Tagging, tagging... maybe this one: Tag der Idioten http://www.imdb.com/title/tt0083160/ ?:P

Borys Musielak added a comment - 30/Mar/09 03:14 AM

Marcin Mościcki added a comment - 30/Mar/09 10:14 AM
Hmm, looks like commit failed.
'Could not connect to server (musielak.eu)' - is it me or is it you?

Borys Musielak added a comment - 30/Mar/09 10:21 AM
Apache was down. Just restarted. Try now.

Marcin Mościcki added a comment - 30/Mar/09 10:24 AM
Should be ok now...

Borys Musielak added a comment - 30/Mar/09 07:47 PM
Faktycznie, działa :)
Zamykam i wrzucam na prod. Dzięki!