Permalink
Browse files

Final.

  • Loading branch information...
1 parent 864f040 commit acc2425ee58f3143b95174287d949413f78af070 Christopher Peplin committed Nov 13, 2010
View
@@ -0,0 +1,3 @@
+[submodule "vendor/comrade"]
+ path = vendor/comrade
+ url = https://github.com/bueda/django-comrade.git
View
170 README.md
@@ -9,5 +9,171 @@ can go a long way, if one method is not better than another.
## Acknowledgements
-The folks at Mozilla working the [next version of AMO](https://github.com/jbalogh/zamboni)
-were the first inspiration for this layout.
+The folks at Mozilla working on the [next version of AMO](https://github.com/jbalogh/zamboni)
+were the primary inspiration for this layout.
+
+## Directory Structure
+
+ django-boilerplate/
+ ....apps/
+ ....foo/
+ ....templates/
+ ....templates/foo/
+ ....templates/foo/foo.html
+ ....models.py
+ ....views.py
+ ....forms.py
+ ....lib/
+ ....logconfig/
+ ....media/
+ ....css/
+ ....vendor/
+ ....js/
+ ....vendor/
+ ....images/
+ ....requirements/
+ ....common.txt
+ ....dev.txt
+ ....production.txt
+ ....templates/
+ ....vendor/
+ ....environment.py
+ ....fabfile.py
+ ....manage.py
+ ....settings.py
+
+
+### apps
+
+Everything in this directory is added to the PYTHONPATH when the
+`environment.py` file is imported.
+
+### lib
+
+Python packages and modules that aren't true Django 'apps' - i.e. they don't
+have their own models, views or forms. These are just regular Python classes and
+methods, and they don't go in the `INSTALLED_APPS` list of your project's
+settings file.
+
+Everything in this directory is added to the PYTHONPATH when the
+`environment.py` file is imported.
+
+### logconfig
+
+An extended version of the
+[log_settings](https://github.com/jbalogh/zamboni/blob/master/log_settings.py)
+module from Mozilla's [zamboni](https://github.com/jbalogh/zamboni).
+
+This package includes an `initialize_logging` method meant to be called from the
+project's `settings.py` that sets Python's logging system. The default for
+server deployments is to log to syslog, and the default for solo development is
+simply to log to the console.
+
+### media
+
+Just an arbitrary convention - a subfolder each for CSS, Javascript and images.
+3rd-party files (e.g. the 960.gs CSS files or jQuery) go in a `vendor/`
+subfolder to keep your own code separate.
+
+### requirements
+
+pip requirements files, optionally one for each app environment. The
+`common.txt` is installed in every case.
+
+Our Fabfile (see below) is set up to install the project's dependencies from
+these files. It's an attempt to standardize the location for dependencies like
+Rails' `Gemfile`. We specificially avoid also listing the dependencies in the
+README of the project, since a list there isn't actually checked programatically
+or ever installed, so it tends to quickly become out of date.
+
+### templates
+
+Project-wide templates (i.e. those not belonging to any specific app in the
+`apps/` folder). The boilerplate includes a `base.html` template that defines
+these blocks:
+
+#### <head>
+
+`title`
+Text for the browser title bar. You can set a default here and append/prepend to
+it in sub-templates using `{{ super }}`.
+
+`site_css`
+
+Primary CSS files for the site. By defaut, includes `media/css/reset.css` and
+`media/css/base.css`.
+
+`css`
+
+Optional page-specific CSS - empty by default. Use this block if a page needs an extra CSS file
+or two, but doesn't want to wipe out the files already linked via the `site_css`
+block.
+
+`extra_head`
+
+Any extra content for betwee the `<head>` tags.
+
+#### <body>
+
+`header`
+
+Top of the body, inside a `div` with the ID `header`.
+
+`content`
+
+After the `header`, inside a `div` with the ID `content`.
+
+`footer`
+
+After `content`, inside a `div` with the ID `footer`.
+
+`site_js`
+
+After all body content, includes site-wide Javascript files. By default,
+includes `media/js/application.js` and jQuery. In deployed environments, links
+to a copy of jQuery on Google's CDN. If running in solo development mode, links
+to a local copy of jQuery from the `media/` directory - becuase the best way to
+fight snakes on a plane is with jQuery on a plane.
+
+`js`
+
+Just like the `css` block, use the `js` block for page-specific Javascript files
+when you don't want to wipe out the site-wide defaults in `site_js`.
+
+### vendor
+
+Python package dependencies installed as git submodules. pip's support for git
+repositories is somewhat unreliable, and if the specific package is your own
+code it can be a bit easier to debug if it's all in one place (and not off in a
+virtualenv).
+
+At Bueda we collect general webapp helpers and views in the separate package
+`comrade` and share it among all of our applications. It is included here as an
+example of a Python package as a git submodule.
+
+Any directory in `vendor/` is added to the `PYTHONPATH` by `environment.py`.
+
+### Files
+
+#### environment.py
+
+Modifies the PYTHONPATH to allow importing from the `apps/`, `lib/` and
+`vendor/` directories. This module is imported at the top of `settings.py` to
+make sure it runs for both local development (using Django's built-in server)
+and in production (run through mod-wsgi, gunicorn, etc.).
+
+#### fabfile.py
+
+We use Fabric to deploy to remote servers in development, staging and production
+environments. The boilerplate Fabfile is quite thin, as most of the commands are
+imported from [buedafab](https://github.com/bueda/ops), a collection of our
+Fabric utilites.
+
+#### manage.py
+
+The standard Django `manage.py`.
+
+#### settings.py
+
+Many good default settings for Django applciations - check the file for more
+detailed documentation.
View
No changes.
View
No changes.
View
No changes.
View
No changes.
No changes.
View
No changes.
View
@@ -1,15 +1,10 @@
+"""Add the boilerplate's directories to Python's site-packages path.
+"""
import os
import site
import sys
ROOT = os.path.dirname(os.path.abspath(__file__))
-if os.path.splitext(os.path.basename(__file__))[0] == 'cProfile':
- if os.environ.get('DJANGO_APP_PATH'):
- ROOT = os.environ['DJANGO_APP_PATH']
- else:
- print 'When using cProfile you must set $DJANGO_APP_PATH'
- sys.exit(2)
-
path = lambda *a: os.path.join(ROOT, *a)
prev_sys_path = list(sys.path)
View
@@ -1,4 +1,8 @@
#!/usr/bin/env python
+"""Fabfile using only commands from buedafab (https://github.com/bueda/ops) to
+deploy this app to remote servers.
+"""
+
import os
from fabric.api import *
View
@@ -1,22 +1,20 @@
-# This is a copy of the Python logging.config.dictconfig module,
-# reproduced with permission. It is provided here for backwards
-# compatibility for Python versions prior to 2.7.
+# This is a copy of the Python logging.config.dictconfig module. It is provided
+# here for backwards compatibility for Python versions prior to 2.7.
#
# Copyright 2009-2010 by Vinay Sajip. All Rights Reserved.
#
# Permission to use, copy, modify, and distribute this software and its
-# documentation for any purpose and without fee is hereby granted,
-# provided that the above copyright notice appear in all copies and that
-# both that copyright notice and this permission notice appear in
-# supporting documentation, and that the name of Vinay Sajip
-# not be used in advertising or publicity pertaining to distribution
-# of the software without specific, written prior permission.
+# documentation for any purpose and without fee is hereby granted, provided that
+# the above copyright notice appear in all copies and that both that copyright
+# notice and this permission notice appear in supporting documentation, and that
+# the name of Vinay Sajip not be used in advertising or publicity pertaining to
+# distribution of the software without specific, written prior permission.
# VINAY SAJIP DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
-# ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
-# VINAY SAJIP BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
-# ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
-# IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
-# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+# ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL VINAY
+# SAJIP BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
+# DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
import logging.handlers
import re
View
@@ -1,4 +1,7 @@
-from tornado.options import _LogFormatter as TornadoLogFormatter
+"""
+An extended version of the log_settings module from zamboni:
+https://github.com/jbalogh/zamboni/blob/master/log_settings.py
+"""
import logging, logging.handlers
import os.path
import types
@@ -60,15 +63,11 @@ def initialize_logging(syslog_tag, syslog_facility, loggers,
'datefmt': '%H:%M:%s',
'format': '%s: [%%(REMOTE_ADDR)s] %s' % (syslog_tag, base_fmt),
},
- 'tornado': {
- '()': TornadoLogFormatter,
- 'color': True
- },
},
'handlers': {
'console': {
'()': logging.StreamHandler,
- 'formatter': 'tornado'
+ 'formatter': 'debug'
},
'null': {
'()': NullHandler,
View
@@ -1,11 +1,9 @@
#!/usr/bin/env python
-import sys
-
from django.core.management import execute_manager
try:
import settings # Assumed to be in the same directory.
except ImportError, e:
- print e
+ 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"
View
@@ -0,0 +1,64 @@
+html, body, span, applet, object, iframe,
+h1, h2, h3, h4, h5, h6, p, blockquote, pre,
+a, abbr, acronym, address, big, cite, code,
+del, dfn, em, font, ins, kbd, q, s, samp,
+small, strike, strong, sub, sup, tt, var,
+dl, dt, dd, ol, ul, li,
+fieldset, form, label, legend {
+ margin: 0;
+ padding: 0;
+ border: 0;
+ outline: 0;
+ font-weight: normal;
+ font-style: normal;
+ font-size: 100%;
+ vertical-align: baseline;
+}
+
+: focus {
+ outline: 0;
+}
+
+body {
+ line-height: 1.2;
+ color: black;
+ background: white;
+}
+
+h1,
+h2,
+h3,
+h4,
+h5,
+h6 {
+ font-size: 100%;
+ font-weight: normal;
+}
+
+ol, ul {
+ list-style: none;
+}
+
+/* tables still need 'cellspacing="0"' in the markup */
+table {
+ border-collapse: separate;
+ border-spacing: 0;
+}
+
+caption, th, td {
+ text-align: left;
+ font-weight: normal;
+}
+
+blockquote:before, blockquote:after,
+q:before, q:after {
+ content: "";
+}
+
+blockquote, q {
+ quotes: "" "";
+}
+
+img {
+ border: none;
+}
View
Binary file not shown.
Oops, something went wrong.

0 comments on commit acc2425

Please sign in to comment.