Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesturk committed Oct 22, 2009
1 parent 666d51b commit ee7a502
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
3 changes: 0 additions & 3 deletions layar/models.py

This file was deleted.

20 changes: 10 additions & 10 deletions layar/views.py
@@ -1,6 +1,6 @@
from hashlib import sha1
from django.conf import settings
from django.http import HttpResponse
from django.utils.hashcompat import sha_constructor as sha1
from django.utils import simplejson as json

class LayarException(Exception):
Expand All @@ -20,7 +20,7 @@ def __init__(self, id, lat, lon, title, actions=None, image_url=None,
self.line2 = line2 # recommended max len 35
self.line3 = line3
self.line4 = line4
self.type = type
self.type = type # must be 0..3
self.attribution = attribution # recommended max len 45
self.actions = actions

Expand All @@ -45,6 +45,7 @@ class LayarView(object):

results_per_page = 15
max_results = 50
verify_hash = True

def __init__(self):
self.developer_key = settings.LAYAR_DEVELOPER_KEY
Expand All @@ -64,18 +65,16 @@ def __call__(self, request):
slider = request.GET.get('CUSTOM_SLIDER')
page = int(request.GET.get('pageKey', 0))

# oauth: oauth_consumer_key, oauth_signature_method, oauth_timestamp,
# oauth_nonce, oauth_version, oauth_signature

layar_response = dict(hotspots=[], layer=layer_name, errorCode=0,
errorString='ok', nextPageKey=None, morePages=False)
errorString='ok', nextPageKey=None, morePages=False)

try:

# verify hash
key = self.developer_key + timestamp
if sha1(key).hexdigest() != developer_hash:
raise LayarException(20, 'Bad developerHash')
if self.verify_hash:
key = self.developer_key + timestamp
if sha1(key).hexdigest() != developer_hash:
raise LayarException(20, 'Bad developerHash')

# get ``max_results`` items from queryset
try:
Expand Down Expand Up @@ -113,4 +112,5 @@ def __call__(self, request):
layar_response['errorString'] = e.message

content = json.dumps(layar_response)
return HttpResponse(content, content_type='application/javascript; charset=utf-8')
return HttpResponse(content,
content_type='application/javascript; charset=utf-8')

0 comments on commit ee7a502

Please sign in to comment.