Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Initial commit

  • Loading branch information...
commit 83fc74ac1dfd5635fb59ca0e4ddfce733e9097e1 0 parents
David Cramer authored July 08, 2010

Showing 33 changed files with 936 additions and 0 deletions. Show diff stats Hide diff stats

  1. 2  .gitignore
  2. 3  MANIFEST.in
  3. 19  README.txt
  4. 0  __init__.py b/djangospot/lib/__init__.py
  5. 72  development.ini
  6. 0  djangospot/__init__.py
  7. 0  djangospot/config/__init__.py
  8. 60  djangospot/config/deployment.ini_tmpl
  9. 44  djangospot/config/environment.py
  10. 67  djangospot/config/middleware.py
  11. 28  djangospot/config/routing.py
  12. 0  djangospot/controllers/__init__.py
  13. 47  djangospot/controllers/directory.py
  14. 44  djangospot/controllers/error.py
  15. 21  djangospot/lib/app_globals.py
  16. 21  djangospot/lib/base.py
  17. 8  djangospot/lib/helpers.py
  18. 7  djangospot/model/__init__.py
  19. 11  djangospot/model/meta.py
  20. 2  djangospot/templates/bone.html
  21. 15  djangospot/templates/directory/add.html
  22. 9  djangospot/templates/directory/details.html
  23. 12  djangospot/templates/directory/index.html
  24. 34  djangospot/tests/__init__.py
  25. 0  djangospot/tests/functional/__init__.py
  26. 7  djangospot/tests/functional/test_directory.py
  27. 0  djangospot/tests/test_models.py
  28. 18  djangospot/websetup.py
  29. 19  docs/index.txt
  30. 276  ez_setup.py
  31. 31  setup.cfg
  32. 38  setup.py
  33. 21  test.ini
2  .gitignore
... ...
@@ -0,0 +1,2 @@
  1
+/djangospot.egg-info
  2
+*.pyc
3  MANIFEST.in
... ...
@@ -0,0 +1,3 @@
  1
+include djangospot/config/deployment.ini_tmpl
  2
+recursive-include djangospot/public *
  3
+recursive-include djangospot/templates *
19  README.txt
... ...
@@ -0,0 +1,19 @@
  1
+This file is for you to describe the djangospot application. Typically
  2
+you would include information such as the information below:
  3
+
  4
+Installation and Setup
  5
+======================
  6
+
  7
+Install ``djangospot`` using easy_install::
  8
+
  9
+    easy_install djangospot
  10
+
  11
+Make a config file as follows::
  12
+
  13
+    paster make-config djangospot config.ini
  14
+
  15
+Tweak the config file as appropriate and then setup the application::
  16
+
  17
+    paster setup-app config.ini
  18
+
  19
+Then you are ready to go.
0  __init__.py b/djangospot/lib/__init__.py
No changes.
72  development.ini
... ...
@@ -0,0 +1,72 @@
  1
+#
  2
+# djangospot - Pylons development environment configuration
  3
+#
  4
+# The %(here)s variable will be replaced with the parent directory of this file
  5
+#
  6
+[DEFAULT]
  7
+debug = true
  8
+# Uncomment and replace with the address which should receive any error reports
  9
+#email_to = you@yourdomain.com
  10
+smtp_server = localhost
  11
+error_email_from = paste@localhost
  12
+
  13
+[server:main]
  14
+use = egg:Paste#http
  15
+host = 127.0.0.1
  16
+port = 5000
  17
+
  18
+[app:main]
  19
+use = egg:djangospot
  20
+full_stack = true
  21
+static_files = true
  22
+
  23
+cache_dir = %(here)s/data
  24
+beaker.session.key = djangospot
  25
+beaker.session.secret = somesecret
  26
+
  27
+# If you'd like to fine-tune the individual locations of the cache data dirs
  28
+# for the Cache data, or the Session saves, un-comment the desired settings
  29
+# here:
  30
+#beaker.cache.data_dir = %(here)s/data/cache
  31
+#beaker.session.data_dir = %(here)s/data/sessions
  32
+
  33
+# WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT*
  34
+# Debug mode will enable the interactive debugging tool, allowing ANYONE to
  35
+# execute malicious code after an exception is raised.
  36
+#set debug = false
  37
+
  38
+
  39
+# Logging configuration
  40
+[loggers]
  41
+keys = root, routes, djangospot
  42
+
  43
+[handlers]
  44
+keys = console
  45
+
  46
+[formatters]
  47
+keys = generic
  48
+
  49
+[logger_root]
  50
+level = INFO
  51
+handlers = console
  52
+
  53
+[logger_routes]
  54
+level = INFO
  55
+handlers =
  56
+qualname = routes.middleware
  57
+# "level = DEBUG" logs the route matched and routing variables.
  58
+
  59
+[logger_djangospot]
  60
+level = DEBUG
  61
+handlers =
  62
+qualname = djangospot
  63
+
  64
+[handler_console]
  65
+class = StreamHandler
  66
+args = (sys.stderr,)
  67
+level = NOTSET
  68
+formatter = generic
  69
+
  70
+[formatter_generic]
  71
+format = %(asctime)s,%(msecs)03d %(levelname)-5.5s [%(name)s] [%(threadName)s] %(message)s
  72
+datefmt = %H:%M:%S
0  djangospot/__init__.py
No changes.
0  djangospot/config/__init__.py
No changes.
60  djangospot/config/deployment.ini_tmpl
... ...
@@ -0,0 +1,60 @@
  1
+#
  2
+# djangospot - Pylons configuration
  3
+#
  4
+# The %(here)s variable will be replaced with the parent directory of this file
  5
+#
  6
+[DEFAULT]
  7
+debug = true
  8
+email_to = you@yourdomain.com
  9
+smtp_server = localhost
  10
+error_email_from = paste@localhost
  11
+
  12
+[server:main]
  13
+use = egg:Paste#http
  14
+host = 0.0.0.0
  15
+port = 5000
  16
+
  17
+[app:main]
  18
+use = egg:djangospot
  19
+full_stack = true
  20
+static_files = true
  21
+
  22
+cache_dir = %(here)s/data
  23
+beaker.session.key = djangospot
  24
+beaker.session.secret = ${app_instance_secret}
  25
+app_instance_uuid = ${app_instance_uuid}
  26
+
  27
+# If you'd like to fine-tune the individual locations of the cache data dirs
  28
+# for the Cache data, or the Session saves, un-comment the desired settings
  29
+# here:
  30
+#beaker.cache.data_dir = %(here)s/data/cache
  31
+#beaker.session.data_dir = %(here)s/data/sessions
  32
+
  33
+# WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT*
  34
+# Debug mode will enable the interactive debugging tool, allowing ANYONE to
  35
+# execute malicious code after an exception is raised.
  36
+set debug = false
  37
+
  38
+
  39
+# Logging configuration
  40
+[loggers]
  41
+keys = root
  42
+
  43
+[handlers]
  44
+keys = console
  45
+
  46
+[formatters]
  47
+keys = generic
  48
+
  49
+[logger_root]
  50
+level = INFO
  51
+handlers = console
  52
+
  53
+[handler_console]
  54
+class = StreamHandler
  55
+args = (sys.stderr,)
  56
+level = NOTSET
  57
+formatter = generic
  58
+
  59
+[formatter_generic]
  60
+format = %(asctime)s %(levelname)-5.5s [%(name)s] [%(threadName)s] %(message)s
44  djangospot/config/environment.py
... ...
@@ -0,0 +1,44 @@
  1
+"""Pylons environment configuration"""
  2
+import os
  3
+
  4
+from jinja2 import Environment, FileSystemLoader
  5
+from pylons.configuration import PylonsConfig
  6
+
  7
+import djangospot.lib.app_globals as app_globals
  8
+import djangospot.lib.helpers
  9
+from djangospot.config.routing import make_map
  10
+#from djangospot.model import init_model
  11
+
  12
+def load_environment(global_conf, app_conf):
  13
+    """Configure the Pylons environment via the ``pylons.config``
  14
+    object
  15
+    """
  16
+    config = PylonsConfig()
  17
+    
  18
+    # Pylons paths
  19
+    root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
  20
+    paths = dict(root=root,
  21
+                 controllers=os.path.join(root, 'controllers'),
  22
+                 static_files=os.path.join(root, 'public'),
  23
+                 templates=[os.path.join(root, 'templates')])
  24
+
  25
+    # Initialize config with the basic options
  26
+    config.init_app(global_conf, app_conf, package='djangospot', paths=paths)
  27
+
  28
+    config['routes.map'] = make_map(config)
  29
+    config['pylons.app_globals'] = app_globals.Globals(config)
  30
+    config['pylons.h'] = djangospot.lib.helpers
  31
+    
  32
+    # Setup cache object as early as possible
  33
+    import pylons
  34
+    pylons.cache._push_object(config['pylons.app_globals'].cache)
  35
+    
  36
+
  37
+    # Create the Jinja2 Environment
  38
+    jinja2_env = Environment(loader=FileSystemLoader(paths['templates']))
  39
+    config['pylons.app_globals'].jinja2_env = jinja2_env
  40
+
  41
+    # CONFIGURATION OPTIONS HERE (note: all config options will override
  42
+    # any Pylons config options)
  43
+    
  44
+    return config
67  djangospot/config/middleware.py
... ...
@@ -0,0 +1,67 @@
  1
+"""Pylons middleware initialization"""
  2
+from beaker.middleware import SessionMiddleware
  3
+from paste.cascade import Cascade
  4
+from paste.registry import RegistryManager
  5
+from paste.urlparser import StaticURLParser
  6
+from paste.deploy.converters import asbool
  7
+from pylons.middleware import ErrorHandler, StatusCodeRedirect
  8
+from pylons.wsgiapp import PylonsApp
  9
+from routes.middleware import RoutesMiddleware
  10
+
  11
+from djangospot.config.environment import load_environment
  12
+
  13
+def make_app(global_conf, full_stack=True, static_files=True, **app_conf):
  14
+    """Create a Pylons WSGI application and return it
  15
+
  16
+    ``global_conf``
  17
+        The inherited configuration for this application. Normally from
  18
+        the [DEFAULT] section of the Paste ini file.
  19
+
  20
+    ``full_stack``
  21
+        Whether this application provides a full WSGI stack (by default,
  22
+        meaning it handles its own exceptions and errors). Disable
  23
+        full_stack when this application is "managed" by another WSGI
  24
+        middleware.
  25
+
  26
+    ``static_files``
  27
+        Whether this application serves its own static files; disable
  28
+        when another web server is responsible for serving them.
  29
+
  30
+    ``app_conf``
  31
+        The application's local configuration. Normally specified in
  32
+        the [app:<name>] section of the Paste ini file (where <name>
  33
+        defaults to main).
  34
+
  35
+    """
  36
+    # Configure the Pylons environment
  37
+    config = load_environment(global_conf, app_conf)
  38
+
  39
+    # The Pylons WSGI app
  40
+    app = PylonsApp(config=config)
  41
+
  42
+    # Routing/Session/Cache Middleware
  43
+    app = RoutesMiddleware(app, config['routes.map'], singleton=False)
  44
+    app = SessionMiddleware(app, config)
  45
+
  46
+    # CUSTOM MIDDLEWARE HERE (filtered by error handling middlewares)
  47
+
  48
+    if asbool(full_stack):
  49
+        # Handle Python exceptions
  50
+        app = ErrorHandler(app, global_conf, **config['pylons.errorware'])
  51
+
  52
+        # Display error documents for 401, 403, 404 status codes (and
  53
+        # 500 when debug is disabled)
  54
+        if asbool(config['debug']):
  55
+            app = StatusCodeRedirect(app)
  56
+        else:
  57
+            app = StatusCodeRedirect(app, [400, 401, 403, 404, 500])
  58
+
  59
+    # Establish the Registry for this application
  60
+    app = RegistryManager(app)
  61
+
  62
+    if asbool(static_files):
  63
+        # Serve static files
  64
+        static_app = StaticURLParser(config['pylons.paths']['static_files'])
  65
+        app = Cascade([static_app, app])
  66
+    app.config = config
  67
+    return app
28  djangospot/config/routing.py
... ...
@@ -0,0 +1,28 @@
  1
+"""Routes configuration
  2
+
  3
+The more specific and detailed routes should be defined first so they
  4
+may take precedent over the more generic routes. For more information
  5
+refer to the routes manual at http://routes.groovie.org/docs/
  6
+"""
  7
+from routes import Mapper
  8
+
  9
+def make_map(config):
  10
+    """Create, configure and return the routes Mapper"""
  11
+    map = Mapper(directory=config['pylons.paths']['controllers'],
  12
+                 always_scan=config['debug'])
  13
+    map.minimization = False
  14
+    map.explicit = False
  15
+
  16
+    # The ErrorController route (handles 404/500 error pages); it should
  17
+    # likely stay at the top, ensuring it can always be resolved
  18
+    map.connect('/error/{action}', controller='error')
  19
+    map.connect('/error/{action}/{id}', controller='error')
  20
+
  21
+    # CUSTOM ROUTES HERE
  22
+
  23
+    map.connect('/{controller}/{action}')
  24
+    map.connect('/{controller}/{action}/{id}')
  25
+
  26
+    map.connect('/', controller='directory', action='index')
  27
+
  28
+    return map
0  djangospot/controllers/__init__.py
No changes.
47  djangospot/controllers/directory.py
... ...
@@ -0,0 +1,47 @@
  1
+import logging
  2
+
  3
+from pylons import request, response, session, tmpl_context as c, url, app_globals as g
  4
+from pylons.decorators import validate
  5
+from pylons.controllers.util import abort, redirect
  6
+
  7
+from djangospot.lib.base import BaseController, render
  8
+
  9
+log = logging.getLogger(__name__)
  10
+
  11
+class DirectoryController(BaseController):
  12
+
  13
+    def index(self):
  14
+        c.projects = [(k, g.redis.hgetall('project.%s' % k)) for k in g.redis.sort('projects',  0, 10)]
  15
+        return render('directory/index.html')
  16
+
  17
+    def details(self):
  18
+        c.project_id = request.params['project_id']
  19
+        c.project = g.redis.hgetall('project.%s' % c.project_id)
  20
+        if not c.project:
  21
+            abort(404, '404 Not Found')
  22
+        return render('directory/details.html')
  23
+
  24
+    def add(self):
  25
+        c.form_result = {}
  26
+        c.form_errors = {}
  27
+        if request.params:
  28
+            schema = ProjectForm()
  29
+            try:
  30
+                c.form_result = schema.to_python(request.params)
  31
+            except formencode.validators.Invalid, error:
  32
+                c.form_result = error.value
  33
+                c.form_errors = error.error_dict or {}
  34
+            else:
  35
+                idx = g.redis.incr('next.project.id')
  36
+                g.redis.rpush('projects', idx)
  37
+                g.redis.hset('project.%s' % idx, 'name', c.form_result['name'])
  38
+                g.redis.hset('project.%s' % idx, 'url', c.form_result['url'])
  39
+        return render('directory/add.html')
  40
+
  41
+import formencode
  42
+
  43
+class ProjectForm(formencode.Schema):
  44
+    allow_extra_fields = True
  45
+    filter_extra_fields = True
  46
+    name = formencode.validators.String(not_empty=True)
  47
+    url = formencode.validators.URL(not_empty=True)
44  djangospot/controllers/error.py
... ...
@@ -0,0 +1,44 @@
  1
+import cgi
  2
+
  3
+from paste.urlparser import PkgResourcesParser
  4
+from pylons.middleware import error_document_template
  5
+from webhelpers.html.builder import literal
  6
+
  7
+from djangospot.lib.base import BaseController
  8
+
  9
+class ErrorController(BaseController):
  10
+    """Generates error documents as and when they are required.
  11
+
  12
+    The ErrorDocuments middleware forwards to ErrorController when error
  13
+    related status codes are returned from the application.
  14
+
  15
+    This behaviour can be altered by changing the parameters to the
  16
+    ErrorDocuments middleware in your config/middleware.py file.
  17
+
  18
+    """
  19
+    def document(self):
  20
+        """Render the error document"""
  21
+        request = self._py_object.request
  22
+        resp = request.environ.get('pylons.original_response')
  23
+        content = literal(resp.body) or cgi.escape(request.GET.get('message', ''))
  24
+        page = error_document_template % \
  25
+            dict(prefix=request.environ.get('SCRIPT_NAME', ''),
  26
+                 code=cgi.escape(request.GET.get('code', str(resp.status_int))),
  27
+                 message=content)
  28
+        return page
  29
+
  30
+    def img(self, id):
  31
+        """Serve Pylons' stock images"""
  32
+        return self._serve_file('/'.join(['media/img', id]))
  33
+
  34
+    def style(self, id):
  35
+        """Serve Pylons' stock stylesheets"""
  36
+        return self._serve_file('/'.join(['media/style', id]))
  37
+
  38
+    def _serve_file(self, path):
  39
+        """Call Paste's FileApp (a WSGI application) to serve the file
  40
+        at the specified path
  41
+        """
  42
+        request = self._py_object.request
  43
+        request.environ['PATH_INFO'] = '/%s' % path
  44
+        return PkgResourcesParser('pylons', 'pylons')(request.environ, self.start_response)
21  djangospot/lib/app_globals.py
... ...
@@ -0,0 +1,21 @@
  1
+"""The application's Globals object"""
  2
+
  3
+import redis
  4
+
  5
+from beaker.cache import CacheManager
  6
+from beaker.util import parse_cache_config_options
  7
+
  8
+class Globals(object):
  9
+    """Globals acts as a container for objects available throughout the
  10
+    life of the application
  11
+
  12
+    """
  13
+
  14
+    def __init__(self, config):
  15
+        """One instance of Globals is created during application
  16
+        initialization and is available during requests via the
  17
+        'app_globals' variable
  18
+
  19
+        """
  20
+        self.cache = CacheManager(**parse_cache_config_options(config))
  21
+        self.redis = redis.Redis(host='localhost', port=6379, db=0)
21  djangospot/lib/base.py
... ...
@@ -0,0 +1,21 @@
  1
+"""The base Controller API
  2
+
  3
+Provides the BaseController class for subclassing.
  4
+"""
  5
+from pylons.controllers import WSGIController
  6
+from pylons.templating import render_jinja2 as render
  7
+
  8
+#from djangospot.model.meta import Session
  9
+
  10
+class BaseController(WSGIController):
  11
+
  12
+    def __call__(self, environ, start_response):
  13
+        """Invoke the Controller"""
  14
+        # WSGIController.__call__ dispatches to the Controller method
  15
+        # the request is routed to. This routing information is
  16
+        # available in environ['pylons.routes_dict']
  17
+        try:
  18
+            return WSGIController.__call__(self, environ, start_response)
  19
+        finally:
  20
+            pass
  21
+            #Session.remove()
8  djangospot/lib/helpers.py
... ...
@@ -0,0 +1,8 @@
  1
+"""Helper functions
  2
+
  3
+Consists of functions to typically be used within templates, but also
  4
+available to Controllers. This module is available to templates as 'h'.
  5
+"""
  6
+# Import helpers as desired, or define your own, ie:
  7
+from webhelpers.html import escape, HTML, literal, url_escape
  8
+from webhelpers.html.tags import *
7  djangospot/model/__init__.py
... ...
@@ -0,0 +1,7 @@
  1
+# """The application's model objects"""
  2
+# from djangospot.model.meta import Session, Base
  3
+# 
  4
+# 
  5
+# def init_model(engine):
  6
+#     """Call me before using any of the tables or classes in the model"""
  7
+#     Session.configure(bind=engine)
11  djangospot/model/meta.py
... ...
@@ -0,0 +1,11 @@
  1
+# """SQLAlchemy Metadata and Session object"""
  2
+# from sqlalchemy.ext.declarative import declarative_base
  3
+# from sqlalchemy.orm import scoped_session, sessionmaker
  4
+# 
  5
+# __all__ = ['Base', 'Session']
  6
+# 
  7
+# # SQLAlchemy session manager. Updated by model.init_model()
  8
+# Session = scoped_session(sessionmaker())
  9
+# 
  10
+# # The declarative Base
  11
+# Base = declarative_base()
2  djangospot/templates/bone.html
... ...
@@ -0,0 +1,2 @@
  1
+{% block content %}
  2
+{% endblock %}
15  djangospot/templates/directory/add.html
... ...
@@ -0,0 +1,15 @@
  1
+{% extends "bone.html" %}
  2
+
  3
+{% block content %}
  4
+	{{ h.form('', method='post') }}
  5
+
  6
+	<p>Project Name: {{ h.text('name', value=c.form_result.get('name', '')) }}</p>
  7
+	<p>{{ c.form_errors.get('email', '') }}</p>
  8
+
  9
+	<p>Project URL: {{ h.text('url', value=c.form_result.get('url', '')) }}</p>
  10
+	<p>{{ c.form_errors.get('url', '') }}</p>
  11
+
  12
+	{{ h.submit('submit', 'Submit') }}
  13
+
  14
+	{{ h.end_form() }}
  15
+{% endblock %}
9  djangospot/templates/directory/details.html
... ...
@@ -0,0 +1,9 @@
  1
+{% extends "bone.html" %}
  2
+
  3
+{% block content %}
  4
+	<h1>{{ c.project.name }}</h1>
  5
+	<dl>
  6
+		<dt>URL:</dt>
  7
+		<dd>{{ c.project.url }}</dd>
  8
+	</dl>
  9
+{% endblock %}
12  djangospot/templates/directory/index.html
... ...
@@ -0,0 +1,12 @@
  1
+{% extends "bone.html" %}
  2
+
  3
+{% block content %}
  4
+<ul>
  5
+	{% for project_id, project in c.projects %}
  6
+		<li>
  7
+			<a href="{{ url(controller='directory', action='details', project_id=project_id) }}">{{ project.name }}</a><br/>
  8
+			<small>{{ project.url }}</small>
  9
+		</li>
  10
+	{% endfor %}
  11
+</ul>
  12
+{% endblock %}
34  djangospot/tests/__init__.py
... ...
@@ -0,0 +1,34 @@
  1
+"""Pylons application test package
  2
+
  3
+This package assumes the Pylons environment is already loaded, such as
  4
+when this script is imported from the `nosetests --with-pylons=test.ini`
  5
+command.
  6
+
  7
+This module initializes the application via ``websetup`` (`paster
  8
+setup-app`) and provides the base testing objects.
  9
+"""
  10
+from unittest import TestCase
  11
+
  12
+from paste.deploy import loadapp
  13
+from paste.script.appinstall import SetupCommand
  14
+from pylons import url
  15
+from routes.util import URLGenerator
  16
+from webtest import TestApp
  17
+
  18
+import pylons.test
  19
+
  20
+__all__ = ['environ', 'url', 'TestController']
  21
+
  22
+# Invoke websetup with the current config file
  23
+SetupCommand('setup-app').run([pylons.test.pylonsapp.config['__file__']])
  24
+
  25
+environ = {}
  26
+
  27
+class TestController(TestCase):
  28
+
  29
+    def __init__(self, *args, **kwargs):
  30
+        wsgiapp = pylons.test.pylonsapp
  31
+        config = wsgiapp.config
  32
+        self.app = TestApp(wsgiapp)
  33
+        url._push_object(URLGenerator(config['routes.map'], environ))
  34
+        TestCase.__init__(self, *args, **kwargs)
0  djangospot/tests/functional/__init__.py
No changes.
7  djangospot/tests/functional/test_directory.py
... ...
@@ -0,0 +1,7 @@
  1
+from djangospot.tests import *
  2
+
  3
+class TestDirectoryController(TestController):
  4
+
  5
+    def test_index(self):
  6
+        response = self.app.get(url(controller='directory', action='index'))
  7
+        # Test response...
0  djangospot/tests/test_models.py
No changes.
18  djangospot/websetup.py
... ...
@@ -0,0 +1,18 @@
  1
+"""Setup the djangospot application"""
  2
+import logging
  3
+
  4
+import pylons.test
  5
+
  6
+from djangospot.config.environment import load_environment
  7
+#from djangospot.model.meta import Session, Base
  8
+
  9
+log = logging.getLogger(__name__)
  10
+
  11
+def setup_app(command, conf, vars):
  12
+    """Place any commands to setup djangospot here"""
  13
+    # Don't reload the app if it was loaded under the testing environment
  14
+    if not pylons.test.pylonsapp:
  15
+        load_environment(conf.global_conf, conf.local_conf)
  16
+
  17
+    # Create the tables if they don't already exist
  18
+    #Base.metadata.create_all(bind=Session.bind)
19  docs/index.txt
... ...
@@ -0,0 +1,19 @@
  1
+djangospot
  2
+++++++++++
  3
+
  4
+This is the main index page of your documentation. It should be written in
  5
+`reStructuredText format <http://docutils.sourceforge.net/rst.html>`_.
  6
+
  7
+You can generate your documentation in HTML format by running this command::
  8
+
  9
+    setup.py pudge
  10
+
  11
+For this to work you will need to download and install `buildutils`_,
  12
+`pudge`_, and `pygments`_.  The ``pudge`` command is disabled by
  13
+default; to ativate it in your project, run::
  14
+
  15
+    setup.py addcommand -p buildutils.pudge_command
  16
+
  17
+.. _buildutils: http://pypi.python.org/pypi/buildutils
  18
+.. _pudge: http://pudge.lesscode.org/
  19
+.. _pygments: http://pygments.org/
276  ez_setup.py
... ...
@@ -0,0 +1,276 @@
  1
+#!python
  2
+"""Bootstrap setuptools installation
  3
+
  4
+If you want to use setuptools in your package's setup.py, just include this
  5
+file in the same directory with it, and add this to the top of your setup.py::
  6
+
  7
+    from ez_setup import use_setuptools
  8
+    use_setuptools()
  9
+
  10
+If you want to require a specific version of setuptools, set a download
  11
+mirror, or use an alternate download directory, you can do so by supplying
  12
+the appropriate options to ``use_setuptools()``.
  13
+
  14
+This file can also be run as a script to install or upgrade setuptools.
  15
+"""
  16
+import sys
  17
+DEFAULT_VERSION = "0.6c9"
  18
+DEFAULT_URL     = "http://pypi.python.org/packages/%s/s/setuptools/" % sys.version[:3]
  19
+
  20
+md5_data = {
  21
+    'setuptools-0.6b1-py2.3.egg': '8822caf901250d848b996b7f25c6e6ca',
  22
+    'setuptools-0.6b1-py2.4.egg': 'b79a8a403e4502fbb85ee3f1941735cb',
  23
+    'setuptools-0.6b2-py2.3.egg': '5657759d8a6d8fc44070a9d07272d99b',
  24
+    'setuptools-0.6b2-py2.4.egg': '4996a8d169d2be661fa32a6e52e4f82a',
  25
+    'setuptools-0.6b3-py2.3.egg': 'bb31c0fc7399a63579975cad9f5a0618',
  26
+    'setuptools-0.6b3-py2.4.egg': '38a8c6b3d6ecd22247f179f7da669fac',
  27
+    'setuptools-0.6b4-py2.3.egg': '62045a24ed4e1ebc77fe039aa4e6f7e5',
  28
+    'setuptools-0.6b4-py2.4.egg': '4cb2a185d228dacffb2d17f103b3b1c4',
  29
+    'setuptools-0.6c1-py2.3.egg': 'b3f2b5539d65cb7f74ad79127f1a908c',
  30
+    'setuptools-0.6c1-py2.4.egg': 'b45adeda0667d2d2ffe14009364f2a4b',
  31
+    'setuptools-0.6c2-py2.3.egg': 'f0064bf6aa2b7d0f3ba0b43f20817c27',
  32
+    'setuptools-0.6c2-py2.4.egg': '616192eec35f47e8ea16cd6a122b7277',
  33
+    'setuptools-0.6c3-py2.3.egg': 'f181fa125dfe85a259c9cd6f1d7b78fa',
  34
+    'setuptools-0.6c3-py2.4.egg': 'e0ed74682c998bfb73bf803a50e7b71e',
  35
+    'setuptools-0.6c3-py2.5.egg': 'abef16fdd61955514841c7c6bd98965e',
  36
+    'setuptools-0.6c4-py2.3.egg': 'b0b9131acab32022bfac7f44c5d7971f',
  37
+    'setuptools-0.6c4-py2.4.egg': '2a1f9656d4fbf3c97bf946c0a124e6e2',
  38
+    'setuptools-0.6c4-py2.5.egg': '8f5a052e32cdb9c72bcf4b5526f28afc',
  39
+    'setuptools-0.6c5-py2.3.egg': 'ee9fd80965da04f2f3e6b3576e9d8167',
  40
+    'setuptools-0.6c5-py2.4.egg': 'afe2adf1c01701ee841761f5bcd8aa64',
  41
+    'setuptools-0.6c5-py2.5.egg': 'a8d3f61494ccaa8714dfed37bccd3d5d',
  42
+    'setuptools-0.6c6-py2.3.egg': '35686b78116a668847237b69d549ec20',
  43
+    'setuptools-0.6c6-py2.4.egg': '3c56af57be3225019260a644430065ab',
  44
+    'setuptools-0.6c6-py2.5.egg': 'b2f8a7520709a5b34f80946de5f02f53',
  45
+    'setuptools-0.6c7-py2.3.egg': '209fdf9adc3a615e5115b725658e13e2',
  46
+    'setuptools-0.6c7-py2.4.egg': '5a8f954807d46a0fb67cf1f26c55a82e',
  47
+    'setuptools-0.6c7-py2.5.egg': '45d2ad28f9750e7434111fde831e8372',
  48
+    'setuptools-0.6c8-py2.3.egg': '50759d29b349db8cfd807ba8303f1902',
  49
+    'setuptools-0.6c8-py2.4.egg': 'cba38d74f7d483c06e9daa6070cce6de',
  50
+    'setuptools-0.6c8-py2.5.egg': '1721747ee329dc150590a58b3e1ac95b',
  51
+    'setuptools-0.6c9-py2.3.egg': 'a83c4020414807b496e4cfbe08507c03',
  52
+    'setuptools-0.6c9-py2.4.egg': '260a2be2e5388d66bdaee06abec6342a',
  53
+    'setuptools-0.6c9-py2.5.egg': 'fe67c3e5a17b12c0e7c541b7ea43a8e6',
  54
+    'setuptools-0.6c9-py2.6.egg': 'ca37b1ff16fa2ede6e19383e7b59245a',
  55
+}
  56
+
  57
+import sys, os
  58
+try: from hashlib import md5
  59
+except ImportError: from md5 import md5
  60
+
  61
+def _validate_md5(egg_name, data):
  62
+    if egg_name in md5_data:
  63
+        digest = md5(data).hexdigest()
  64
+        if digest != md5_data[egg_name]:
  65
+            print >>sys.stderr, (
  66
+                "md5 validation of %s failed!  (Possible download problem?)"
  67
+                % egg_name
  68
+            )
  69
+            sys.exit(2)
  70
+    return data
  71
+
  72
+def use_setuptools(
  73
+    version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir,
  74
+    download_delay=15
  75
+):
  76
+    """Automatically find/download setuptools and make it available on sys.path
  77
+
  78
+    `version` should be a valid setuptools version number that is available
  79
+    as an egg for download under the `download_base` URL (which should end with
  80
+    a '/').  `to_dir` is the directory where setuptools will be downloaded, if
  81
+    it is not already available.  If `download_delay` is specified, it should
  82
+    be the number of seconds that will be paused before initiating a download,
  83
+    should one be required.  If an older version of setuptools is installed,
  84
+    this routine will print a message to ``sys.stderr`` and raise SystemExit in
  85
+    an attempt to abort the calling script.
  86
+    """
  87
+    was_imported = 'pkg_resources' in sys.modules or 'setuptools' in sys.modules
  88
+    def do_download():
  89
+        egg = download_setuptools(version, download_base, to_dir, download_delay)
  90
+        sys.path.insert(0, egg)
  91
+        import setuptools; setuptools.bootstrap_install_from = egg
  92
+    try:
  93
+        import pkg_resources
  94
+    except ImportError:
  95
+        return do_download()       
  96
+    try:
  97
+        pkg_resources.require("setuptools>="+version); return
  98
+    except pkg_resources.VersionConflict, e:
  99
+        if was_imported:
  100
+            print >>sys.stderr, (
  101
+            "The required version of setuptools (>=%s) is not available, and\n"
  102
+            "can't be installed while this script is running. Please install\n"
  103
+            " a more recent version first, using 'easy_install -U setuptools'."
  104
+            "\n\n(Currently using %r)"
  105
+            ) % (version, e.args[0])
  106
+            sys.exit(2)
  107
+        else:
  108
+            del pkg_resources, sys.modules['pkg_resources']    # reload ok
  109
+            return do_download()
  110
+    except pkg_resources.DistributionNotFound:
  111
+        return do_download()
  112
+
  113
+def download_setuptools(
  114
+    version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir,
  115
+    delay = 15
  116
+):
  117
+    """Download setuptools from a specified location and return its filename
  118
+
  119
+    `version` should be a valid setuptools version number that is available
  120
+    as an egg for download under the `download_base` URL (which should end
  121
+    with a '/'). `to_dir` is the directory where the egg will be downloaded.
  122
+    `delay` is the number of seconds to pause before an actual download attempt.
  123
+    """
  124
+    import urllib2, shutil
  125
+    egg_name = "setuptools-%s-py%s.egg" % (version,sys.version[:3])
  126
+    url = download_base + egg_name
  127
+    saveto = os.path.join(to_dir, egg_name)
  128
+    src = dst = None
  129
+    if not os.path.exists(saveto):  # Avoid repeated downloads
  130
+        try:
  131
+            from distutils import log
  132
+            if delay:
  133
+                log.warn("""
  134
+---------------------------------------------------------------------------
  135
+This script requires setuptools version %s to run (even to display
  136
+help).  I will attempt to download it for you (from
  137
+%s), but
  138
+you may need to enable firewall access for this script first.
  139
+I will start the download in %d seconds.
  140
+
  141
+(Note: if this machine does not have network access, please obtain the file
  142
+
  143
+   %s
  144
+
  145
+and place it in this directory before rerunning this script.)
  146
+---------------------------------------------------------------------------""",
  147
+                    version, download_base, delay, url
  148
+                ); from time import sleep; sleep(delay)
  149
+            log.warn("Downloading %s", url)
  150
+            src = urllib2.urlopen(url)
  151
+            # Read/write all in one block, so we don't create a corrupt file
  152
+            # if the download is interrupted.
  153
+            data = _validate_md5(egg_name, src.read())
  154
+            dst = open(saveto,"wb"); dst.write(data)
  155
+        finally:
  156
+            if src: src.close()
  157
+            if dst: dst.close()
  158
+    return os.path.realpath(saveto)
  159
+
  160
+
  161
+
  162
+
  163
+
  164
+
  165
+
  166
+
  167
+
  168
+
  169
+
  170
+
  171
+
  172
+
  173
+
  174
+
  175
+
  176
+
  177
+
  178
+
  179
+
  180
+
  181
+
  182
+
  183
+
  184
+
  185
+
  186
+
  187
+
  188
+
  189
+
  190
+
  191
+
  192
+
  193
+
  194
+
  195
+def main(argv, version=DEFAULT_VERSION):
  196
+    """Install or upgrade setuptools and EasyInstall"""
  197
+    try:
  198
+        import setuptools
  199
+    except ImportError:
  200
+        egg = None
  201
+        try:
  202
+            egg = download_setuptools(version, delay=0)
  203
+            sys.path.insert(0,egg)
  204
+            from setuptools.command.easy_install import main
  205
+            return main(list(argv)+[egg])   # we're done here
  206
+        finally:
  207
+            if egg and os.path.exists(egg):
  208
+                os.unlink(egg)
  209
+    else:
  210
+        if setuptools.__version__ == '0.0.1':
  211
+            print >>sys.stderr, (
  212
+            "You have an obsolete version of setuptools installed.  Please\n"
  213
+            "remove it from your system entirely before rerunning this script."
  214
+            )
  215
+            sys.exit(2)
  216
+
  217
+    req = "setuptools>="+version
  218
+    import pkg_resources
  219
+    try:
  220
+        pkg_resources.require(req)
  221
+    except pkg_resources.VersionConflict:
  222
+        try:
  223
+            from setuptools.command.easy_install import main
  224
+        except ImportError:
  225
+            from easy_install import main
  226
+        main(list(argv)+[download_setuptools(delay=0)])
  227
+        sys.exit(0) # try to force an exit
  228
+    else:
  229
+        if argv:
  230
+            from setuptools.command.easy_install import main
  231
+            main(argv)
  232
+        else:
  233
+            print "Setuptools version",version,"or greater has been installed."
  234
+            print '(Run "ez_setup.py -U setuptools" to reinstall or upgrade.)'
  235
+
  236
+def update_md5(filenames):
  237
+    """Update our built-in md5 registry"""
  238
+
  239
+    import re
  240
+
  241
+    for name in filenames:
  242
+        base = os.path.basename(name)
  243
+        f = open(name,'rb')
  244
+        md5_data[base] = md5(f.read()).hexdigest()
  245
+        f.close()
  246
+
  247
+    data = ["    %r: %r,\n" % it for it in md5_data.items()]
  248
+    data.sort()
  249
+    repl = "".join(data)
  250
+
  251
+    import inspect
  252
+    srcfile = inspect.getsourcefile(sys.modules[__name__])
  253
+    f = open(srcfile, 'rb'); src = f.read(); f.close()
  254
+
  255
+    match = re.search("\nmd5_data = {\n([^}]+)}", src)
  256
+    if not match:
  257
+        print >>sys.stderr, "Internal error!"
  258
+        sys.exit(2)
  259
+
  260
+    src = src[:match.start(1)] + repl + src[match.end(1):]
  261
+    f = open(srcfile,'w')
  262
+    f.write(src)
  263
+    f.close()
  264
+
  265
+
  266
+if __name__=='__main__':
  267
+    if len(sys.argv)>2 and sys.argv[1]=='--md5update':
  268
+        update_md5(sys.argv[2:])
  269
+    else:
  270
+        main(sys.argv[1:])
  271
+
  272
+
  273
+
  274
+
  275
+
  276
+
31  setup.cfg
... ...
@@ -0,0 +1,31 @@
  1
+[egg_info]
  2
+tag_build = dev
  3
+tag_svn_revision = true
  4
+
  5
+[easy_install]
  6
+find_links = http://www.pylonshq.com/download/
  7
+
  8
+[nosetests]
  9
+with-pylons = test.ini
  10
+
  11
+# Babel configuration
  12
+[compile_catalog]
  13
+domain = djangospot
  14
+directory = djangospot/i18n
  15
+statistics = true
  16
+
  17
+[extract_messages]
  18
+add_comments = TRANSLATORS:
  19
+output_file = djangospot/i18n/djangospot.pot
  20
+width = 80
  21
+
  22
+[init_catalog]
  23
+domain = djangospot
  24
+input_file = djangospot/i18n/djangospot.pot
  25
+output_dir = djangospot/i18n
  26
+
  27
+[update_catalog]
  28
+domain = djangospot
  29
+input_file = djangospot/i18n/djangospot.pot
  30
+output_dir = djangospot/i18n
  31
+previous = true
38  setup.py
... ...
@@ -0,0 +1,38 @@
  1
+try:
  2
+    from setuptools import setup, find_packages
  3
+except ImportError:
  4
+    from ez_setup import use_setuptools
  5
+    use_setuptools()
  6
+    from setuptools import setup, find_packages
  7
+
  8
+setup(
  9
+    name='djangospot',
  10
+    version='0.1',
  11
+    description='',
  12
+    author='',
  13
+    author_email='',
  14
+    url='',
  15
+    install_requires=[
  16
+        "Pylons>=1.0",
  17
+        "SQLAlchemy>=0.5",
  18
+        "Jinja2",
  19
+        "redis",
  20
+    ],
  21
+    setup_requires=["PasteScript>=1.6.3"],
  22
+    packages=find_packages(exclude=['ez_setup']),
  23
+    include_package_data=True,
  24
+    test_suite='nose.collector',
  25
+    package_data={'djangospot': ['i18n/*/LC_MESSAGES/*.mo']},
  26
+    #message_extractors={'djangospot': [
  27
+    #        ('**.py', 'python', None),
  28
+    #        ('public/**', 'ignore', None)]},
  29
+    zip_safe=False,
  30
+    paster_plugins=['PasteScript', 'Pylons'],
  31
+    entry_points="""
  32
+    [paste.app_factory]
  33
+    main = djangospot.config.middleware:make_app
  34
+
  35
+    [paste.app_install]
  36
+    main = pylons.util:PylonsInstaller
  37
+    """,
  38
+)
21  test.ini
... ...
@@ -0,0 +1,21 @@
  1
+#
  2
+# djangospot - Pylons testing environment configuration
  3
+#
  4
+# The %(here)s variable will be replaced with the parent directory of this file
  5
+#
  6
+[DEFAULT]
  7
+debug = true
  8
+# Uncomment and replace with the address which should receive any error reports
  9
+#email_to = you@yourdomain.com
  10
+smtp_server = localhost
  11
+error_email_from = paste@localhost
  12
+
  13
+[server:main]
  14
+use = egg:Paste#http
  15
+host = 127.0.0.1
  16
+port = 5000
  17
+
  18
+[app:main]
  19
+use = config:development.ini
  20
+
  21
+# Add additional test specific configuration options as necessary.

0 notes on commit 83fc74a

Please sign in to comment.
Something went wrong with that request. Please try again.