Skip to content

Commit

Permalink
Configured for google app engine
Browse files Browse the repository at this point in the history
  • Loading branch information
timothyfbowen committed Sep 23, 2011
1 parent ef0d1c3 commit d970010
Show file tree
Hide file tree
Showing 12 changed files with 164 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.pyc
*.swp
*~
11 changes: 11 additions & 0 deletions app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
application: bowenbroslate
version: 1
runtime: python
api_version: 1

handlers:
- url: /static
static_dir: static

- url: /.*
script: main.py
39 changes: 39 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import logging, os, sys

# Google App Engine imports.
from google.appengine.ext.webapp import util

# Force sys.path to have our own directory first, in case we want to import
# from it.
sys.path.insert(0, os.path.abspath(os.path.dirname(__file__)))

# Must set this env var *before* importing any part of Django
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'

import logging
import django.core.handlers.wsgi
import django.core.signals
import django.db
import django.dispatch.dispatcher

def log_exception(*args, **kwds):
logging.exception('Exception in request:')

# Log errors.
django.dispatch.dispatcher.connect(
log_exception, django.core.signals.got_request_exception)

# Unregister the rollback event handler.
django.dispatch.dispatcher.disconnect(
django.db._rollback_on_exception,
django.core.signals.got_request_exception)

def main():
# Create a Django application for WSGI.
application = django.core.handlers.wsgi.WSGIHandler()

# Run the WSGI CGI handler with that application.
util.run_wsgi_app(application)

if __name__ == '__main__':
main()
11 changes: 11 additions & 0 deletions manage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env python
from django.core.management import execute_manager
try:
import settings # Assumed to be in the same directory.
except ImportError:
import sys
sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
sys.exit(1)

if __name__ == "__main__":
execute_manager(settings)
35 changes: 35 additions & 0 deletions settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import os

# 'project' refers to the name of the module created with django-admin.py
ROOT_URLCONF = 'urls'

MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
# 'django.contrib.sessions.middleware.SessionMiddleware',
# 'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.doc.XViewMiddleware',
)

INSTALLED_APPS = (
# 'django.contrib.auth',
'django.contrib.contenttypes',
# 'django.contrib.sessions',
'django.contrib.sites',
)

ROOT_PATH = os.path.dirname(__file__)
TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or
# "C:/www/django/templates". Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
ROOT_PATH + '/templates',
)

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
'myBlog.posts',
)
21 changes: 21 additions & 0 deletions urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

from django.conf.urls.defaults import *
from django.conf import settings
import website.views

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
#admin.autodiscover()

urlpatterns = patterns('',
# Example:
# (r'^myBlog/', include('myBlog.foo.urls')),

# Uncomment the admin/doc line below and add 'django.contrib.admindocs'
# to INSTALLED_APPS to enable admin documentation:
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),

# Uncomment the next line to enable the admin:
#(r'^admin/(.*)', admin.site.root),
(r'^$', website.views.index),
)
Empty file added website/__init__.py
Empty file.
4 changes: 4 additions & 0 deletions website/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from myBlog.posts.models import Post
from django.contrib import admin

admin.site.register(Post)
18 changes: 18 additions & 0 deletions website/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from django.db import models
from django.contrib.auth.models import User

class Post(models.Model):
author = models.ForeignKey(User)
date = models.DateTimeField()
title = models.CharField(max_length=100)
post = models.TextField()
def __str__(self):
return self.title
class Admin:
list_display = ('author', 'date', 'title')
search_fields = ('title', 'post')
list_filter = ('author', 'date')



# Create your models here.
16 changes: 16 additions & 0 deletions website/models.py~
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from django.db import models
from django.contrib.auth.models import User

class Post(models.Model):
author = models.ForeignKey(User)
date = models.DateTimeField()
title = models.CharField(max_length=100)
post = models.TextField()
def __str__(self):
return self.title
class Admin:
pass



# Create your models here.
5 changes: 5 additions & 0 deletions website/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.http import HttpResponse

def index(request):
return HttpResponse("Hello world!")

1 change: 1 addition & 0 deletions website/views.py~
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Create your views here.

0 comments on commit d970010

Please sign in to comment.