Skip to content

Commit

Permalink
Moved many boilerplate files to their own folder to keep them separat…
Browse files Browse the repository at this point in the history
…ed from the actual application.
  • Loading branch information
tmeryu committed Sep 26, 2012
1 parent 9519455 commit eca493e
Show file tree
Hide file tree
Showing 113 changed files with 51 additions and 58 deletions.
32 changes: 16 additions & 16 deletions app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ skip_files:
- ^(.*/)?.*\.py[co]
- ^(.*/)?.*/RCS/.*
- ^(.*/)?\..*
- ^(.*/)?tests$
- ^(.*/)?test$
- ^(.*/)?test$
- ^Makefile
- ^COPYING.LESSER
Expand All @@ -29,32 +29,32 @@ builtins:
handlers:
- url: /favicon\.ico
mime_type: image/vnd.microsoft.icon
static_files: static/favicon.ico
upload: static/favicon.ico
static_files: boilerplate/static/favicon.ico
upload: boilerplate/static/favicon.ico

- url: /apple-touch-icon\.png
static_files: static/apple-touch-icon.png
upload: static/apple-touch-icon.png
static_files: boilerplate/static/apple-touch-icon.png
upload: boilerplate/static/apple-touch-icon.png

- url: /apple-touch-icon-precomposed\.png
static_files: static/apple-touch-icon-precomposed.png
upload: static/apple-touch-icon-precomposed.png
static_files: boilerplate/static/apple-touch-icon-precomposed.png
upload: boilerplate/static/apple-touch-icon-precomposed.png

- url: /(robots\.txt|humans\.txt|crossdomain\.xml)
static_files: static/\1
upload: static/(robots\.txt|humans\.txt|crossdomain\.xml)
static_files: boilerplate/static/\1
upload: boilerplate/static/(robots\.txt|humans\.txt|crossdomain\.xml)

- url: /img/(.*\.(gif|png|jpg))
static_files: static/img/\1
upload: static/img/(.*\.(gif|png|jpg))
static_files: boilerplate/static/img/\1
upload: boilerplate/static/img/(.*\.(gif|png|jpg))

- url: /css
mime_type: text/css
static_dir: static/css
static_dir: boilerplate/static/css

- url: /js
mime_type: text/javascript
static_dir: static/js
static_dir: boilerplate/static/js

- url: /.*
script: main.app
Expand All @@ -71,10 +71,10 @@ libraries:
error_handlers:
# Only errors with error_code, don't put a default error here
- error_code: over_quota
file: templates/errors/over_quota.html
file: boilerplate/templates/errors/over_quota.html

- error_code: dos_api_denial
file: templates/errors/dos_api_denial.html
file: boilerplate/templates/errors/dos_api_denial.html

- error_code: timeout
file: templates/errors/timeout.html
file: boilerplate/templates/errors/timeout.html
5 changes: 5 additions & 0 deletions appengine_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from google.appengine.ext.appstats import recording

def webapp_add_wsgi_middleware(app):
app = recording.appstats_wsgi_middleware(app)
return app
2 changes: 1 addition & 1 deletion babel/messages/checkers.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def num_plurals(catalog, message):
"message")
return

# skip further tests if no catalog is provided.
# skip further test if no catalog is provided.
elif catalog is None:
return

Expand Down
2 changes: 1 addition & 1 deletion babel/messages/tests/data/project/file1.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# file1.py for tests
# file1.py for test

from gettext import gettext as _
def foo():
Expand Down
2 changes: 1 addition & 1 deletion babel/messages/tests/data/project/file2.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# file2.py for tests
# file2.py for test

from gettext import ngettext

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-

# This file won't normally be in this directory.
# It IS only for tests
# It IS only for test

from gettext import ngettext

Expand Down
2 changes: 1 addition & 1 deletion babel/messages/tests/data/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# =============================================================================
# $Id: setup.py 114 2007-06-14 21:17:14Z palgarvio $
# =============================================================================
# $URL: http:https://svn.edgewall.org/repos/babel/tags/0.9.6/babel/messages/tests/data/setup.py $
# $URL: http:https://svn.edgewall.org/repos/babel/tags/0.9.6/babel/messages/test/data/setup.py $
# $LastChangedDate: 2007-06-14 23:17:14 +0200 (do, 14 jun 2007) $
# $Rev: 114 $
# $LastChangedBy: palgarvio $
Expand Down
1 change: 1 addition & 0 deletions boilerplate/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__author__ = 'tomas'
4 changes: 2 additions & 2 deletions config.py → boilerplate/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
'secret_key': '_PUT_KEY_HERE_YOUR_SECRET_KEY_',
}
webapp2_config['webapp2_extras.auth'] = {
'user_model': 'models.models.User',
'user_model': 'boilerplate.models.User',
'cookie_name': 'session_name'
}
webapp2_config['webapp2_extras.jinja2'] = {
'template_path': 'templates',
'template_path': 'boilerplate/templates',
'environment_args': {'extensions': ['jinja2.ext.i18n']},
}

Expand Down
File renamed without changes.
11 changes: 4 additions & 7 deletions web/handlers.py → boilerplate/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@
from webapp2_extras.appengine.auth.models import Unique
from google.appengine.api import taskqueue
# local application/library specific imports
import config
import web.forms as forms
import models.models as models
from boilerplate import config, models
import forms as forms
from lib import utils, httpagentparser, captcha, twitter
from lib.basehandler import BaseHandler
from lib.basehandler import user_required
Expand Down Expand Up @@ -51,8 +50,6 @@ def post(self):
from google.appengine.api import mail, app_identity
from google.appengine.api.datastore_errors import BadValueError
from google.appengine.runtime import apiproxy_errors
import config
from models import models

to = self.request.get("to")
subject = self.request.get("subject")
Expand Down Expand Up @@ -238,7 +235,7 @@ def get(self, provider_name):

elif provider_name == 'linkedin':
self.session['facebook'] = None
link = linkedin.LinkedIn(config.linkedin_api,config.linkedin_secret, callback_url)
link = linkedin.LinkedIn(config.linkedin_api, config.linkedin_secret, callback_url)
if link.request_token():
self.session['request_token']=link._request_token
self.session['request_token_secret']=link._request_token_secret
Expand Down Expand Up @@ -365,7 +362,7 @@ def get(self, provider_name):
# association with linkedin
elif provider_name == "linkedin":
callback_url = "%s/social_login/%s/complete" % (self.request.host_url, provider_name)
link = linkedin.LinkedIn(config.linkedin_api,config.linkedin_secret, callback_url)
link = linkedin.LinkedIn(config.linkedin_api, config.linkedin_secret, callback_url)
request_token = self.session['request_token']
request_token_secret= self.session['request_token_secret']
link._request_token = request_token
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion routes.py → boilerplate/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"""

from webapp2_extras.routes import RedirectRoute
from web import handlers
import handlers

secure_scheme = 'https'

Expand Down
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 2 additions & 3 deletions lib/basehandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@
from webapp2_extras import auth
from webapp2_extras import sessions
# local application/library specific imports
import config
from boilerplate import config, models
from lib import utils, i18n
from babel import Locale
import models.models as models

def user_required(handler):
"""
Expand Down Expand Up @@ -63,7 +62,7 @@ def jinja2_factory(app):
'str': str
})
j.environment.tests.update({
# Set tests.
# Set test.
# ...
})
return j
Expand Down
2 changes: 1 addition & 1 deletion lib/i18n.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from google.appengine.api import urlfetch
from webapp2_extras import i18n
from babel import Locale
import config
from boilerplate import config

def parse_accept_language_header(string, pattern='([a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})?)\s*(;\s*q\s*=\s*(1|0\.[0-9]+))?'):
"""
Expand Down
4 changes: 2 additions & 2 deletions lib/simplejson/encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def __init__(self, skipkeys=False, ensure_ascii=True,
Otherwise, it will be a ValueError to encode such floats.
If sort_keys is True, then the output of dictionaries will be
sorted by key; this is useful for regression tests to ensure
sorted by key; this is useful for regression test to ensure
that JSON serializations can be compared on a day-to-day basis.
If indent is a non-negative integer, then JSON array
Expand Down Expand Up @@ -219,7 +219,7 @@ def _encoder(o, _orig_encoder=_encoder, _encoding=self.encoding):

def floatstr(o, allow_nan=self.allow_nan, _repr=FLOAT_REPR, _inf=INFINITY, _neginf=-INFINITY):
# Check for specials. Note that this type of test is processor- and/or
# platform-specific, so do tests which don't depend on the internals.
# platform-specific, so do test which don't depend on the internals.

if o != o:
text = 'NaN'
Expand Down
10 changes: 1 addition & 9 deletions lib/tests/test_i18n.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,10 @@
'''
import unittest
import webapp2
import os
import re
import webtest
from google.appengine.ext import testbed
from google.appengine.ext import ndb
from webapp2_extras import auth
from mock import Mock
from mock import patch
from boilerplate import config

from lib import i18n
import config

class I18nTest(unittest.TestCase):
def setUp(self):
Expand Down
4 changes: 2 additions & 2 deletions lib/twitter.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from boilerplate import config
from lib.oauth2 import Consumer as OAuthConsumer, Token, Request as OAuthRequest, \
SignatureMethod_HMAC_SHA1
from urllib2 import Request, urlopen
from urllib2 import urlopen
from lib import simplejson
import config

# Twitter configuration
TWITTER_SERVER = 'api.twitter.com'
Expand Down
2 changes: 1 addition & 1 deletion lib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from Crypto.Cipher import AES

import config
from boilerplate import config

def random_string(size=6, chars=string.ascii_letters + string.digits):
""" Generate random string """
Expand Down
4 changes: 2 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
from boilerplate import config

__author__ = 'Rodrigo Augosto (@coto)'
__website__ = 'www.beecoss.com'

import os
import webapp2
import config
import routes
from boilerplate import routes

from lib.basehandler import handle_error

Expand Down
2 changes: 1 addition & 1 deletion pytz/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def _UTC():
These examples belong in the UTC class above, but it is obscured; or in
the README.txt, but we are not depending on Python 2.4 so integrating
the README.txt examples with the unit tests is not trivial.
the README.txt examples with the unit test is not trivial.
>>> import datetime, pickle
>>> dt = datetime.datetime(2005, 3, 1, 14, 13, 21, tzinfo=utc)
Expand Down
File renamed without changes.
9 changes: 4 additions & 5 deletions web/tests/test_handlers.py → test/test_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@
from mock import Mock
from mock import patch

import config
from boilerplate import config, models
import routes
import web
import models.models as models
import boilerplate
from lib import utils
from lib import captcha
from lib import i18n
Expand All @@ -44,7 +43,7 @@
class AppTest(unittest.TestCase):
def setUp(self):

# fix configuration if this is still a raw boilerplate code - required by tests with mails
# fix configuration if this is still a raw boilerplate code - required by test with mails
if not utils.is_email_valid(config.contact_sender):
config.contact_sender = "[email protected]"
if not utils.is_email_valid(config.contact_recipient):
Expand All @@ -53,7 +52,7 @@ def setUp(self):
# create a WSGI application.
w2config = config.webapp2_config
# use absolute path for templates
w2config['webapp2_extras.jinja2']['template_path'] = os.path.join(os.path.join(os.path.dirname(web.__file__), '..'), 'templates')
w2config['webapp2_extras.jinja2']['template_path'] = os.path.join(os.path.join(os.path.dirname(boilerplate.__file__), '..'), 'templates')
self.app = webapp2.WSGIApplication(config=w2config)
routes.add_routes(self.app)
self.testapp = webtest.TestApp(self.app, extra_environ={'REMOTE_ADDR' : '127.0.0.1'})
Expand Down
2 changes: 1 addition & 1 deletion testrunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import unittest

USAGE = """%prog SDK_PATH TEST_PATH
Run unit tests for App Engine apps.
Run unit test for App Engine apps.
SDK_PATH Path to the SDK installation
TEST_PATH Path to package containing test modules"""
Expand Down
Empty file removed web/__init__.py
Empty file.
Empty file removed web/tests/__init__.py
Empty file.

0 comments on commit eca493e

Please sign in to comment.