Created
October 7, 2010 18:58
-
-
Save RobCombs/615676 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://localhost:8000/photo/rob/test/events_event/ | |
from django.db import connection, transaction | |
def photo_detail(request, slug_hierarchy, pk_hash): | |
cursor = connection.cursor() | |
"""Retrieve a photo object by the hash of the photo primary key and return it to the photo template""" | |
try: | |
cursor.execute("DROP TABLE %s" % pk_hash) | |
transaction.commit_unless_managed() | |
photo = MedleyPhoto.objects.get_by_pk_hash(pk_hash, | |
sites__id__exact=settings.SITE_ID, | |
status__exact=LIVE_STATUS | |
) | |
except MedleyPhoto.DoesNotExist: | |
raise Http404, "Photo does not exist: %s" % pk_hash | |
except MedleyPhoto.MultipleObjectsReturned: | |
logging.warning("Multiple photos found for pk_hash %s and site %d", | |
pk_hash, settings.SITE_ID) | |
raise Http404, "Photo does not exist: %s" % pk_hash | |
context = { | |
'photo': photo, | |
} | |
return render_to_response('photos/photo.html', context, context_instance=RequestContext(request)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment