/usr/lib/python2.7/dist-packages/pyramid/scaffolds/__init__.py is in python-pyramid 1.4.5+dfsg-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | import binascii
import os
from textwrap import dedent
from pyramid.compat import native_
from pyramid.scaffolds.template import Template # API
class PyramidTemplate(Template):
"""
A class that can be used as a base class for Pyramid scaffolding
templates.
"""
def pre(self, command, output_dir, vars):
""" Overrides :meth:`pyramid.scaffold.template.Template.pre`, adding
several variables to the default variables list (including
``random_string``, and ``package_logger``). It also prevents common
misnamings (such as naming a package "site" or naming a package
logger "root".
"""
if vars['package'] == 'site':
raise ValueError('Sorry, you may not name your package "site". '
'The package name "site" has a special meaning in '
'Python. Please name it anything except "site".')
vars['random_string'] = native_(binascii.hexlify(os.urandom(20)))
package_logger = vars['package']
if package_logger == 'root':
# Rename the app logger in the rare case a project is named 'root'
package_logger = 'app'
vars['package_logger'] = package_logger
return Template.pre(self, command, output_dir, vars)
def post(self, command, output_dir, vars): # pragma: no cover
""" Overrides :meth:`pyramid.scaffold.template.Template.post`, to
print "Welcome to Pyramid. Sorry for the convenience." after a
successful scaffolding rendering."""
separator = "=" * 79
msg = dedent(
"""
%(separator)s
Tutorials: http://docs.pylonsproject.org/projects/pyramid_tutorials
Documentation: http://docs.pylonsproject.org/projects/pyramid
Twitter (tips & updates): http://twitter.com/pylons
Mailing List: http://groups.google.com/group/pylons-discuss
Welcome to Pyramid. Sorry for the convenience.
%(separator)s
""" % {'separator': separator})
self.out(msg)
return Template.post(self, command, output_dir, vars)
def out(self, msg): # pragma: no cover (replaceable testing hook)
print(msg)
class StarterProjectTemplate(PyramidTemplate):
_template_dir = 'starter'
summary = 'Pyramid starter project'
class ZODBProjectTemplate(PyramidTemplate):
_template_dir = 'zodb'
summary = 'Pyramid ZODB project using traversal'
class AlchemyProjectTemplate(PyramidTemplate):
_template_dir = 'alchemy'
summary = 'Pyramid SQLAlchemy project using url dispatch'
|