Skip to content

Commit

Permalink
Beginning of GAE port
Browse files Browse the repository at this point in the history
Notes:
* Still unclear how we should handle secret information such as
  keys and tokens.
* app.wsgi better be renamed to app.py
* In GAE, we would have to use memcached, so Redis must be changed.
* For https, certificates will have to be handled differently :/

So we still can't just migrate to GAE, but this is a start, so I will
commit, and keep it.

refs #37
  • Loading branch information
lestrrat committed Jul 30, 2016
1 parent c5b38d8 commit b14b8cf
Show file tree
Hide file tree
Showing 6 changed files with 1,620 additions and 1,004 deletions.
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,9 @@ update-trans:
pybabel update --input-file messages.pot --output-dir translations/ --locale ja --domain messages

compile-trans:
pybabel compile --directory translations/ --domain messages
pybabel compile --directory translations/ --domain messages

appengine-deploy:
# Note: If you are on OS X, and you are using homebrew python,
# you are going to get a weird error.
pip install -r requirements.txt -t lib
22 changes: 20 additions & 2 deletions app.wsgi
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,28 @@ class Config(object):
with open(file, 'r') as f:
self.cfg = json.load(f)

for section in ['OCTAV', 'REDIS_INFO', 'GITHUB', 'GOOGLE_MAP']:
sections = {
'OCTAV': ['debug', 'endpoint', 'key', 'secret'],
'REDIS_INFO': ['host','port', 'db'],
'GITHUB': ['client_id', 'client_secret'],
'GOOGLE_MAP': ['api_key']
}
for section in sections.keys():
if not self.cfg.get(section):
raise Exception( "missing section '" + section + "' in config file '" + file + "'" )
if self.cfg.get('OCTAV').get('BASE_URI'):
raise Exception(
'DEPRECATED: {"OCTAV":{"BASE_URI"}} in config.json is deprecated.\
Please use {"OCTAV":{"endpoint"}} instead and remove {"OCTAV":{"BASE_URI"}}.'
)
)

# Allow settings to be derived from environment
for section, subsections in sections.items():
for subsection in subsections:
v = os.getenv('%s_%s' % (section,subsection.upper()), None)
if not v:
continue
self.cfg[section][subsection] = v

def section(self, name):
return self.cfg.get(name)
Expand Down Expand Up @@ -110,10 +124,14 @@ def index():
key = "conferences.lang." + lang
conferences = cache.get(key)
if not conferences:
print("fetching..")
conferences = octav.list_conference(lang=lang)
print(conferences)
if conferences is None:
raise HTTPError(status=500, body=octav.last_error())
cache.set(key, conferences, 600)

print("rendering...")
return template('index.tpl', {
'pagetitle': 'top',
'conferences': conferences,
Expand Down
2 changes: 2 additions & 0 deletions appengine_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import vendor
vendor.add('lib')
Loading

0 comments on commit b14b8cf

Please sign in to comment.