Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

attempted to add some docs to the ini file #357

Closed
wants to merge 3 commits into from

2 participants

@mmerickel
Owner

Is something along these lines interesting? If so I can explore it further. I noticed Pyramid doesn't really document the server runner itself either, and the PasteDeploy docs kind of suck for it. This becomes important now that 1.3 ships with wsgiref as the default instead of something "production ready".

@mcdonc
Owner

Yeah these are interesting. It would be best if the URLs could be divined from the version, though, I think. I'll never remember to change them.

@mcdonc
Owner

At least the URLs to Pyramid docs, I mean.. the URLs to toolbar and other docs, who knows.

@mmerickel
Owner

Updated this to autogenerate the URLs for fun. I think it's more important that we fix RTD to point "latest" at the stable branch, not the master docs and then just set the URL at latest or something.

@mmerickel
Owner

closing, replaced by #706

@mmerickel mmerickel closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 22, 2011
  1. @mmerickel
Commits on Mar 13, 2012
  1. @mmerickel

    Merge branch '1.3-branch' into feature.scaffold-comments

    mmerickel authored
    Conflicts:
    	pyramid/scaffolds/starter/development.ini_tmpl
  2. @mmerickel
This page is out of date. Refresh to see the latest.
View
48 pyramid/scaffolds/__init__.py
@@ -40,17 +40,65 @@ def post(self, command, output_dir, vars): # pragma: no cover
def out(self, msg): # pragma: no cover (replaceable testing hook)
print(msg)
+
+_DEBUGTOOLBAR_URL_FMT = ('http://docs.pylonsproject.org/projects/'
+ 'pyramid_debugtoolbar/en/%(version)s/#settings')
+_LOGGING_URL_FMT = ('http://docs.pylonsproject.org/projects/'
+ 'pyramid/en/%(version)s/narr/logging.html')
+_SETTINGS_URL_FMT = ('http://docs.pylonsproject.org/projects/'
+ 'pyramid/en/%(version)s/narr/environment.html')
+
+def _get_version(name, pkg_resources=None):
+ """ Get the version of a package or None."""
+ try:
+ if pkg_resources is None: # pragma: no cover
+ import pkg_resources
+ pkg = pkg_resources.get_distribution(name)
+ return pkg.parsed_version
+ except (ImportError, ValueError):
+ pass
+
+def _make_pylons_link(name, pkg_resources=None):
+ """ Create a link to the pyramid documentation."""
+ v = _get_version(name, pkg_resources=pkg_resources)
+ try:
+ return '%s.%s-branch' % (int(v[0]), int(v[1]))
+ except:
+ return 'latest'
+
+def _add_ini_urls(vars, pkg_resources=None):
+ """ Add some basic URLs to the template vars for use in INI comments."""
+ pyramid_version = _make_pylons_link('pyramid', pkg_resources=pkg_resources)
+ debugtoolbar_version = 'latest'
+ vars['settings_url'] = _SETTINGS_URL_FMT % {'version': pyramid_version}
+ vars['logging_url'] = _LOGGING_URL_FMT % {'version': pyramid_version}
+ vars['debugtoolbar_url'] = _DEBUGTOOLBAR_URL_FMT % {'version':
+ debugtoolbar_version}
+
class StarterProjectTemplate(PyramidTemplate):
_template_dir = 'starter'
summary = 'Pyramid starter project'
+ def pre(self, command, output_dir, vars):
+ _add_ini_urls(vars)
+ return PyramidTemplate.pre(self, command, output_dir, vars)
+
class ZODBProjectTemplate(PyramidTemplate):
_template_dir = 'zodb'
summary = 'Pyramid ZODB project using traversal'
+ def pre(self, command, output_dir, vars):
+ _add_ini_urls(vars)
+ return PyramidTemplate.pre(self, command, output_dir, vars)
+
class AlchemyProjectTemplate(PyramidTemplate):
_template_dir = 'alchemy'
summary = 'Pyramid SQLAlchemy project using url dispatch'
+
+ def pre(self, command, output_dir, vars):
+ _add_ini_urls(vars)
+ return PyramidTemplate.pre(self, command, output_dir, vars)
+
def post(self, command, output_dir, vars): # pragma: no cover
val = PyramidTemplate.post(self, command, output_dir, vars)
vars = vars.copy()
View
21 pyramid/scaffolds/alchemy/development.ini_tmpl
@@ -1,6 +1,11 @@
[app:main]
use = egg:{{project}}
+###
+# pyramid debugging
+# {{settings_url}}
+###
+
pyramid.reload_templates = true
pyramid.debug_authorization = false
pyramid.debug_notfound = false
@@ -13,12 +18,24 @@ pyramid.includes =
sqlalchemy.url = sqlite:///%(here)s/{{project}}.db
+###
+# debugtoolbar settings
+# {{debugtoolbar_url}}
+###
+
+# By default, the toolbar only appears for clients from IP addresses
+# '127.0.0.1' and '::1'.
+# debugtoolbar.hosts = 127.0.0.1 ::1
+
[server:main]
use = egg:waitress#main
host = 0.0.0.0
port = 6543
-# Begin logging configuration
+###
+# logging configuration
+# {{logging_url}}
+###
[loggers]
keys = root, {{package_logger}}, sqlalchemy
@@ -54,5 +71,3 @@ formatter = generic
[formatter_generic]
format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s
-
-# End logging configuration
View
12 pyramid/scaffolds/alchemy/production.ini_tmpl
@@ -1,6 +1,11 @@
[app:main]
use = egg:{{project}}
+###
+# pyramid debugging
+# {{settings_url}}
+###
+
pyramid.reload_templates = false
pyramid.debug_authorization = false
pyramid.debug_notfound = false
@@ -17,7 +22,10 @@ use = egg:waitress#main
host = 0.0.0.0
port = 6543
-# Begin logging configuration
+###
+# logging configuration
+# {{logging_url}}
+###
[loggers]
keys = root, {{package_logger}}, sqlalchemy
@@ -53,5 +61,3 @@ formatter = generic
[formatter_generic]
format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s
-
-# End logging configuration
View
21 pyramid/scaffolds/starter/development.ini_tmpl
@@ -1,6 +1,11 @@
[app:main]
use = egg:{{project}}
+###
+# pyramid debugging
+# {{settings_url}}
+###
+
pyramid.reload_templates = true
pyramid.debug_authorization = false
pyramid.debug_notfound = false
@@ -10,12 +15,24 @@ pyramid.default_locale_name = en
pyramid.includes =
pyramid_debugtoolbar
+###
+# debugtoolbar settings
+# {{debugtoolbar_url}}
+###
+
+# By default, the toolbar only appears for clients from IP addresses
+# '127.0.0.1' and '::1'.
+# debugtoolbar.hosts = 127.0.0.1 ::1
+
[server:main]
use = egg:waitress#main
host = 0.0.0.0
port = 6543
-# Begin logging configuration
+###
+# logging configuration
+# {{logging_url}}
+###
[loggers]
keys = root, {{package_logger}}
@@ -43,5 +60,3 @@ formatter = generic
[formatter_generic]
format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s
-
-# End logging configuration
View
12 pyramid/scaffolds/starter/production.ini_tmpl
@@ -1,6 +1,11 @@
[app:main]
use = egg:{{project}}
+###
+# pyramid debugging
+# {{settings_url}}
+###
+
pyramid.reload_templates = false
pyramid.debug_authorization = false
pyramid.debug_notfound = false
@@ -13,7 +18,10 @@ use = egg:waitress#main
host = 0.0.0.0
port = 6543
-# Begin logging configuration
+###
+# logging configuration
+# {{logging_url}}
+###
[loggers]
keys = root, {{package_logger}}
@@ -41,5 +49,3 @@ formatter = generic
[formatter_generic]
format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s
-
-# End logging configuration
View
21 pyramid/scaffolds/zodb/development.ini_tmpl
@@ -1,6 +1,11 @@
[app:main]
use = egg:{{project}}
+###
+# pyramid debugging
+# {{settings_url}}
+###
+
pyramid.reload_templates = true
pyramid.debug_authorization = false
pyramid.debug_notfound = false
@@ -15,12 +20,24 @@ pyramid.includes =
tm.attempts = 3
zodbconn.uri = file://%(here)s/Data.fs?connection_cache_size=20000
+###
+# debugtoolbar settings
+# {{debugtoolbar_url}}
+###
+
+# By default, the toolbar only appears for clients from IP addresses
+# '127.0.0.1' and '::1'.
+# debugtoolbar.hosts = 127.0.0.1 ::1
+
[server:main]
use = egg:waitress#main
host = 0.0.0.0
port = 6543
-# Begin logging configuration
+###
+# logging configuration
+# {{logging_url}}
+###
[loggers]
keys = root, {{package_logger}}
@@ -48,5 +65,3 @@ formatter = generic
[formatter_generic]
format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s
-
-# End logging configuration
View
12 pyramid/scaffolds/zodb/production.ini_tmpl
@@ -1,6 +1,11 @@
[app:main]
use = egg:{{project}}
+###
+# pyramid debugging
+# {{settings_url}}
+###
+
pyramid.reload_templates = false
pyramid.debug_authorization = false
pyramid.debug_notfound = false
@@ -19,7 +24,10 @@ use = egg:waitress#main
host = 0.0.0.0
port = 6543
-# Begin logging configuration
+###
+# logging configuration
+# {{logging_url}}
+###
[loggers]
keys = root, {{package_logger}}
@@ -47,5 +55,3 @@ formatter = generic
[formatter_generic]
format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s
-
-# End logging configuration
View
51 pyramid/tests/test_scaffolds/test_init.py
@@ -24,3 +24,54 @@ def test_pre_root(self):
self.assertTrue(vars['random_string'])
self.assertEqual(vars['package_logger'], 'app')
+class TestINIURLs(unittest.TestCase):
+
+ def test_it(self):
+ from pyramid.scaffolds import _add_ini_urls
+ vars = {}
+ pkg_resources = DummyPkgResources({'pyramid': DummyDistribution()})
+ _add_ini_urls(vars, pkg_resources=pkg_resources)
+ self.assertEqual(
+ vars['settings_url'],
+ ('http://docs.pylonsproject.org/projects/'
+ 'pyramid/en/1.3-branch/narr/environment.html'))
+ self.assertEqual(
+ vars['logging_url'],
+ ('http://docs.pylonsproject.org/projects/'
+ 'pyramid/en/1.3-branch/narr/logging.html'))
+ self.assertEqual(
+ vars['debugtoolbar_url'],
+ ('http://docs.pylonsproject.org/projects/'
+ 'pyramid_debugtoolbar/en/latest/#settings'))
+
+ def test_it_failover(self):
+ from pyramid.scaffolds import _add_ini_urls
+ vars = {}
+ class _dist(object):
+ @property
+ def parsed_version(self):
+ raise ValueError
+ pkg_resources = DummyPkgResources({'pyramid': _dist})
+ _add_ini_urls(vars, pkg_resources=pkg_resources)
+ self.assertEqual(
+ vars['settings_url'],
+ ('http://docs.pylonsproject.org/projects/'
+ 'pyramid/en/latest/narr/environment.html'))
+ self.assertEqual(
+ vars['logging_url'],
+ ('http://docs.pylonsproject.org/projects/'
+ 'pyramid/en/latest/narr/logging.html'))
+ self.assertEqual(
+ vars['debugtoolbar_url'],
+ ('http://docs.pylonsproject.org/projects/'
+ 'pyramid_debugtoolbar/en/latest/#settings'))
+
+class DummyDistribution(object):
+ parsed_version = ('00000001', '00000003', '*b', '00000002', '*final')
+
+class DummyPkgResources(object):
+ def __init__(self, dists):
+ self.dists = dists
+
+ def get_distribution(self, name):
+ return self.dists[name]
Something went wrong with that request. Please try again.