]> gitweb.michael.orlitzky.com - dead/census-tools.git/commitdiff
Added the "maps" Pylons project.
authorMichael Orlitzky <michael@orlitzky.com>
Mon, 15 Feb 2010 21:01:44 +0000 (16:01 -0500)
committerMichael Orlitzky <michael@orlitzky.com>
Mon, 15 Feb 2010 21:01:44 +0000 (16:01 -0500)
47 files changed:
www/maps/MANIFEST.in [new file with mode: 0644]
www/maps/data/templates/.gitignore [new file with mode: 0644]
www/maps/development.ini [new file with mode: 0644]
www/maps/docs/index.txt [new file with mode: 0644]
www/maps/ez_setup.py [new file with mode: 0644]
www/maps/maps.egg-info/PKG-INFO [new file with mode: 0644]
www/maps/maps.egg-info/SOURCES.txt [new file with mode: 0644]
www/maps/maps.egg-info/dependency_links.txt [new file with mode: 0644]
www/maps/maps.egg-info/entry_points.txt [new file with mode: 0644]
www/maps/maps.egg-info/not-zip-safe [new file with mode: 0644]
www/maps/maps.egg-info/paster_plugins.txt [new file with mode: 0644]
www/maps/maps.egg-info/requires.txt [new file with mode: 0644]
www/maps/maps.egg-info/top_level.txt [new file with mode: 0644]
www/maps/maps/__init__.py [new file with mode: 0644]
www/maps/maps/config/__init__.py [new file with mode: 0644]
www/maps/maps/config/deployment.ini_tmpl [new file with mode: 0644]
www/maps/maps/config/environment.py [new file with mode: 0644]
www/maps/maps/config/middleware.py [new file with mode: 0644]
www/maps/maps/config/routing.py [new file with mode: 0644]
www/maps/maps/controllers/__init__.py [new file with mode: 0644]
www/maps/maps/controllers/directions.py [new file with mode: 0644]
www/maps/maps/controllers/error.py [new file with mode: 0644]
www/maps/maps/controllers/javascript.py [new file with mode: 0644]
www/maps/maps/controllers/location.py [new file with mode: 0644]
www/maps/maps/lib/__init__.py [new file with mode: 0644]
www/maps/maps/lib/app_globals.py [new file with mode: 0644]
www/maps/maps/lib/base.py [new file with mode: 0644]
www/maps/maps/lib/helpers.py [new file with mode: 0644]
www/maps/maps/model/__init__.py [new file with mode: 0644]
www/maps/maps/public/bg.png [new file with mode: 0644]
www/maps/maps/public/favicon.ico [new file with mode: 0644]
www/maps/maps/public/pylons-logo.gif [new file with mode: 0644]
www/maps/maps/public/stylesheets/common.css [new file with mode: 0644]
www/maps/maps/public/stylesheets/reset.css [new file with mode: 0644]
www/maps/maps/templates/base.mako [new file with mode: 0644]
www/maps/maps/templates/javascript/routing.mako [new file with mode: 0644]
www/maps/maps/templates/location/index.mako [new file with mode: 0644]
www/maps/maps/tests/__init__.py [new file with mode: 0644]
www/maps/maps/tests/functional/__init__.py [new file with mode: 0644]
www/maps/maps/tests/functional/test_directions.py [new file with mode: 0644]
www/maps/maps/tests/functional/test_javascript.py [new file with mode: 0644]
www/maps/maps/tests/functional/test_location.py [new file with mode: 0644]
www/maps/maps/tests/test_models.py [new file with mode: 0644]
www/maps/maps/websetup.py [new file with mode: 0644]
www/maps/setup.cfg [new file with mode: 0644]
www/maps/setup.py [new file with mode: 0644]
www/maps/test.ini [new file with mode: 0644]

diff --git a/www/maps/MANIFEST.in b/www/maps/MANIFEST.in
new file mode 100644 (file)
index 0000000..4949be5
--- /dev/null
@@ -0,0 +1,3 @@
+include maps/config/deployment.ini_tmpl
+recursive-include maps/public *
+recursive-include maps/templates *
diff --git a/www/maps/data/templates/.gitignore b/www/maps/data/templates/.gitignore
new file mode 100644 (file)
index 0000000..72e8ffc
--- /dev/null
@@ -0,0 +1 @@
+*
diff --git a/www/maps/development.ini b/www/maps/development.ini
new file mode 100644 (file)
index 0000000..3c95c40
--- /dev/null
@@ -0,0 +1,72 @@
+#
+# maps - Pylons development environment configuration
+#
+# The %(here)s variable will be replaced with the parent directory of this file
+#
+[DEFAULT]
+debug = true
+# Uncomment and replace with the address which should receive any error reports
+#email_to = you@yourdomain.com
+smtp_server = localhost
+error_email_from = paste@localhost
+
+[server:main]
+use = egg:Paste#http
+host = 127.0.0.1
+port = 5000
+
+[app:main]
+use = egg:maps
+full_stack = true
+static_files = true
+
+cache_dir = %(here)s/data
+beaker.session.key = maps
+beaker.session.secret = somesecret
+
+# If you'd like to fine-tune the individual locations of the cache data dirs
+# for the Cache data, or the Session saves, un-comment the desired settings
+# here:
+#beaker.cache.data_dir = %(here)s/data/cache
+#beaker.session.data_dir = %(here)s/data/sessions
+
+# WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT*
+# Debug mode will enable the interactive debugging tool, allowing ANYONE to
+# execute malicious code after an exception is raised.
+#set debug = false
+
+
+# Logging configuration
+[loggers]
+keys = root, routes, maps
+
+[handlers]
+keys = console
+
+[formatters]
+keys = generic
+
+[logger_root]
+level = INFO
+handlers = console
+
+[logger_routes]
+level = INFO
+handlers =
+qualname = routes.middleware
+# "level = DEBUG" logs the route matched and routing variables.
+
+[logger_maps]
+level = DEBUG
+handlers =
+qualname = maps
+
+[handler_console]
+class = StreamHandler
+args = (sys.stderr,)
+level = NOTSET
+formatter = generic
+
+[formatter_generic]
+format = %(asctime)s,%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
+datefmt = %H:%M:%S
diff --git a/www/maps/docs/index.txt b/www/maps/docs/index.txt
new file mode 100644 (file)
index 0000000..9552483
--- /dev/null
@@ -0,0 +1,19 @@
+maps
+++++
+
+This is the main index page of your documentation. It should be written in
+`reStructuredText format <http://docutils.sourceforge.net/rst.html>`_.
+
+You can generate your documentation in HTML format by running this command::
+
+    setup.py pudge
+
+For this to work you will need to download and install `buildutils`_,
+`pudge`_, and `pygments`_.  The ``pudge`` command is disabled by
+default; to ativate it in your project, run::
+
+    setup.py addcommand -p buildutils.pudge_command
+
+.. _buildutils: http://pypi.python.org/pypi/buildutils
+.. _pudge: http://pudge.lesscode.org/
+.. _pygments: http://pygments.org/
diff --git a/www/maps/ez_setup.py b/www/maps/ez_setup.py
new file mode 100644 (file)
index 0000000..d24e845
--- /dev/null
@@ -0,0 +1,276 @@
+#!python
+"""Bootstrap setuptools installation
+
+If you want to use setuptools in your package's setup.py, just include this
+file in the same directory with it, and add this to the top of your setup.py::
+
+    from ez_setup import use_setuptools
+    use_setuptools()
+
+If you want to require a specific version of setuptools, set a download
+mirror, or use an alternate download directory, you can do so by supplying
+the appropriate options to ``use_setuptools()``.
+
+This file can also be run as a script to install or upgrade setuptools.
+"""
+import sys
+DEFAULT_VERSION = "0.6c9"
+DEFAULT_URL     = "http://pypi.python.org/packages/%s/s/setuptools/" % sys.version[:3]
+
+md5_data = {
+    'setuptools-0.6b1-py2.3.egg': '8822caf901250d848b996b7f25c6e6ca',
+    'setuptools-0.6b1-py2.4.egg': 'b79a8a403e4502fbb85ee3f1941735cb',
+    'setuptools-0.6b2-py2.3.egg': '5657759d8a6d8fc44070a9d07272d99b',
+    'setuptools-0.6b2-py2.4.egg': '4996a8d169d2be661fa32a6e52e4f82a',
+    'setuptools-0.6b3-py2.3.egg': 'bb31c0fc7399a63579975cad9f5a0618',
+    'setuptools-0.6b3-py2.4.egg': '38a8c6b3d6ecd22247f179f7da669fac',
+    'setuptools-0.6b4-py2.3.egg': '62045a24ed4e1ebc77fe039aa4e6f7e5',
+    'setuptools-0.6b4-py2.4.egg': '4cb2a185d228dacffb2d17f103b3b1c4',
+    'setuptools-0.6c1-py2.3.egg': 'b3f2b5539d65cb7f74ad79127f1a908c',
+    'setuptools-0.6c1-py2.4.egg': 'b45adeda0667d2d2ffe14009364f2a4b',
+    'setuptools-0.6c2-py2.3.egg': 'f0064bf6aa2b7d0f3ba0b43f20817c27',
+    'setuptools-0.6c2-py2.4.egg': '616192eec35f47e8ea16cd6a122b7277',
+    'setuptools-0.6c3-py2.3.egg': 'f181fa125dfe85a259c9cd6f1d7b78fa',
+    'setuptools-0.6c3-py2.4.egg': 'e0ed74682c998bfb73bf803a50e7b71e',
+    'setuptools-0.6c3-py2.5.egg': 'abef16fdd61955514841c7c6bd98965e',
+    'setuptools-0.6c4-py2.3.egg': 'b0b9131acab32022bfac7f44c5d7971f',
+    'setuptools-0.6c4-py2.4.egg': '2a1f9656d4fbf3c97bf946c0a124e6e2',
+    'setuptools-0.6c4-py2.5.egg': '8f5a052e32cdb9c72bcf4b5526f28afc',
+    'setuptools-0.6c5-py2.3.egg': 'ee9fd80965da04f2f3e6b3576e9d8167',
+    'setuptools-0.6c5-py2.4.egg': 'afe2adf1c01701ee841761f5bcd8aa64',
+    'setuptools-0.6c5-py2.5.egg': 'a8d3f61494ccaa8714dfed37bccd3d5d',
+    'setuptools-0.6c6-py2.3.egg': '35686b78116a668847237b69d549ec20',
+    'setuptools-0.6c6-py2.4.egg': '3c56af57be3225019260a644430065ab',
+    'setuptools-0.6c6-py2.5.egg': 'b2f8a7520709a5b34f80946de5f02f53',
+    'setuptools-0.6c7-py2.3.egg': '209fdf9adc3a615e5115b725658e13e2',
+    'setuptools-0.6c7-py2.4.egg': '5a8f954807d46a0fb67cf1f26c55a82e',
+    'setuptools-0.6c7-py2.5.egg': '45d2ad28f9750e7434111fde831e8372',
+    'setuptools-0.6c8-py2.3.egg': '50759d29b349db8cfd807ba8303f1902',
+    'setuptools-0.6c8-py2.4.egg': 'cba38d74f7d483c06e9daa6070cce6de',
+    'setuptools-0.6c8-py2.5.egg': '1721747ee329dc150590a58b3e1ac95b',
+    'setuptools-0.6c9-py2.3.egg': 'a83c4020414807b496e4cfbe08507c03',
+    'setuptools-0.6c9-py2.4.egg': '260a2be2e5388d66bdaee06abec6342a',
+    'setuptools-0.6c9-py2.5.egg': 'fe67c3e5a17b12c0e7c541b7ea43a8e6',
+    'setuptools-0.6c9-py2.6.egg': 'ca37b1ff16fa2ede6e19383e7b59245a',
+}
+
+import sys, os
+try: from hashlib import md5
+except ImportError: from md5 import md5
+
+def _validate_md5(egg_name, data):
+    if egg_name in md5_data:
+        digest = md5(data).hexdigest()
+        if digest != md5_data[egg_name]:
+            print >>sys.stderr, (
+                "md5 validation of %s failed!  (Possible download problem?)"
+                % egg_name
+            )
+            sys.exit(2)
+    return data
+
+def use_setuptools(
+    version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir,
+    download_delay=15
+):
+    """Automatically find/download setuptools and make it available on sys.path
+
+    `version` should be a valid setuptools version number that is available
+    as an egg for download under the `download_base` URL (which should end with
+    a '/').  `to_dir` is the directory where setuptools will be downloaded, if
+    it is not already available.  If `download_delay` is specified, it should
+    be the number of seconds that will be paused before initiating a download,
+    should one be required.  If an older version of setuptools is installed,
+    this routine will print a message to ``sys.stderr`` and raise SystemExit in
+    an attempt to abort the calling script.
+    """
+    was_imported = 'pkg_resources' in sys.modules or 'setuptools' in sys.modules
+    def do_download():
+        egg = download_setuptools(version, download_base, to_dir, download_delay)
+        sys.path.insert(0, egg)
+        import setuptools; setuptools.bootstrap_install_from = egg
+    try:
+        import pkg_resources
+    except ImportError:
+        return do_download()       
+    try:
+        pkg_resources.require("setuptools>="+version); return
+    except pkg_resources.VersionConflict, e:
+        if was_imported:
+            print >>sys.stderr, (
+            "The required version of setuptools (>=%s) is not available, and\n"
+            "can't be installed while this script is running. Please install\n"
+            " a more recent version first, using 'easy_install -U setuptools'."
+            "\n\n(Currently using %r)"
+            ) % (version, e.args[0])
+            sys.exit(2)
+        else:
+            del pkg_resources, sys.modules['pkg_resources']    # reload ok
+            return do_download()
+    except pkg_resources.DistributionNotFound:
+        return do_download()
+
+def download_setuptools(
+    version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir,
+    delay = 15
+):
+    """Download setuptools from a specified location and return its filename
+
+    `version` should be a valid setuptools version number that is available
+    as an egg for download under the `download_base` URL (which should end
+    with a '/'). `to_dir` is the directory where the egg will be downloaded.
+    `delay` is the number of seconds to pause before an actual download attempt.
+    """
+    import urllib2, shutil
+    egg_name = "setuptools-%s-py%s.egg" % (version,sys.version[:3])
+    url = download_base + egg_name
+    saveto = os.path.join(to_dir, egg_name)
+    src = dst = None
+    if not os.path.exists(saveto):  # Avoid repeated downloads
+        try:
+            from distutils import log
+            if delay:
+                log.warn("""
+---------------------------------------------------------------------------
+This script requires setuptools version %s to run (even to display
+help).  I will attempt to download it for you (from
+%s), but
+you may need to enable firewall access for this script first.
+I will start the download in %d seconds.
+
+(Note: if this machine does not have network access, please obtain the file
+
+   %s
+
+and place it in this directory before rerunning this script.)
+---------------------------------------------------------------------------""",
+                    version, download_base, delay, url
+                ); from time import sleep; sleep(delay)
+            log.warn("Downloading %s", url)
+            src = urllib2.urlopen(url)
+            # Read/write all in one block, so we don't create a corrupt file
+            # if the download is interrupted.
+            data = _validate_md5(egg_name, src.read())
+            dst = open(saveto,"wb"); dst.write(data)
+        finally:
+            if src: src.close()
+            if dst: dst.close()
+    return os.path.realpath(saveto)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+def main(argv, version=DEFAULT_VERSION):
+    """Install or upgrade setuptools and EasyInstall"""
+    try:
+        import setuptools
+    except ImportError:
+        egg = None
+        try:
+            egg = download_setuptools(version, delay=0)
+            sys.path.insert(0,egg)
+            from setuptools.command.easy_install import main
+            return main(list(argv)+[egg])   # we're done here
+        finally:
+            if egg and os.path.exists(egg):
+                os.unlink(egg)
+    else:
+        if setuptools.__version__ == '0.0.1':
+            print >>sys.stderr, (
+            "You have an obsolete version of setuptools installed.  Please\n"
+            "remove it from your system entirely before rerunning this script."
+            )
+            sys.exit(2)
+
+    req = "setuptools>="+version
+    import pkg_resources
+    try:
+        pkg_resources.require(req)
+    except pkg_resources.VersionConflict:
+        try:
+            from setuptools.command.easy_install import main
+        except ImportError:
+            from easy_install import main
+        main(list(argv)+[download_setuptools(delay=0)])
+        sys.exit(0) # try to force an exit
+    else:
+        if argv:
+            from setuptools.command.easy_install import main
+            main(argv)
+        else:
+            print "Setuptools version",version,"or greater has been installed."
+            print '(Run "ez_setup.py -U setuptools" to reinstall or upgrade.)'
+
+def update_md5(filenames):
+    """Update our built-in md5 registry"""
+
+    import re
+
+    for name in filenames:
+        base = os.path.basename(name)
+        f = open(name,'rb')
+        md5_data[base] = md5(f.read()).hexdigest()
+        f.close()
+
+    data = ["    %r: %r,\n" % it for it in md5_data.items()]
+    data.sort()
+    repl = "".join(data)
+
+    import inspect
+    srcfile = inspect.getsourcefile(sys.modules[__name__])
+    f = open(srcfile, 'rb'); src = f.read(); f.close()
+
+    match = re.search("\nmd5_data = {\n([^}]+)}", src)
+    if not match:
+        print >>sys.stderr, "Internal error!"
+        sys.exit(2)
+
+    src = src[:match.start(1)] + repl + src[match.end(1):]
+    f = open(srcfile,'w')
+    f.write(src)
+    f.close()
+
+
+if __name__=='__main__':
+    if len(sys.argv)>2 and sys.argv[1]=='--md5update':
+        update_md5(sys.argv[2:])
+    else:
+        main(sys.argv[1:])
+
+
+
+
+
+
diff --git a/www/maps/maps.egg-info/PKG-INFO b/www/maps/maps.egg-info/PKG-INFO
new file mode 100644 (file)
index 0000000..6954676
--- /dev/null
@@ -0,0 +1,10 @@
+Metadata-Version: 1.0
+Name: maps
+Version: 0.1dev
+Summary: UNKNOWN
+Home-page: UNKNOWN
+Author: UNKNOWN
+Author-email: UNKNOWN
+License: UNKNOWN
+Description: UNKNOWN
+Platform: UNKNOWN
diff --git a/www/maps/maps.egg-info/SOURCES.txt b/www/maps/maps.egg-info/SOURCES.txt
new file mode 100644 (file)
index 0000000..83a5490
--- /dev/null
@@ -0,0 +1,33 @@
+MANIFEST.in
+README.txt
+setup.cfg
+setup.py
+maps/__init__.py
+maps/websetup.py
+maps.egg-info/PKG-INFO
+maps.egg-info/SOURCES.txt
+maps.egg-info/dependency_links.txt
+maps.egg-info/entry_points.txt
+maps.egg-info/not-zip-safe
+maps.egg-info/paster_plugins.txt
+maps.egg-info/requires.txt
+maps.egg-info/top_level.txt
+maps/config/__init__.py
+maps/config/deployment.ini_tmpl
+maps/config/environment.py
+maps/config/middleware.py
+maps/config/routing.py
+maps/controllers/__init__.py
+maps/controllers/error.py
+maps/lib/__init__.py
+maps/lib/app_globals.py
+maps/lib/base.py
+maps/lib/helpers.py
+maps/model/__init__.py
+maps/public/bg.png
+maps/public/favicon.ico
+maps/public/index.html
+maps/public/pylons-logo.gif
+maps/tests/__init__.py
+maps/tests/test_models.py
+maps/tests/functional/__init__.py
\ No newline at end of file
diff --git a/www/maps/maps.egg-info/dependency_links.txt b/www/maps/maps.egg-info/dependency_links.txt
new file mode 100644 (file)
index 0000000..8b13789
--- /dev/null
@@ -0,0 +1 @@
+
diff --git a/www/maps/maps.egg-info/entry_points.txt b/www/maps/maps.egg-info/entry_points.txt
new file mode 100644 (file)
index 0000000..02077d8
--- /dev/null
@@ -0,0 +1,7 @@
+
+    [paste.app_factory]
+    main = maps.config.middleware:make_app
+
+    [paste.app_install]
+    main = pylons.util:PylonsInstaller
+    
\ No newline at end of file
diff --git a/www/maps/maps.egg-info/not-zip-safe b/www/maps/maps.egg-info/not-zip-safe
new file mode 100644 (file)
index 0000000..8b13789
--- /dev/null
@@ -0,0 +1 @@
+
diff --git a/www/maps/maps.egg-info/paster_plugins.txt b/www/maps/maps.egg-info/paster_plugins.txt
new file mode 100644 (file)
index 0000000..c24c7fe
--- /dev/null
@@ -0,0 +1,2 @@
+PasteScript
+Pylons
diff --git a/www/maps/maps.egg-info/requires.txt b/www/maps/maps.egg-info/requires.txt
new file mode 100644 (file)
index 0000000..a6822b7
--- /dev/null
@@ -0,0 +1 @@
+Pylons>=0.9.7
\ No newline at end of file
diff --git a/www/maps/maps.egg-info/top_level.txt b/www/maps/maps.egg-info/top_level.txt
new file mode 100644 (file)
index 0000000..89722a3
--- /dev/null
@@ -0,0 +1 @@
+maps
diff --git a/www/maps/maps/__init__.py b/www/maps/maps/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/www/maps/maps/config/__init__.py b/www/maps/maps/config/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/www/maps/maps/config/deployment.ini_tmpl b/www/maps/maps/config/deployment.ini_tmpl
new file mode 100644 (file)
index 0000000..97028a9
--- /dev/null
@@ -0,0 +1,60 @@
+#
+# maps - Pylons configuration
+#
+# The %(here)s variable will be replaced with the parent directory of this file
+#
+[DEFAULT]
+debug = true
+email_to = you@yourdomain.com
+smtp_server = localhost
+error_email_from = paste@localhost
+
+[server:main]
+use = egg:Paste#http
+host = 0.0.0.0
+port = 5000
+
+[app:main]
+use = egg:maps
+full_stack = true
+static_files = true
+
+cache_dir = %(here)s/data
+beaker.session.key = maps
+beaker.session.secret = ${app_instance_secret}
+app_instance_uuid = ${app_instance_uuid}
+
+# If you'd like to fine-tune the individual locations of the cache data dirs
+# for the Cache data, or the Session saves, un-comment the desired settings
+# here:
+#beaker.cache.data_dir = %(here)s/data/cache
+#beaker.session.data_dir = %(here)s/data/sessions
+
+# WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT*
+# Debug mode will enable the interactive debugging tool, allowing ANYONE to
+# execute malicious code after an exception is raised.
+set debug = false
+
+
+# Logging configuration
+[loggers]
+keys = root
+
+[handlers]
+keys = console
+
+[formatters]
+keys = generic
+
+[logger_root]
+level = INFO
+handlers = console
+
+[handler_console]
+class = StreamHandler
+args = (sys.stderr,)
+level = NOTSET
+formatter = generic
+
+[formatter_generic]
+format = %(asctime)s %(levelname)-5.5s [%(name)s] %(message)s
diff --git a/www/maps/maps/config/environment.py b/www/maps/maps/config/environment.py
new file mode 100644 (file)
index 0000000..0b7e055
--- /dev/null
@@ -0,0 +1,41 @@
+"""Pylons environment configuration"""
+import os
+
+from mako.lookup import TemplateLookup
+from pylons import config
+from pylons.error import handle_mako_error
+
+import maps.lib.app_globals as app_globals
+import maps.lib.helpers
+from maps.config.routing import make_map
+
+def load_environment(global_conf, app_conf):
+    """Configure the Pylons environment via the ``pylons.config``
+    object
+    """
+    # Pylons paths
+    root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+    paths = dict(root=root,
+                 controllers=os.path.join(root, 'controllers'),
+                 static_files=os.path.join(root, 'public'),
+                 templates=[os.path.join(root, 'templates')])
+
+    # Initialize config with the basic options
+    config.init_app(global_conf, app_conf, package='maps', paths=paths)
+
+    config['routes.map'] = make_map()
+    config['pylons.app_globals'] = app_globals.Globals()
+    config['pylons.h'] = maps.lib.helpers
+
+    # Create the Mako TemplateLookup, with the default auto-escaping
+    config['pylons.app_globals'].mako_lookup = TemplateLookup(
+        directories=paths['templates'],
+        error_handler=handle_mako_error,
+        module_directory=os.path.join(app_conf['cache_dir'], 'templates'),
+        input_encoding='utf-8', default_filters=['escape'],
+        imports=['from webhelpers.html import escape'])
+
+    # CONFIGURATION OPTIONS HERE (note: all config options will override
+    # any Pylons config options)
+    config['pylons.strict_c'] = True
+    
diff --git a/www/maps/maps/config/middleware.py b/www/maps/maps/config/middleware.py
new file mode 100644 (file)
index 0000000..3bc9bf5
--- /dev/null
@@ -0,0 +1,69 @@
+"""Pylons middleware initialization"""
+from beaker.middleware import CacheMiddleware, SessionMiddleware
+from paste.cascade import Cascade
+from paste.registry import RegistryManager
+from paste.urlparser import StaticURLParser
+from paste.deploy.converters import asbool
+from pylons import config
+from pylons.middleware import ErrorHandler, StatusCodeRedirect
+from pylons.wsgiapp import PylonsApp
+from routes.middleware import RoutesMiddleware
+
+from maps.config.environment import load_environment
+
+def make_app(global_conf, full_stack=True, static_files=True, **app_conf):
+    """Create a Pylons WSGI application and return it
+
+    ``global_conf``
+        The inherited configuration for this application. Normally from
+        the [DEFAULT] section of the Paste ini file.
+
+    ``full_stack``
+        Whether this application provides a full WSGI stack (by default,
+        meaning it handles its own exceptions and errors). Disable
+        full_stack when this application is "managed" by another WSGI
+        middleware.
+
+    ``static_files``
+        Whether this application serves its own static files; disable
+        when another web server is responsible for serving them.
+
+    ``app_conf``
+        The application's local configuration. Normally specified in
+        the [app:<name>] section of the Paste ini file (where <name>
+        defaults to main).
+
+    """
+    # Configure the Pylons environment
+    load_environment(global_conf, app_conf)
+
+    # The Pylons WSGI app
+    app = PylonsApp()
+
+    # Routing/Session/Cache Middleware
+    app = RoutesMiddleware(app, config['routes.map'])
+    app = SessionMiddleware(app, config)
+    app = CacheMiddleware(app, config)
+
+    # CUSTOM MIDDLEWARE HERE (filtered by error handling middlewares)
+
+    if asbool(full_stack):
+        # Handle Python exceptions
+        app = ErrorHandler(app, global_conf, **config['pylons.errorware'])
+
+        # Display error documents for 401, 403, 404 status codes (and
+        # 500 when debug is disabled)
+        if asbool(config['debug']):
+            app = StatusCodeRedirect(app)
+        else:
+            app = StatusCodeRedirect(app, [400, 401, 403, 404, 500])
+
+    # Establish the Registry for this application
+    app = RegistryManager(app)
+
+    if asbool(static_files):
+        # Serve static files
+        static_app = StaticURLParser(config['pylons.paths']['static_files'])
+        app = Cascade([static_app, app])
+
+    return app
diff --git a/www/maps/maps/config/routing.py b/www/maps/maps/config/routing.py
new file mode 100644 (file)
index 0000000..a79360a
--- /dev/null
@@ -0,0 +1,27 @@
+"""Routes configuration
+
+The more specific and detailed routes should be defined first so they
+may take precedent over the more generic routes. For more information
+refer to the routes manual at http://routes.groovie.org/docs/
+"""
+from pylons import config
+from routes import Mapper
+
+def make_map():
+    """Create, configure and return the routes Mapper"""
+    map = Mapper(directory=config['pylons.paths']['controllers'],
+                 always_scan=config['debug'])
+    map.minimization = False
+
+    # The ErrorController route (handles 404/500 error pages); it should
+    # likely stay at the top, ensuring it can always be resolved
+    map.connect('/error/{action}', controller='error')
+    map.connect('/error/{action}/{id}', controller='error')
+
+    # CUSTOM ROUTES HERE
+
+    map.connect('/{controller}/{action}')
+    map.connect('/{controller}/{action}/{id}')
+
+    map.connect('home', '/', controller='location', action='index')
+    return map
diff --git a/www/maps/maps/controllers/__init__.py b/www/maps/maps/controllers/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/www/maps/maps/controllers/directions.py b/www/maps/maps/controllers/directions.py
new file mode 100644 (file)
index 0000000..eabdfd4
--- /dev/null
@@ -0,0 +1,88 @@
+import json
+import logging
+import os
+import site
+import sys
+
+from pylons import request, response, session, tmpl_context as c
+from pylons.controllers.util import abort, redirect_to
+from maps.lib.base import BaseController, render
+
+# Ugh.
+project_root = os.path.dirname(os.path.abspath(__file__)) + '/../../../..'
+site.addsitedir(project_root + '/src')
+import KML
+
+
+log = logging.getLogger(__name__)
+
+class DirectionsController(BaseController):
+
+    # Google geocodes the start and end coordinates
+    # automatically. There's no other way to pass the "name" of a
+    # route back to the server, so we have to rely on the geocoded
+    # names for identification.
+    def get_route_address(self, route, start=True):
+        location_string = "start"
+        
+        if not start:
+            # There are only two named properties, one for
+            # start_geocode and one for end_geocode.
+            location_string = "end"
+
+        # Get the GeocoderResponse object.
+        gr = route[location_string + '_geocode']
+
+        try:
+            return gr['formatted_address']
+        except:
+            return 'Unknown'
+
+    
+    def directions_result_to_placemarks(self, result):
+        placemarks = []
+        trip_idx = 0
+
+        for trip in result['trips']:
+            trip_idx += 1            
+            
+            for route in trip['routes']:
+                p = KML.Placemark()
+                route_start = self.get_route_address(route, True)
+                route_end   = self.get_route_address(route, False)
+                route_name  = route_start + " to " + route_end
+                route_name += ' (' + str(trip_idx) + ')'
+                name_element = KML.Name(route_name)
+                p.children.append(name_element)
+                ls = KML.LineString()
+
+                coords = KML.Coordinates()
+                
+                for step in route['steps']:
+                    for coord in step['lat_lngs']:
+                        coords.text += str(coord.values()[1])
+                        coords.text += ','
+                        coords.text += str(coord.values()[0])
+                        coords.text += ',0 '
+                        
+                ls.children.append(coords)
+                p.children.append(ls)
+                placemarks.append(p)
+            
+        return placemarks
+
+    
+    def json_to_kml(self):
+        directions_array = json.loads(request.POST['directions_result'])
+        placemarks = []
+        for result in directions_array:
+            placemarks += self.directions_result_to_placemarks(result)
+
+        doc = KML.Document()
+        for p in placemarks:
+            doc.children.append(p)
+
+        response.content_type = 'application/vnd.google-earth.kml+xml'
+        response.headers['Content-disposition'] = 'attachment; filename=routes.kml'
+        return doc.to_kml()
+
diff --git a/www/maps/maps/controllers/error.py b/www/maps/maps/controllers/error.py
new file mode 100644 (file)
index 0000000..b98525c
--- /dev/null
@@ -0,0 +1,46 @@
+import cgi
+
+from paste.urlparser import PkgResourcesParser
+from pylons import request
+from pylons.controllers.util import forward
+from pylons.middleware import error_document_template
+from webhelpers.html.builder import literal
+
+from maps.lib.base import BaseController
+
+class ErrorController(BaseController):
+
+    """Generates error documents as and when they are required.
+
+    The ErrorDocuments middleware forwards to ErrorController when error
+    related status codes are returned from the application.
+
+    This behaviour can be altered by changing the parameters to the
+    ErrorDocuments middleware in your config/middleware.py file.
+
+    """
+
+    def document(self):
+        """Render the error document"""
+        resp = request.environ.get('pylons.original_response')
+        content = literal(resp.body) or cgi.escape(request.GET.get('message', ''))
+        page = error_document_template % \
+            dict(prefix=request.environ.get('SCRIPT_NAME', ''),
+                 code=cgi.escape(request.GET.get('code', str(resp.status_int))),
+                 message=content)
+        return page
+
+    def img(self, id):
+        """Serve Pylons' stock images"""
+        return self._serve_file('/'.join(['media/img', id]))
+
+    def style(self, id):
+        """Serve Pylons' stock stylesheets"""
+        return self._serve_file('/'.join(['media/style', id]))
+
+    def _serve_file(self, path):
+        """Call Paste's FileApp (a WSGI application) to serve the file
+        at the specified path
+        """
+        request.environ['PATH_INFO'] = '/%s' % path
+        return forward(PkgResourcesParser('pylons', 'pylons'))
diff --git a/www/maps/maps/controllers/javascript.py b/www/maps/maps/controllers/javascript.py
new file mode 100644 (file)
index 0000000..ebce010
--- /dev/null
@@ -0,0 +1,17 @@
+import logging
+
+from pylons import request, response, session, tmpl_context as c
+from pylons.controllers.util import abort, redirect_to
+
+from maps.lib.base import BaseController, render
+
+log = logging.getLogger(__name__)
+
+class JavascriptController(BaseController):
+
+    def index(self):
+        return ''
+
+    def routing(self):
+        c.json = request.GET['json']
+        return render('/javascript/routing.mako')
diff --git a/www/maps/maps/controllers/location.py b/www/maps/maps/controllers/location.py
new file mode 100644 (file)
index 0000000..c3e8298
--- /dev/null
@@ -0,0 +1,45 @@
+import csv
+import json
+import logging
+
+from pylons import request, response, session, tmpl_context as c
+from pylons.controllers.util import abort, redirect_to
+
+from maps.lib.base import BaseController, render
+
+log = logging.getLogger(__name__)
+
+class LocationController(BaseController):
+
+    def index(self):
+        c.load_maps = False
+
+        if request.method == 'POST':
+            c.load_maps = True
+
+            # Get the contents of the uploaded files.
+            producers_data = request.POST['producers'].value.splitlines()
+            consumers_data = request.POST['consumers'].value.splitlines()
+        
+            producers_csv = csv.DictReader(producers_data)
+            consumers_csv = csv.DictReader(consumers_data)
+
+            # Create a big json string to pass as a parameter to our
+            # javascript page.
+            json_objects = []
+
+            for row in producers_csv:
+                # Add the producers to the output, one at a time.
+                # But first, insert a 'type' field.
+                row['type'] = 'producer'
+                json_objects.append(row)
+
+            for row in consumers_csv:
+                # Do the same thing for the consumers.
+                row['type'] = 'consumer'
+                json_objects.append(row)
+
+            c.json = json.dumps(json_objects)
+        
+        return render('/location/index.mako')
+
diff --git a/www/maps/maps/lib/__init__.py b/www/maps/maps/lib/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/www/maps/maps/lib/app_globals.py b/www/maps/maps/lib/app_globals.py
new file mode 100644 (file)
index 0000000..8e62241
--- /dev/null
@@ -0,0 +1,15 @@
+"""The application's Globals object"""
+
+class Globals(object):
+
+    """Globals acts as a container for objects available throughout the
+    life of the application
+
+    """
+
+    def __init__(self):
+        """One instance of Globals is created during application
+        initialization and is available during requests via the
+        'app_globals' variable
+
+        """
diff --git a/www/maps/maps/lib/base.py b/www/maps/maps/lib/base.py
new file mode 100644 (file)
index 0000000..56a090b
--- /dev/null
@@ -0,0 +1,15 @@
+"""The base Controller API
+
+Provides the BaseController class for subclassing.
+"""
+from pylons.controllers import WSGIController
+from pylons.templating import render_mako as render
+
+class BaseController(WSGIController):
+
+    def __call__(self, environ, start_response):
+        """Invoke the Controller"""
+        # WSGIController.__call__ dispatches to the Controller method
+        # the request is routed to. This routing information is
+        # available in environ['pylons.routes_dict']
+        return WSGIController.__call__(self, environ, start_response)
diff --git a/www/maps/maps/lib/helpers.py b/www/maps/maps/lib/helpers.py
new file mode 100644 (file)
index 0000000..630f1ba
--- /dev/null
@@ -0,0 +1,8 @@
+"""Helper functions
+
+Consists of functions to typically be used within templates, but also
+available to Controllers. This module is available to templates as 'h'.
+"""
+# Import helpers as desired, or define your own, ie:
+from webhelpers.html import literal
+from webhelpers.html.tags import *
diff --git a/www/maps/maps/model/__init__.py b/www/maps/maps/model/__init__.py
new file mode 100644 (file)
index 0000000..03dff1b
--- /dev/null
@@ -0,0 +1,3 @@
+
+
+    
diff --git a/www/maps/maps/public/bg.png b/www/maps/maps/public/bg.png
new file mode 100644 (file)
index 0000000..69c1798
Binary files /dev/null and b/www/maps/maps/public/bg.png differ
diff --git a/www/maps/maps/public/favicon.ico b/www/maps/maps/public/favicon.ico
new file mode 100644 (file)
index 0000000..21e215e
Binary files /dev/null and b/www/maps/maps/public/favicon.ico differ
diff --git a/www/maps/maps/public/pylons-logo.gif b/www/maps/maps/public/pylons-logo.gif
new file mode 100644 (file)
index 0000000..61b2d9a
Binary files /dev/null and b/www/maps/maps/public/pylons-logo.gif differ
diff --git a/www/maps/maps/public/stylesheets/common.css b/www/maps/maps/public/stylesheets/common.css
new file mode 100644 (file)
index 0000000..49b2581
--- /dev/null
@@ -0,0 +1,111 @@
+body {  
+  background-color: #fff;
+  color: #000;
+  font-family: georgia;
+  font-size: 16px;
+  line-height: 1.5;
+  margin: 1em auto;
+  width: 42em;
+}
+
+
+caption {
+  color: #0b2850;
+  font-family: 'Times New Roman', serif;
+  font-style: italic;
+  line-height: 1.22222em;
+  font-size: 1.125em;
+  margin: 1.22222em 0;
+  text-align: center;
+}
+
+
+em {
+  font-style: italic;
+}
+
+
+h1 {
+  font-family: 'Times New Roman', serif;
+  font-size: 3em;
+  text-transform: lowercase;
+  font-variant: small-caps;
+  margin-top: .5em;
+}
+
+
+h2 {
+  font-size: 1.5em;
+  margin: 1em 0;
+}
+
+
+h3, legend {
+  color: #339;
+  font-family: 'Times New Roman', serif;
+  font-size: 1.2em;
+  font-style: italic;
+  margin: .5em 0;
+}
+
+
+h3 {
+  margin: 1.25em 0;
+}
+
+
+label, input {
+  display: block;
+  margin: .5em 0;
+}
+
+
+p {
+  margin: 1.5em 0;
+}
+
+
+table {
+  border: 1px #e0e0e0 dotted;
+  margin: 0 auto;
+  width: 80%;
+}
+
+
+td, th {
+  padding: .5em;
+  text-align: left;
+}
+
+
+th {
+  color: #a00;
+}
+
+
+td {
+  border-top: 1px #e0e0e0 dotted;
+}
+
+
+.csv q:before, .csv q:after {
+  content: "\"";
+  font-style: normal;
+}
+
+
+.csv td:after, .csv th:after {
+  content: ",";
+}
+
+
+/* Remove the comma from the last column. */
+/* Internet Explorer will not do CSS3 magic it does not understand. */
+.csv tr > td:last-child:after, .csv tr > th:last-child:after {
+  content: "";
+}
+
+
+input.submit {
+  margin: 1em auto;
+}
diff --git a/www/maps/maps/public/stylesheets/reset.css b/www/maps/maps/public/stylesheets/reset.css
new file mode 100644 (file)
index 0000000..57584bf
--- /dev/null
@@ -0,0 +1,35 @@
+html, body, div, span,
+applet, object, iframe,
+h1, h2, h3, h4, h5, h6, p, blockquote, pre,
+a, abbr, acronym, address, big, cite, code,
+del, dfn, em, font, img, ins, kbd, q, s, samp,
+small, strike, strong, sub, sup, tt, var,
+dd, dl, dt, li, ol, ul,
+fieldset, form, label, legend,
+table, caption, tbody, tfoot, thead, tr, th, td {
+  margin: 0;
+  padding: 0;
+  border: 0;
+  font-weight: normal;
+  font-style: inherit;
+  font-size: 100%;
+  line-height: 1.5;
+  font-family: inherit;
+  text-align: inherit;
+  vertical-align: baseline;
+  background: transparent;
+}
+table {
+  border-collapse: collapse;
+  border-spacing: 0;
+}
+ol, ul {
+  list-style: none;
+}
+q:before, q:after,
+blockquote:before, blockquote:after {
+  content: "";
+}
+blockquote, q {
+  quotes: "" "";
+}
diff --git a/www/maps/maps/templates/base.mako b/www/maps/maps/templates/base.mako
new file mode 100644 (file)
index 0000000..0b14045
--- /dev/null
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+
+<html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
+
+  <head>
+      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+      <meta name="author" content="Michael Orlitzky" />
+
+      <title>Map Demo</title>
+
+      ${h.stylesheet_link('/stylesheets/reset.css')}
+      ${h.stylesheet_link('/stylesheets/common.css')}
+      
+      % if c.load_maps:
+      <script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script>
+      <script type="text/javascript"
+              src="/javascript/routing?json=${c.json}">
+      </script>
+      
+      % endif    
+  </head>
+  
+  <body>
+
+    ${next.body()}\
+    
+  </body>
+</html>
diff --git a/www/maps/maps/templates/javascript/routing.mako b/www/maps/maps/templates/javascript/routing.mako
new file mode 100644 (file)
index 0000000..20103a5
--- /dev/null
@@ -0,0 +1,146 @@
+function post_directions_result(url, directions_result) {
+  /* Create a new form, and add it to the DOM. Then, create a hidden
+     input control as a child of the form which contains the data that
+     we'd like to post. Finally, add the form to the document's body,
+     and submit it. */
+  var new_form = document.createElement("form");
+  new_form.method = "post";
+  new_form.action = url;
+  var new_input = document.createElement("input");
+  new_input.setAttribute("id", "directions_result");
+  new_input.setAttribute("name", "directions_result");
+  new_input.setAttribute("type", "hidden");
+  new_input.setAttribute("value", directions_result);
+  new_form.appendChild(new_input);
+  document.body.appendChild(new_form);
+  new_form.submit();
+}
+
+
+var producers = new Array();
+var consumers = new Array();
+
+/* The URL encoding changes all of our double quotes to &quot;, so we
+ * have to convert them back before we do anything with the JSON
+ * data. */
+var locations_json = "${c.json}";
+locations_json = locations_json.replace(/&quot;/g, '"');
+var locations = JSON.parse(locations_json);
+
+for (var location_idx = 0; location_idx < locations.length; location_idx++) {
+  if (locations[location_idx].type == 'producer') {
+    producers.push(locations[location_idx]);
+  }
+  else {
+    consumers.push(locations[location_idx]);
+  }
+}
+
+
+// Start another JSON array, this time containing our route data.
+var json_string = '[';
+var completed_requests = 0;
+var total_requests = (producers.length * consumers.length);
+
+function routing_callback(result, status) {
+  /* This is the callback that gets applied to each
+   * DirectionsResult. It occurs asynchronously, which is why we keep
+   * track of the total/completed requests. Only the last call to
+   * complete should actually do something with the final result. */
+  if (status == google.maps.DirectionsStatus.OK) {
+    json_string += JSON.stringify(result);
+
+    for (var trip_idx = 0; trip_idx < result.trips.length; trip_idx++) {
+      num_routes = result.trips[trip_idx].routes.length;
+      if (num_routes > 1) {
+         alert("Unexpected number of routes (" +
+             result.trips.routes.length.toString() +
+             ") on trip number " + trip_idx.toString() + '.');
+      }
+    }
+  }
+  else {
+    alert("Error, status: " + status);
+  }
+
+  completed_requests += 1;
+
+  if (completed_requests == total_requests) {
+    // Close the array, and do something with the result.
+    json_string += ']';
+    post_directions_result('/directions/json_to_kml', json_string)
+  }
+  else {
+    // Continue the array.
+    json_string += ',';
+  }
+  
+}
+
+
+
+function get_directions(pairs_to_skip) {
+  /* We can only get directions for 10 producer/consumer pairs at a
+   * time. We pass the pairs_to_skip variable back to this function
+   * via setTimeout so that we can skip the ones we've already
+   * submitted. */
+
+  // Create the object that will do the direction-getting.
+  var directions_service = new google.maps.DirectionsService();
+  var requests_submitted = 0;
+  
+  // And ask it to get directions for each producer/consumer pair.
+  for (var i = 0; i < producers.length; i++) {
+    for (var j = 0; j < consumers.length; j++) {
+
+      var pair_number = (i * consumers.length) + (j+1);
+
+      if (pair_number <= pairs_to_skip || requests_submitted > 9) {
+       continue;
+      }
+
+      var producer_latlng = new google.maps.LatLng(producers[i].latitude,
+                                                  producers[i].longitude);
+      
+      var consumer_latlng = new google.maps.LatLng(consumers[i].latitude,
+                                                  consumers[i].longitude);
+
+      var directions_request = {
+       origin: producer_latlng,
+       destination: consumer_latlng,
+       provideTripAlternatives: true,
+
+       travelMode: google.maps.DirectionsTravelMode.DRIVING
+      }
+
+      /* The function routing_callback(...) gets applied to the result
+       * of route(). Ideally, that result will be a DirectionsResult
+       * object containing directions. This executes
+       * asynchronously. */
+      directions_service.route(directions_request, routing_callback);
+
+      requests_submitted += 1;      
+    }
+  }
+
+  if (pairs_to_skip < total_requests) {
+    // Next time around, skip whatever requests we submitted this
+    // time.
+    pairs_to_skip += requests_submitted;
+
+    /* 5 seconds is the smallest timeout that will work here. */
+    window.setTimeout("get_directions(" + pairs_to_skip + ");", 5000);
+  }
+      
+  return;
+}
+
+
+function onload_handler(e) {
+  // Avoid problems with the implicit event argument to onload
+  // handlers.
+  get_directions(0);
+}
+
+
+window.onload = onload_handler;
diff --git a/www/maps/maps/templates/location/index.mako b/www/maps/maps/templates/location/index.mako
new file mode 100644 (file)
index 0000000..4f80d54
--- /dev/null
@@ -0,0 +1,67 @@
+<%inherit file="/base.mako"/>\
+
+<h1>Generate KML Routes</h1>
+
+<form method="post" action="" enctype="multipart/form-data">
+  <fieldset>
+    <legend>Producer/Consumer Upload</legend>
+    
+    <label for="producers">Producers File</label>
+    <input type="file" id="producers" name="producers" />
+
+    <label for="consumers">Consumers File</label>
+    <input type="file" id="consumers" name="consumers" />
+    
+    <input class="submit" type="submit" value="Route" />
+  </fieldset>
+</form>
+
+
+<h2>File Format</h2>
+<p>
+  Both uploaded files should have the same format. They should be
+  comma-delimited, with the first row containing three column names:
+  <em>name</em>, <em>latitude</em>, and <em>longitude</em>. The
+  <em>name</em> column, being of type string, should have its values
+  double-quoted.
+</p>
+
+<table class="csv" summary="Example CSV file">
+  <caption>producers-example.csv</caption>
+  <tr>
+    <th>name</th>
+    <th>latitude</th>
+    <th>longitude</th>
+  </tr>
+
+  <tr>
+    <td><q>Jack O'Neill</q></td>
+    <td>35.02135823</td>
+    <td>-76.20178512</td>
+  </tr>
+
+  <tr>
+    <td><q>Daniel Jackson</q></td>
+    <td>38.286422</td>
+    <td>-79.327437</td>
+  </tr>
+
+  <tr>
+    <td><q>Samantha Carter</q></td>
+    <td>35.9974632</td>
+    <td>-80.000000</td>
+  </tr>
+
+  <tr>
+    <td><q>Teal'c</q></td>
+    <td>45.20434632</td>
+    <td>-72.07234637</td>
+  </tr>
+
+  <tr>
+    <td><q>George Hammond</q></td>
+    <td>36.536257346</td>
+    <td>-73.263458</td>
+  </tr>
+  
+</table>
diff --git a/www/maps/maps/tests/__init__.py b/www/maps/maps/tests/__init__.py
new file mode 100644 (file)
index 0000000..d51f6f2
--- /dev/null
@@ -0,0 +1,36 @@
+"""Pylons application test package
+
+This package assumes the Pylons environment is already loaded, such as
+when this script is imported from the `nosetests --with-pylons=test.ini`
+command.
+
+This module initializes the application via ``websetup`` (`paster
+setup-app`) and provides the base testing objects.
+"""
+from unittest import TestCase
+
+from paste.deploy import loadapp
+from paste.script.appinstall import SetupCommand
+from pylons import config, url
+from routes.util import URLGenerator
+from webtest import TestApp
+
+import pylons.test
+
+__all__ = ['environ', 'url', 'TestController']
+
+# Invoke websetup with the current config file
+SetupCommand('setup-app').run([config['__file__']])
+
+environ = {}
+
+class TestController(TestCase):
+
+    def __init__(self, *args, **kwargs):
+        if pylons.test.pylonsapp:
+            wsgiapp = pylons.test.pylonsapp
+        else:
+            wsgiapp = loadapp('config:%s' % config['__file__'])
+        self.app = TestApp(wsgiapp)
+        url._push_object(URLGenerator(config['routes.map'], environ))
+        TestCase.__init__(self, *args, **kwargs)
diff --git a/www/maps/maps/tests/functional/__init__.py b/www/maps/maps/tests/functional/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/www/maps/maps/tests/functional/test_directions.py b/www/maps/maps/tests/functional/test_directions.py
new file mode 100644 (file)
index 0000000..7ceadd1
--- /dev/null
@@ -0,0 +1,7 @@
+from maps.tests import *
+
+class TestDirectionsController(TestController):
+
+    def test_index(self):
+        response = self.app.get(url(controller='directions', action='index'))
+        # Test response...
diff --git a/www/maps/maps/tests/functional/test_javascript.py b/www/maps/maps/tests/functional/test_javascript.py
new file mode 100644 (file)
index 0000000..0ca5aae
--- /dev/null
@@ -0,0 +1,7 @@
+from maps.tests import *
+
+class TestJavascriptController(TestController):
+
+    def test_index(self):
+        response = self.app.get(url(controller='javascript', action='index'))
+        # Test response...
diff --git a/www/maps/maps/tests/functional/test_location.py b/www/maps/maps/tests/functional/test_location.py
new file mode 100644 (file)
index 0000000..b0ee36f
--- /dev/null
@@ -0,0 +1,7 @@
+from maps.tests import *
+
+class TestLocationController(TestController):
+
+    def test_index(self):
+        response = self.app.get(url(controller='location', action='index'))
+        # Test response...
diff --git a/www/maps/maps/tests/test_models.py b/www/maps/maps/tests/test_models.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/www/maps/maps/websetup.py b/www/maps/maps/websetup.py
new file mode 100644 (file)
index 0000000..5a3ab45
--- /dev/null
@@ -0,0 +1,10 @@
+"""Setup the maps application"""
+import logging
+
+from maps.config.environment import load_environment
+
+log = logging.getLogger(__name__)
+
+def setup_app(command, conf, vars):
+    """Place any commands to setup maps here"""
+    load_environment(conf.global_conf, conf.local_conf)
diff --git a/www/maps/setup.cfg b/www/maps/setup.cfg
new file mode 100644 (file)
index 0000000..508bcde
--- /dev/null
@@ -0,0 +1,31 @@
+[egg_info]
+tag_build = dev
+tag_svn_revision = true
+
+[easy_install]
+find_links = http://www.pylonshq.com/download/
+
+[nosetests]
+with-pylons = test.ini
+
+# Babel configuration
+[compile_catalog]
+domain = maps
+directory = maps/i18n
+statistics = true
+
+[extract_messages]
+add_comments = TRANSLATORS:
+output_file = maps/i18n/maps.pot
+width = 80
+
+[init_catalog]
+domain = maps
+input_file = maps/i18n/maps.pot
+output_dir = maps/i18n
+
+[update_catalog]
+domain = maps
+input_file = maps/i18n/maps.pot
+output_dir = maps/i18n
+previous = true
diff --git a/www/maps/setup.py b/www/maps/setup.py
new file mode 100644 (file)
index 0000000..05f24e9
--- /dev/null
@@ -0,0 +1,36 @@
+try:
+    from setuptools import setup, find_packages
+except ImportError:
+    from ez_setup import use_setuptools
+    use_setuptools()
+    from setuptools import setup, find_packages
+
+setup(
+    name='maps',
+    version='0.1',
+    description='',
+    author='',
+    author_email='',
+    url='',
+    install_requires=[
+        "Pylons>=0.9.7",
+    ],
+    setup_requires=["PasteScript>=1.6.3"],
+    packages=find_packages(exclude=['ez_setup']),
+    include_package_data=True,
+    test_suite='nose.collector',
+    package_data={'maps': ['i18n/*/LC_MESSAGES/*.mo']},
+    #message_extractors={'maps': [
+    #        ('**.py', 'python', None),
+    #        ('templates/**.mako', 'mako', {'input_encoding': 'utf-8'}),
+    #        ('public/**', 'ignore', None)]},
+    zip_safe=False,
+    paster_plugins=['PasteScript', 'Pylons'],
+    entry_points="""
+    [paste.app_factory]
+    main = maps.config.middleware:make_app
+
+    [paste.app_install]
+    main = pylons.util:PylonsInstaller
+    """,
+)
diff --git a/www/maps/test.ini b/www/maps/test.ini
new file mode 100644 (file)
index 0000000..b7a28a0
--- /dev/null
@@ -0,0 +1,21 @@
+#
+# maps - Pylons testing environment configuration
+#
+# The %(here)s variable will be replaced with the parent directory of this file
+#
+[DEFAULT]
+debug = true
+# Uncomment and replace with the address which should receive any error reports
+#email_to = you@yourdomain.com
+smtp_server = localhost
+error_email_from = paste@localhost
+
+[server:main]
+use = egg:Paste#http
+host = 127.0.0.1
+port = 5000
+
+[app:main]
+use = config:development.ini
+
+# Add additional test specific configuration options as necessary.