Skip to content

Commit

Permalink
added simplified feed.kml url
Browse files Browse the repository at this point in the history
  • Loading branch information
trey0 committed Oct 10, 2011
1 parent b1ceb6b commit cb9eef0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
26 changes: 16 additions & 10 deletions geocamLens/ViewKml.py
Expand Up @@ -52,7 +52,7 @@ def kmlStartSession(self, request):
print >> sys.stderr, "ViewKml: started session %s" % sessionId print >> sys.stderr, "ViewKml: started session %s" % sessionId
return KmlUtil.wrapKmlDjango(self.kmlGetStartSessionKml(request, sessionId)) return KmlUtil.wrapKmlDjango(self.kmlGetStartSessionKml(request, sessionId))


def kmlGetAllFeaturesFolder(self, request, searchQuery, newUtime): def kmlGetAllFeaturesFolder(self, request, searchQuery, newUtime=None):
allFeatures = self.search.getAllFeatures() allFeatures = self.search.getAllFeatures()
features = self.search.searchFeatures(allFeatures, searchQuery) features = self.search.searchFeatures(allFeatures, searchQuery)
if 0: if 0:
Expand All @@ -67,16 +67,19 @@ def kmlGetAllFeaturesFolder(self, request, searchQuery, newUtime):
</Folder> </Folder>
""" % featuresKml) """ % featuresKml)


def kmlGetInitialKml(self, request, sessionId): def kmlGetInitialKml(self, request, sessionId=None):
newUtime = datetime.datetime.now() if sessionId:
session, _created = GoogleEarthSession.objects.get_or_create(sessionId=sessionId, newUtime = datetime.datetime.now()
defaults=dict(utime=newUtime)) session, _created = GoogleEarthSession.objects.get_or_create(sessionId=sessionId,
session.utime = newUtime defaults=dict(utime=newUtime))
session.save() session.utime = newUtime
session.save()
query = session.getSearchQuery()
else:
newUtime = None
query = ''


allFeaturesFolder = self.kmlGetAllFeaturesFolder(request, allFeaturesFolder = self.kmlGetAllFeaturesFolder(request, query, newUtime)
session.getSearchQuery(),
newUtime)
global CACHED_CSS global CACHED_CSS
if not CACHED_CSS: if not CACHED_CSS:
cssPath = '%sgeocamCore/css/share.css' % settings.MEDIA_ROOT cssPath = '%sgeocamCore/css/share.css' % settings.MEDIA_ROOT
Expand Down Expand Up @@ -131,3 +134,6 @@ def kmlGetSessionResponse(self, request, quotedId, method):
return KmlUtil.wrapKmlDjango(self.kmlGetUpdateKml(request, sessionId)) return KmlUtil.wrapKmlDjango(self.kmlGetUpdateKml(request, sessionId))
else: else:
raise Exception('method must be "initial" or "update"') raise Exception('method must be "initial" or "update"')

def kmlFeed(self, request):
return KmlUtil.wrapKmlDjango(self.kmlGetInitialKml(request))
3 changes: 3 additions & 0 deletions geocamLens/urls.py
Expand Up @@ -23,6 +23,9 @@
{'challenge': 'digest', {'challenge': 'digest',
'readOnly': True}, 'readOnly': True},
'geocamLens_kmlGetSessionResponse'), 'geocamLens_kmlGetSessionResponse'),
(r'^feed\.kml$', views.kmlFeed,
{'readOnly': True},
'geocamLens_kml'),


# features # features
(r'^features.json', views.featuresJson, {'readOnly': True}), (r'^features.json', views.featuresJson, {'readOnly': True}),
Expand Down

0 comments on commit cb9eef0

Please sign in to comment.