Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Empty pylons project

  • Loading branch information...
commit 703aad536ef0f895c96101aba19a5dfadd45672b 0 parents
Matthew Bowra-Dean authored

Showing 37 changed files with 993 additions and 0 deletions. Show diff stats Hide diff stats

  1. +3 0  MANIFEST.in
  2. +19 0 README.txt
  3. +72 0 development.ini
  4. +19 0 docs/index.txt
  5. +276 0 ez_setup.py
  6. +10 0 metahash.egg-info/PKG-INFO
  7. +33 0 metahash.egg-info/SOURCES.txt
  8. +1 0  metahash.egg-info/dependency_links.txt
  9. +7 0 metahash.egg-info/entry_points.txt
  10. +1 0  metahash.egg-info/not-zip-safe
  11. +2 0  metahash.egg-info/paster_plugins.txt
  12. +1 0  metahash.egg-info/requires.txt
  13. +1 0  metahash.egg-info/top_level.txt
  14. 0  metahash/__init__.py
  15. 0  metahash/config/__init__.py
  16. +60 0 metahash/config/deployment.ini_tmpl
  17. +39 0 metahash/config/environment.py
  18. +69 0 metahash/config/middleware.py
  19. +26 0 metahash/config/routing.py
  20. 0  metahash/controllers/__init__.py
  21. +46 0 metahash/controllers/error.py
  22. 0  metahash/lib/__init__.py
  23. +15 0 metahash/lib/app_globals.py
  24. +15 0 metahash/lib/base.py
  25. +7 0 metahash/lib/helpers.py
  26. 0  metahash/model/__init__.py
  27. BIN  metahash/public/bg.png
  28. BIN  metahash/public/favicon.ico
  29. +137 0 metahash/public/index.html
  30. BIN  metahash/public/pylons-logo.gif
  31. +36 0 metahash/tests/__init__.py
  32. 0  metahash/tests/functional/__init__.py
  33. 0  metahash/tests/test_models.py
  34. +10 0 metahash/websetup.py
  35. +31 0 setup.cfg
  36. +36 0 setup.py
  37. +21 0 test.ini
3  MANIFEST.in
... ... @@ -0,0 +1,3 @@
  1 +include metahash/config/deployment.ini_tmpl
  2 +recursive-include metahash/public *
  3 +recursive-include metahash/templates *
19 README.txt
... ... @@ -0,0 +1,19 @@
  1 +This file is for you to describe the metahash application. Typically
  2 +you would include information such as the information below:
  3 +
  4 +Installation and Setup
  5 +======================
  6 +
  7 +Install ``metahash`` using easy_install::
  8 +
  9 + easy_install metahash
  10 +
  11 +Make a config file as follows::
  12 +
  13 + paster make-config metahash 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.
72 development.ini
... ... @@ -0,0 +1,72 @@
  1 +#
  2 +# metahash - 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:metahash
  20 +full_stack = true
  21 +static_files = true
  22 +
  23 +cache_dir = %(here)s/data
  24 +beaker.session.key = metahash
  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, metahash
  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_metahash]
  60 +level = DEBUG
  61 +handlers =
  62 +qualname = metahash
  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] %(message)s
  72 +datefmt = %H:%M:%S
19 docs/index.txt
... ... @@ -0,0 +1,19 @@
  1 +metahash
  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 +
10 metahash.egg-info/PKG-INFO
... ... @@ -0,0 +1,10 @@
  1 +Metadata-Version: 1.0
  2 +Name: metahash
  3 +Version: 0.1dev
  4 +Summary: UNKNOWN
  5 +Home-page: UNKNOWN
  6 +Author: UNKNOWN
  7 +Author-email: UNKNOWN
  8 +License: UNKNOWN
  9 +Description: UNKNOWN
  10 +Platform: UNKNOWN
33 metahash.egg-info/SOURCES.txt
... ... @@ -0,0 +1,33 @@
  1 +MANIFEST.in
  2 +README.txt
  3 +setup.cfg
  4 +setup.py
  5 +metahash/__init__.py
  6 +metahash/websetup.py
  7 +metahash.egg-info/PKG-INFO
  8 +metahash.egg-info/SOURCES.txt
  9 +metahash.egg-info/dependency_links.txt
  10 +metahash.egg-info/entry_points.txt
  11 +metahash.egg-info/not-zip-safe
  12 +metahash.egg-info/paster_plugins.txt
  13 +metahash.egg-info/requires.txt
  14 +metahash.egg-info/top_level.txt
  15 +metahash/config/__init__.py
  16 +metahash/config/deployment.ini_tmpl
  17 +metahash/config/environment.py
  18 +metahash/config/middleware.py
  19 +metahash/config/routing.py
  20 +metahash/controllers/__init__.py
  21 +metahash/controllers/error.py
  22 +metahash/lib/__init__.py
  23 +metahash/lib/app_globals.py
  24 +metahash/lib/base.py
  25 +metahash/lib/helpers.py
  26 +metahash/model/__init__.py
  27 +metahash/public/bg.png
  28 +metahash/public/favicon.ico
  29 +metahash/public/index.html
  30 +metahash/public/pylons-logo.gif
  31 +metahash/tests/__init__.py
  32 +metahash/tests/test_models.py
  33 +metahash/tests/functional/__init__.py
1  metahash.egg-info/dependency_links.txt
... ... @@ -0,0 +1 @@
7 metahash.egg-info/entry_points.txt
... ... @@ -0,0 +1,7 @@
  1 +
  2 + [paste.app_factory]
  3 + main = metahash.config.middleware:make_app
  4 +
  5 + [paste.app_install]
  6 + main = pylons.util:PylonsInstaller
  7 +
1  metahash.egg-info/not-zip-safe
... ... @@ -0,0 +1 @@
  1 +
2  metahash.egg-info/paster_plugins.txt
... ... @@ -0,0 +1,2 @@
  1 +PasteScript
  2 +Pylons
1  metahash.egg-info/requires.txt
... ... @@ -0,0 +1 @@
  1 +Pylons>=0.9.7
1  metahash.egg-info/top_level.txt
... ... @@ -0,0 +1 @@
  1 +metahash
0  metahash/__init__.py
No changes.
0  metahash/config/__init__.py
No changes.
60 metahash/config/deployment.ini_tmpl
... ... @@ -0,0 +1,60 @@
  1 +#
  2 +# metahash - 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:metahash
  19 +full_stack = true
  20 +static_files = true
  21 +
  22 +cache_dir = %(here)s/data
  23 +beaker.session.key = metahash
  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] %(message)s
39 metahash/config/environment.py
... ... @@ -0,0 +1,39 @@
  1 +"""Pylons environment configuration"""
  2 +import os
  3 +
  4 +from mako.lookup import TemplateLookup
  5 +from pylons import config
  6 +from pylons.error import handle_mako_error
  7 +
  8 +import metahash.lib.app_globals as app_globals
  9 +import metahash.lib.helpers
  10 +from metahash.config.routing import make_map
  11 +
  12 +def load_environment(global_conf, app_conf):
  13 + """Configure the Pylons environment via the ``pylons.config``
  14 + object
  15 + """
  16 + # Pylons paths
  17 + root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
  18 + paths = dict(root=root,
  19 + controllers=os.path.join(root, 'controllers'),
  20 + static_files=os.path.join(root, 'public'),
  21 + templates=[os.path.join(root, 'templates')])
  22 +
  23 + # Initialize config with the basic options
  24 + config.init_app(global_conf, app_conf, package='metahash', paths=paths)
  25 +
  26 + config['routes.map'] = make_map()
  27 + config['pylons.app_globals'] = app_globals.Globals()
  28 + config['pylons.h'] = metahash.lib.helpers
  29 +
  30 + # Create the Mako TemplateLookup, with the default auto-escaping
  31 + config['pylons.app_globals'].mako_lookup = TemplateLookup(
  32 + directories=paths['templates'],
  33 + error_handler=handle_mako_error,
  34 + module_directory=os.path.join(app_conf['cache_dir'], 'templates'),
  35 + input_encoding='utf-8', default_filters=['escape'],
  36 + imports=['from webhelpers.html import escape'])
  37 +
  38 + # CONFIGURATION OPTIONS HERE (note: all config options will override
  39 + # any Pylons config options)
69 metahash/config/middleware.py
... ... @@ -0,0 +1,69 @@
  1 +"""Pylons middleware initialization"""
  2 +from beaker.middleware import CacheMiddleware, 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 import config
  8 +from pylons.middleware import ErrorHandler, StatusCodeRedirect
  9 +from pylons.wsgiapp import PylonsApp
  10 +from routes.middleware import RoutesMiddleware
  11 +
  12 +from metahash.config.environment import load_environment
  13 +
  14 +def make_app(global_conf, full_stack=True, static_files=True, **app_conf):
  15 + """Create a Pylons WSGI application and return it
  16 +
  17 + ``global_conf``
  18 + The inherited configuration for this application. Normally from
  19 + the [DEFAULT] section of the Paste ini file.
  20 +
  21 + ``full_stack``
  22 + Whether this application provides a full WSGI stack (by default,
  23 + meaning it handles its own exceptions and errors). Disable
  24 + full_stack when this application is "managed" by another WSGI
  25 + middleware.
  26 +
  27 + ``static_files``
  28 + Whether this application serves its own static files; disable
  29 + when another web server is responsible for serving them.
  30 +
  31 + ``app_conf``
  32 + The application's local configuration. Normally specified in
  33 + the [app:<name>] section of the Paste ini file (where <name>
  34 + defaults to main).
  35 +
  36 + """
  37 + # Configure the Pylons environment
  38 + load_environment(global_conf, app_conf)
  39 +
  40 + # The Pylons WSGI app
  41 + app = PylonsApp()
  42 +
  43 + # Routing/Session/Cache Middleware
  44 + app = RoutesMiddleware(app, config['routes.map'])
  45 + app = SessionMiddleware(app, config)
  46 + app = CacheMiddleware(app, config)
  47 +
  48 + # CUSTOM MIDDLEWARE HERE (filtered by error handling middlewares)
  49 +
  50 + if asbool(full_stack):
  51 + # Handle Python exceptions
  52 + app = ErrorHandler(app, global_conf, **config['pylons.errorware'])
  53 +
  54 + # Display error documents for 401, 403, 404 status codes (and
  55 + # 500 when debug is disabled)
  56 + if asbool(config['debug']):
  57 + app = StatusCodeRedirect(app)
  58 + else:
  59 + app = StatusCodeRedirect(app, [400, 401, 403, 404, 500])
  60 +
  61 + # Establish the Registry for this application
  62 + app = RegistryManager(app)
  63 +
  64 + if asbool(static_files):
  65 + # Serve static files
  66 + static_app = StaticURLParser(config['pylons.paths']['static_files'])
  67 + app = Cascade([static_app, app])
  68 +
  69 + return app
26 metahash/config/routing.py
... ... @@ -0,0 +1,26 @@
  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 pylons import config
  8 +from routes import Mapper
  9 +
  10 +def make_map():
  11 + """Create, configure and return the routes Mapper"""
  12 + map = Mapper(directory=config['pylons.paths']['controllers'],
  13 + always_scan=config['debug'])
  14 + map.minimization = 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 + return map
0  metahash/controllers/__init__.py
No changes.
46 metahash/controllers/error.py
... ... @@ -0,0 +1,46 @@
  1 +import cgi
  2 +
  3 +from paste.urlparser import PkgResourcesParser
  4 +from pylons import request
  5 +from pylons.controllers.util import forward
  6 +from pylons.middleware import error_document_template
  7 +from webhelpers.html.builder import literal
  8 +
  9 +from metahash.lib.base import BaseController
  10 +
  11 +class ErrorController(BaseController):
  12 +
  13 + """Generates error documents as and when they are required.
  14 +
  15 + The ErrorDocuments middleware forwards to ErrorController when error
  16 + related status codes are returned from the application.
  17 +
  18 + This behaviour can be altered by changing the parameters to the
  19 + ErrorDocuments middleware in your config/middleware.py file.
  20 +
  21 + """
  22 +
  23 + def document(self):
  24 + """Render the error document"""
  25 + resp = request.environ.get('pylons.original_response')
  26 + content = literal(resp.body) or cgi.escape(request.GET.get('message', ''))
  27 + page = error_document_template % \
  28 + dict(prefix=request.environ.get('SCRIPT_NAME', ''),
  29 + code=cgi.escape(request.GET.get('code', str(resp.status_int))),
  30 + message=content)
  31 + return page
  32 +
  33 + def img(self, id):
  34 + """Serve Pylons' stock images"""
  35 + return self._serve_file('/'.join(['media/img', id]))
  36 +
  37 + def style(self, id):
  38 + """Serve Pylons' stock stylesheets"""
  39 + return self._serve_file('/'.join(['media/style', id]))
  40 +
  41 + def _serve_file(self, path):
  42 + """Call Paste's FileApp (a WSGI application) to serve the file
  43 + at the specified path
  44 + """
  45 + request.environ['PATH_INFO'] = '/%s' % path
  46 + return forward(PkgResourcesParser('pylons', 'pylons'))
0  metahash/lib/__init__.py
No changes.
15 metahash/lib/app_globals.py
... ... @@ -0,0 +1,15 @@
  1 +"""The application's Globals object"""
  2 +
  3 +class Globals(object):
  4 +
  5 + """Globals acts as a container for objects available throughout the
  6 + life of the application
  7 +
  8 + """
  9 +
  10 + def __init__(self):
  11 + """One instance of Globals is created during application
  12 + initialization and is available during requests via the
  13 + 'app_globals' variable
  14 +
  15 + """
15 metahash/lib/base.py
... ... @@ -0,0 +1,15 @@
  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_mako as render
  7 +
  8 +class BaseController(WSGIController):
  9 +
  10 + def __call__(self, environ, start_response):
  11 + """Invoke the Controller"""
  12 + # WSGIController.__call__ dispatches to the Controller method
  13 + # the request is routed to. This routing information is
  14 + # available in environ['pylons.routes_dict']
  15 + return WSGIController.__call__(self, environ, start_response)
7 metahash/lib/helpers.py
... ... @@ -0,0 +1,7 @@
  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.tags import checkbox, password
0  metahash/model/__init__.py
No changes.
BIN  metahash/public/bg.png
BIN  metahash/public/favicon.ico
Binary file not shown
137 metahash/public/index.html
... ... @@ -0,0 +1,137 @@
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<!DOCTYPE html
  3 + PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  4 + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  5 +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  6 + <head>
  7 + <title>Welcome to Pylons!</title>
  8 + <style type="text/css">
  9 + body {
  10 + font-family: arial, helvetica, sans-serif;
  11 + background-color: #ffc900;
  12 + background-image: url(bg.png);
  13 + background-repeat: repeat-x;
  14 + width:100%;
  15 + height:100%;
  16 + margin:0;
  17 + max-height: 100%;
  18 + padding:0;
  19 + border:none;
  20 + line-height:1.4;
  21 + }
  22 + #container {
  23 + color:white;
  24 + background-color:#111;
  25 + position: absolute;
  26 + left: 50%;
  27 + width: 500px;
  28 + margin-left: -300px;
  29 + padding:50px;
  30 + height:100%;
  31 + }
  32 + #footer {
  33 + margin: 120px 0 0 0;
  34 + padding: 3px;
  35 + text-align:center;
  36 + font-size:small;
  37 + background-color:#222;
  38 + letter-spacing: 1px;
  39 + }
  40 + h1 {
  41 + text-align:center;
  42 + font-size:xx-large;
  43 + font-weight:normal;
  44 + margin: 0 0 20px 0;
  45 + border:none;
  46 + padding:0;
  47 + letter-spacing: 5px;
  48 + }
  49 + h2 {
  50 + font-size:xx-large;
  51 + font-weight:normal;
  52 + margin: 0 0 20px 0;
  53 + border:none;
  54 + padding:0;
  55 + }
  56 + hr {
  57 + margin-bottom:30px;
  58 + border: 1px solid #222;
  59 + background-color: #222;
  60 + padding: 2px;
  61 + }
  62 + #logo {
  63 + background-image: url(signum8b_spk.png);
  64 + background-repeat: no-repeat;
  65 + height: 0;
  66 + overflow: hidden;
  67 + padding-top: 99px;
  68 + width: 239px;
  69 + }
  70 + #left {
  71 + float:left;
  72 + width:250px;
  73 + margin:0 50px 0 0;
  74 + border:none;
  75 + padding:0 0 0 10px;
  76 + }
  77 + #right {
  78 + margin:0 0 0 330px;
  79 + border:none;
  80 + padding:0;
  81 + }
  82 + ul {
  83 + list-style:none;
  84 + margin:0;
  85 + border:none;
  86 + padding:0;
  87 + }
  88 + a:visited {
  89 + color:white;
  90 + text-decoration:none;
  91 + }
  92 + a:link {
  93 + color:white;
  94 + text-decoration:none;
  95 + }</style>
  96 + </head>
  97 + <body>
  98 + <div id="container">
  99 + <h1>Welcome to <img src="pylons-logo.gif" alt="Logo displaying the word Pylons"
  100 + style="vertical-align:-15px; width: 250px;"/>
  101 + </h1>
  102 + <hr/>
  103 + <div id="left">
  104 + <h2>Let's begin!</h2>
  105 + <p>If you haven't used Pylons before, start with the <a href="http://pylonshq.com/docs/en/0.9.7/gettingstarted/"
  106 + style="text-decoration:underline;">beginners' tutorial</a>.</p>
  107 + </div>
  108 + <div id="right">
  109 + <h2>Help</h2>
  110 + <ul>
  111 + <li>
  112 + <a href="http://pylonshq.com/docs/en/0.9.7/">Official documentation</a>
  113 + </li>
  114 + <li>
  115 + <a href="http://wiki.pylonshq.com/display/pylonsfaq/Home">FAQ</a>
  116 + </li>
  117 + <li>
  118 + <a href="http://wiki.pylonshq.com/dashboard.action">Wiki</a>
  119 + </li>
  120 + <li>
  121 + <a href="http://wiki.pylonshq.com/display/pylonscommunity/Home#Home-JointheMailingLists">Mailing list</a>
  122 + </li>
  123 + <li>
  124 + <a href="http://wiki.pylonshq.com/display/pylonscommunity/Home#Home-IRC">IRC</a>
  125 + </li>
  126 + <li>
  127 + <a href="http://pylonshq.com/project/pylonshq/roadmap">Bug tracker</a>
  128 + </li>
  129 + </ul>
  130 + </div>
  131 + <div id="footer">
  132 + <a href="http://www.pylonshq.com" style="color: #ccc; text-decoration:none;"
  133 + >www.pylonshq.com</a>
  134 + </div>
  135 + </div>
  136 + </body>
  137 +</html>
BIN  metahash/public/pylons-logo.gif
36 metahash/tests/__init__.py
... ... @@ -0,0 +1,36 @@
  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 config, 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([config['__file__']])
  24 +
  25 +environ = {}
  26 +
  27 +class TestController(TestCase):
  28 +
  29 + def __init__(self, *args, **kwargs):
  30 + if pylons.test.pylonsapp:
  31 + wsgiapp = pylons.test.pylonsapp
  32 + else:
  33 + wsgiapp = loadapp('config:%s' % config['__file__'])
  34 + self.app = TestApp(wsgiapp)
  35 + url._push_object(URLGenerator(config['routes.map'], environ))
  36 + TestCase.__init__(self, *args, **kwargs)
0  metahash/tests/functional/__init__.py
No changes.
0  metahash/tests/test_models.py
No changes.
10 metahash/websetup.py
... ... @@ -0,0 +1,10 @@
  1 +"""Setup the metahash application"""
  2 +import logging
  3 +
  4 +from metahash.config.environment import load_environment
  5 +
  6 +log = logging.getLogger(__name__)
  7 +
  8 +def setup_app(command, conf, vars):
  9 + """Place any commands to setup metahash here"""
  10 + load_environment(conf.global_conf, conf.local_conf)
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 = metahash
  14 +directory = metahash/i18n
  15 +statistics = true
  16 +
  17 +[extract_messages]
  18 +add_comments = TRANSLATORS:
  19 +output_file = metahash/i18n/metahash.pot
  20 +width = 80
  21 +
  22 +[init_catalog]
  23 +domain = metahash
  24 +input_file = metahash/i18n/metahash.pot
  25 +output_dir = metahash/i18n
  26 +
  27 +[update_catalog]
  28 +domain = metahash
  29 +input_file = metahash/i18n/metahash.pot
  30 +output_dir = metahash/i18n
  31 +previous = true
36 setup.py
... ... @@ -0,0 +1,36 @@
  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='metahash',
  10 + version='0.1',
  11 + description='',
  12 + author='',
  13 + author_email='',
  14 + url='',
  15 + install_requires=[
  16 + "Pylons>=0.9.7",
  17 + ],
  18 + setup_requires=["PasteScript>=1.6.3"],
  19 + packages=find_packages(exclude=['ez_setup']),
  20 + include_package_data=True,
  21 + test_suite='nose.collector',
  22 + package_data={'metahash': ['i18n/*/LC_MESSAGES/*.mo']},
  23 + #message_extractors={'metahash': [
  24 + # ('**.py', 'python', None),
  25 + # ('templates/**.mako', 'mako', {'input_encoding': 'utf-8'}),
  26 + # ('public/**', 'ignore', None)]},
  27 + zip_safe=False,
  28 + paster_plugins=['PasteScript', 'Pylons'],
  29 + entry_points="""
  30 + [paste.app_factory]
  31 + main = metahash.config.middleware:make_app
  32 +
  33 + [paste.app_install]
  34 + main = pylons.util:PylonsInstaller
  35 + """,
  36 +)
21 test.ini
... ... @@ -0,0 +1,21 @@
  1 +#
  2 +# metahash - 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 comments on commit 703aad5

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