Skip to content

Commit

Permalink
switched to GAE mode
Browse files Browse the repository at this point in the history
  • Loading branch information
femmerling committed May 5, 2012
1 parent a650e20 commit 810c63f
Show file tree
Hide file tree
Showing 572 changed files with 91,148 additions and 0 deletions.
Binary file modified .DS_Store
Binary file not shown.
Binary file added gae/.DS_Store
Binary file not shown.
26 changes: 26 additions & 0 deletions gae/app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
application: hxlator
version: 1
runtime: python
api_version: 1

builtins:
- appstats: on
- remote_api: on
- datastore_admin: on

admin_console:
pages:
- name: Appstats
url: /_ah/stats/

handlers:

- url: /favicon.ico
static_files: static/img/favicon.ico
upload: static/img/favicon.ico

- url: /static
static_dir: static

- url: /.*
script: boot.py
38 changes: 38 additions & 0 deletions gae/appengine_console.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/python

""" Usage
python2.5 appengine_console.py <app-id>
for more information please read: http://code.google.com/appengine/articles/remote_api.html
"""
import code
import getpass
import sys
import os

root_dir = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, os.path.join(root_dir, 'lib'))
from gaePath.util import gae_sdk_path, add_gae_sdk_path

add_gae_sdk_path()
sys.path.append(gae_sdk_path() + "/lib/yaml/lib")
sys.path.append(gae_sdk_path() + "/lib/fancy_urllib")
sys.path.append(gae_sdk_path() + '/lib/webob')

from google.appengine.ext.remote_api import remote_api_stub
from google.appengine.ext import db

def auth_func():
return raw_input('Username:'), getpass.getpass('Password:')

if len(sys.argv) < 2:
print "Usage: %s app_id [host]" % (sys.argv[0],)
app_id = sys.argv[1]
if len(sys.argv) > 2:
host = sys.argv[2]
else:
host = '%s.appspot.com' % app_id

remote_api_stub.ConfigureRemoteDatastore(app_id, '/_ah/remote_api', auth_func, host)

code.interact('App Engine interactive console for %s' % (app_id,), None, locals())
23 changes: 23 additions & 0 deletions gae/boot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from wsgiref.handlers import CGIHandler
from google.appengine.ext.appstats import recording
import sys, os

root_dir = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, os.path.join(root_dir, 'lib'))

from main import app

if 'SERVER_SOFTWARE' in os.environ and os.environ['SERVER_SOFTWARE'].startswith('Dev'):
# use our debug.utils with Jinja2 templates
import debug.utils
sys.modules['werkzeug.debug.utils'] = debug.utils

# don't use inspect.getsourcefile because the imp module is empty
import inspect
inspect.getsourcefile = inspect.getfile

# wrap the application
from werkzeug import DebuggedApplication
app = DebuggedApplication(app, evalex=True)

CGIHandler().run(recording.appstats_wsgi_middleware(app))
43 changes: 43 additions & 0 deletions gae/decorators.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# coding: UTF-8

from flask import g
from flask import redirect
from flask import url_for

from functools import wraps

from werkzeug.contrib.cache import GAEMemcachedCache
cache = GAEMemcachedCache()

def login_required(f):
"""
redirects to the index page if the user has no session
"""
@wraps(f)
def decorated_function(*args, **kwargs):
if g.user is None:
return redirect(url_for('index'))
return f(*args, **kwargs)
return decorated_function

def cache_page(timeout=5 * 60, key='view/%s'):
"""
caches a full page in memcache, takes a timeout in seconds
which specifies how long the cache should be valid.
also allows a formatstring to be used as memcache key prefix.
source:
http://flask.pocoo.org/docs/patterns/viewdecorators/#caching-decorator
"""
def decorator(f):
@wraps(f)
def decorated_function(*args, **kwargs):
cache_key = key % request.path
rv = cache.get(cache_key)
if rv is not None:
return rv
rv = f(*args, **kwargs)
cache.set(cache_key, rv, timeout=timeout)
return rv
return decorated_function
return decorator
Binary file added gae/decorators.pyc
Binary file not shown.
11 changes: 11 additions & 0 deletions gae/index.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
indexes:

# AUTOGENERATED

# This index.yaml is automatically updated whenever the dev_appserver
# detects that a new type of query is run. If you want to manage the
# index.yaml file manually, remove the above marker line (the line
# saying "# AUTOGENERATED"). If you want to manage some indexes
# manually, move them above the marker line. The index.yaml file is
# automatically uploaded to the admin console when you next deploy
# your application using appcfg.py.
Binary file added gae/lib/.DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions gae/lib/debug/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Binary file added gae/lib/debug/__init__.pyc
Binary file not shown.
28 changes: 28 additions & 0 deletions gae/lib/debug/templates/console.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Console // Werkzeug Debugger</title>
<link rel="stylesheet" href="./__debugger__?cmd=resource&amp;f=style.css" type="text/css">
<script type="text/javascript" src="./__debugger__?cmd=resource&amp;f=jquery.js"></script>
<script type="text/javascript" src="./__debugger__?cmd=resource&amp;f=debugger.js"></script>
<script type="text/javascript">
var EVALEX = true,
CONSOLE_MODE = true;
</script>
</head>
<body>
<div class="debugger">
<h1>Interactive Console</h1>
<div class="explanation">
In this console you can execute Python expressions in the context of the
application. The initial namespace was created by the debugger automatically.
</div>
<div class="console"><div class="inner">The Console requires JavaScript.</div></div>
<div class="footer">
Brought to you by <strong class="arthur">DON'T PANIC</strong>, your
friendly Werkzeug powered traceback interpreter.
</div>
</div>
</body>
</html>
14 changes: 14 additions & 0 deletions gae/lib/debug/templates/dump_object.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<div class="box">
<h3>{{ title|e }}</h3>
{% if repr %}
<div class="repr">{{ repr }}</div>
{% endif %}
<table>
{% for key, value in items %}
<tr>
<th>{{ key|e }}</th>
<td>{{ value }}</td>
</tr>
{% endfor %}
</table>
</div>
5 changes: 5 additions & 0 deletions gae/lib/debug/templates/frame.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<div class="frame" id="frame-{{ frame.id }}">
<h4>File <cite>"{{ frame.filename|e }}"</cite>, line <em>{{ frame.lineno }}</em>,
in <code>{{ frame.function_name|e }}</code></h4>
<pre>{{ frame.current_line.strip()|e }}</pre>
</div>
10 changes: 10 additions & 0 deletions gae/lib/debug/templates/help_command.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<%py missing = object() %>
<div class="box">
<% if title and text %>
<h3>{{ title }}</h3>
<pre class="help">{{ text }}</pre>
<% else %>
<h3>Help</h3>
<p>Type help(object) for help about object.</p>
<% endif %>
</div>
8 changes: 8 additions & 0 deletions gae/lib/debug/templates/source.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<table class="source">
{% for line in lines %}
<tr class="{{ ' '.join(line.classes) }}">
<td class="lineno">{{ line.lineno }}</td>
<td>{{ line.code|e }}</td>
</tr>
{% endfor %}
</table>
52 changes: 52 additions & 0 deletions gae/lib/debug/templates/traceback_full.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>{{ traceback.exception|e }} // Werkzeug Debugger</title>
<link rel="stylesheet" href="./__debugger__?cmd=resource&amp;f=style.css" type="text/css">
<script type="text/javascript" src="./__debugger__?cmd=resource&amp;f=jquery.js"></script>
<script type="text/javascript" src="./__debugger__?cmd=resource&amp;f=debugger.js"></script>
<script type="text/javascript">
var TRACEBACK = {{ traceback.id }},
CONSOLE_MODE = false,
EVALEX = {% if evalex %}'true'{% else %}'false'{% endif %};
</script>
</head>
<body>
<div class="debugger">
<h1>{{ traceback.exception_type|e }}</h1>
<div class="detail">
<p class="errormsg">{{ traceback.exception|e }}</p>
</div>
<h2 class="traceback">Traceback <em>(most recent call last)</em></h2>
{{ traceback.render_summary(include_title=False) }}
<div class="plain">
<form action="http://paste.pocoo.org/" method="post">
<p>
<input type="hidden" name="language" value="pytb">
This is the Copy/Paste friendly version of the traceback. <span
class="pastemessage">You can also paste this traceback into the public
lodgeit pastebin: <input type="submit" value="create paste"></span>
</p>
<textarea cols="50" rows="10" name="code" readonly>{{ traceback.plaintext|e }}</textarea>
</form>
</div>
<div class="explanation">
The debugger caught an exception in your WSGI application. You can now
look at the traceback which lead to the error. <span class="nojavascript">
If you enable JavaScript you can also use additional features such as code
execution (if the evalex feature is enabled), automatic pasting of the
exceptions and much more.</span>
</div>
<div class="footer">
Brought to you by <strong class="arthur">DON'T PANIC</strong>, your
friendly Werkzeug powered traceback interpreter.
</div>
</div>
</body>
</html>
<!--
{{ traceback.plaintext }}
-->
6 changes: 6 additions & 0 deletions gae/lib/debug/templates/traceback_plaintext.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Traceback (most recent call last):
{% for frame in traceback.frames %}
File "{{ frame.filename }}", line {{ frame.lineno }}, in {{ frame.function_name }}
{{ frame.current_line.strip() }}
{% endfor %}
{{ traceback.exception }}
23 changes: 23 additions & 0 deletions gae/lib/debug/templates/traceback_summary.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<div class="traceback">
{% if traceback.is_syntax_error %}
{% if include_title %}
<h3>Syntax Error</h3>
{% endif %}
<ul>
{% for frame in traceback.frames %}
<li>{{ frame.render() }}</li>
{% endfor %}
</ul>
<pre>{{ traceback.exception|e }}</pre>
{% else %}
{% if include_title %}
<h3>Traceback <em>(most recent call last)</em>:</h3>
{% endif %}
<ul>
{% for frame in traceback.frames %}
<li{% if frame.info %} title="{{ frame.info|e }}"{% endif %}>{{ frame.render() }}</li>
{% endfor %}
</ul>
<blockquote>{{ traceback.exception|e }}</blockquote>
{% endif %}
</div>
20 changes: 20 additions & 0 deletions gae/lib/debug/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
"""
werkzeug.debug.utils
~~~~~~~~~~~~~~~~~~~~
Various other utilities.
:copyright: Copyright 2008 by Armin Ronacher.
:license: BSD.
"""
from os.path import join, dirname
from jinja2 import Environment, FileSystemLoader

env = Environment(loader = FileSystemLoader([join(dirname(__file__), 'templates')]))

def get_template(filename):
return env.get_template(filename)

def render_template(template_filename, **context):
return get_template(template_filename).render(**context)
Binary file added gae/lib/debug/utils.pyc
Binary file not shown.
1 change: 1 addition & 0 deletions gae/lib/flask
1 change: 1 addition & 0 deletions gae/lib/gaePath
1 change: 1 addition & 0 deletions gae/lib/gaeUtils
1 change: 1 addition & 0 deletions gae/lib/jinja2
1 change: 1 addition & 0 deletions gae/lib/werkzeug
Loading

0 comments on commit 810c63f

Please sign in to comment.