Created
July 6, 2011 21:08
-
-
Save pamelafox/1068330 to your computer and use it in GitHub Desktop.
SimpleGeo Timezone Calculation on Python App Engine
This file contains hidden or 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
class User(db.Model): | |
location = db.StringProperty() | |
timezone = db.StringProperty(default='America/Los_Angeles') | |
# Do this once per user | |
def calculate_timezone(self): | |
from simplegeo import Client | |
client = Client('oauth key', 'oauth secret SHH') | |
response = client.context.get_context_by_address(self.location) | |
for feature in response['features']: | |
if feature['classifiers'][0]['category'] == 'Time Zone': | |
timezone = feature['name'] | |
self.timezone = timezone | |
self.put() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment