Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

make zcml compatible with (only) pyramid 1.3, new docs regime, new se…

…tup.py aliases
  • Loading branch information...
commit 7a72bc3eceb748ced7fe75ec22ddfe92d288a904 1 parent 24429c1
@mcdonc mcdonc authored
View
3  CHANGES.txt
@@ -10,6 +10,9 @@ Unreleased
- Add tox.ini for Jenkins testing.
+- ZCML directive no longer compatible with Pyramid 1.0, 1.1, 1.2. Only 1.3
+ supported. Also requires pyramid_zcml 0.9.2 or better.
+
0.2 (2011-03-23)
----------------
View
1  docs/.gitignore
@@ -0,0 +1 @@
+_themes/
View
23 docs/Makefile
@@ -2,7 +2,7 @@
#
# You can set these variables from the command line.
-SPHINXOPTS =
+SPHINXOPTS = -W
SPHINXBUILD = sphinx-build
PAPER =
@@ -25,12 +25,18 @@ help:
clean:
-rm -rf _build/*
-html: _themes
+html:
mkdir -p _build/html _build/doctrees
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) _build/html
@echo
@echo "Build finished. The HTML pages are in _build/html."
+text:
+ mkdir -p _build/text _build/doctrees
+ $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) _build/text
+ @echo
+ @echo "Build finished. The HTML pages are in _build/text."
+
pickle:
mkdir -p _build/pickle _build/doctrees
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) _build/pickle
@@ -41,7 +47,7 @@ pickle:
web: pickle
-htmlhelp: _themes
+htmlhelp:
mkdir -p _build/htmlhelp _build/doctrees
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) _build/htmlhelp
@echo
@@ -51,6 +57,10 @@ htmlhelp: _themes
latex:
mkdir -p _build/latex _build/doctrees
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) _build/latex
+ cp _static/*.png _build/latex
+ ./convert_images.sh
+ cp _static/latex-warning.png _build/latex
+ cp _static/latex-note.png _build/latex
@echo
@echo "Build finished; the LaTeX files are in _build/latex."
@echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
@@ -69,5 +79,8 @@ linkcheck:
@echo "Link check complete; look for any errors in the above output " \
"or in _build/linkcheck/output.txt."
-_themes:
- cd ..; git submodule update --init; cd docs
+epub:
+ $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) _build/epub
+ @echo
+ @echo "Build finished. The epub file is in _build/epub."
+
View
42 docs/conf.py
@@ -19,16 +19,33 @@
# make it absolute, like shown here.
#sys.path.append(os.path.abspath('some/directory'))
-parent = os.path.dirname(os.path.dirname(__file__))
-sys.path.append(os.path.abspath(parent))
-wd = os.getcwd()
-os.chdir(parent)
-os.system('%s setup.py test -q' % sys.executable)
-os.chdir(wd)
-for item in os.listdir(parent):
- if item.endswith('.egg'):
- sys.path.append(os.path.join(parent, item))
+# Add and use Pylons theme
+if 'sphinx-build' in ' '.join(sys.argv): # protect against dumb importers
+ from subprocess import call, Popen, PIPE
+
+ p = Popen('which git', shell=True, stdout=PIPE)
+ git = p.stdout.read().strip()
+ cwd = os.getcwd()
+ _themes = os.path.join(cwd, '_themes')
+
+ if not os.path.isdir(_themes):
+ call([git, 'clone', 'git://github.com/Pylons/pylons_sphinx_theme.git',
+ '_themes'])
+ else:
+ os.chdir(_themes)
+ call([git, 'checkout', 'master'])
+ call([git, 'pull'])
+ os.chdir(cwd)
+
+ sys.path.append(os.path.abspath('_themes'))
+
+html_theme_path = ['_themes']
+html_theme = 'pyramid'
+html_theme_options = dict(
+ github_url='https://github.com/Pylons/pyramid_who',
+# in_progress='true'
+ )
# General configuration
# ---------------------
@@ -71,6 +88,8 @@
# searched for source files.
#exclude_dirs = []
+exclude_patterns = ['_themes/README.rst',]
+
# The reST default role (used for this markup: `text`) to use for all
# documents.
#default_role = None
@@ -93,11 +112,6 @@
# Options for HTML output
# -----------------------
-# Add and use Pylons theme
-sys.path.append(os.path.abspath('_themes'))
-html_theme_path = ['_themes']
-html_theme = 'pyramid'
-
# The style sheet to use for HTML and HTML Help pages. A file of that name
# must exist either in Sphinx' static/ path, or in one of the custom paths
# given in html_static_path.
View
55 pyramid_who/tests/test_zcml.py
@@ -1,14 +1,13 @@
import unittest
-class TestRepozeWhowAuthenticationPolicyDirective(unittest.TestCase):
+class TestRepozeWhoAuthenticationPolicyDirective(unittest.TestCase):
_tempdir = None
def setUp(self):
from pyramid.testing import setUp
self.config = setUp(autocommit=False)
- self.config._ctx = self.config._make_context()
def tearDown(self):
from pyramid.testing import tearDown
@@ -44,51 +43,55 @@ def _callFUT(self, context,
def test_it_defaults(self):
from pyramid.interfaces import IAuthenticationPolicy
from pyramid_who.whov2 import _null_callback
- reg = self.config.registry
- context = self.config._ctx
+ self.config._set_authorization_policy(object())
+ context = DummyZCMLContext(self.config)
self._callFUT(context)
- actions = extract_actions(context.actions)
+ actions = context.actions
self.assertEqual(len(actions), 1)
regadapt = actions[0]
self.assertEqual(regadapt['discriminator'], IAuthenticationPolicy)
- self.assertEqual(regadapt['callable'], None)
self.assertEqual(regadapt['args'], ())
+ regadapt['callable']()
+ reg = self.config.registry
policy = reg.getUtility(IAuthenticationPolicy)
self.assertEqual(policy._identifier_id, 'IDENTIFIER')
self.assertEqual(policy._callback, _null_callback)
def test_it(self):
- reg = self.config.registry
from pyramid.interfaces import IAuthenticationPolicy
- context = self.config._ctx
+ context = DummyZCMLContext(self.config)
+ self.config._set_authorization_policy(object())
def _callback(identity, request):
""" """ # hide from coverage
config_file = self._makeWhoConfig('firstbase.ini')
- self._callFUT(context, config_file,
- 'something', _callback)
- actions = extract_actions(context.actions)
+ self._callFUT(context, config_file, 'something', _callback)
+ actions = context.actions
self.assertEqual(len(actions), 1)
regadapt = actions[0]
self.assertEqual(regadapt['discriminator'], IAuthenticationPolicy)
- self.assertEqual(regadapt['callable'], None)
self.assertEqual(regadapt['args'], ())
+ regadapt['callable']()
+ reg = self.config.registry
policy = reg.getUtility(IAuthenticationPolicy)
self.assertEqual(policy._config_file, config_file)
self.assertEqual(policy._identifier_id, 'something')
self.assertEqual(policy._callback, _callback)
+from pyramid.config import Configurator
+
+class DummyZCMLContext(object):
+ config_class = Configurator
+ introspection = False
+ def __init__(self, config):
+ self.registry = config.registry
+ self.package = config.package
+ self.autocommit = config.autocommit
+ self.route_prefix = getattr(config, 'route_prefix', None)
+ self.basepath = getattr(config, 'basepath', None)
+ self.includepath = getattr(config, 'includepath', ())
+ self.info = getattr(config, 'info', '')
+ self.actions = config._ctx.actions
+ self._ctx = config._ctx
-def extract_actions(native):
- from zope.configuration.config import expand_action
- L = []
- for action in native:
- (discriminator, callable, args, kw, includepath, info, order
- ) = expand_action(*action)
- d = {}
- d['discriminator'] = discriminator
- d['callable'] = callable
- d['args'] = args
- d['kw'] = kw
- d['order'] = order
- L.append(d)
- return L
+ def action(self, *arg, **kw): # pragma: no cover
+ self._ctx.action(*arg, **kw)
View
9 pyramid_who/zcml.py
@@ -3,10 +3,8 @@
from zope.schema import ASCIILine
from zope.schema import TextLine
-from pyramid.config import Configurator
from pyramid_who.whov2 import WhoV2AuthenticationPolicy
-
class IRepozeWho2AuthenticationPolicyDirective(Interface):
config_file = ASCIILine(title=u'config_file', required=True)
identifier_name = TextLine(title=u'identitfier_name', required=True)
@@ -22,7 +20,6 @@ def repozewho2authenticationpolicy(_context,
else:
policy = WhoV2AuthenticationPolicy(config_file, identifier_name,
callback=callback)
- # authentication policies must be registered eagerly so they can
- # be found by the view registration machinery
- config = Configurator.with_context(_context)
- config._set_authentication_policy(policy)
+ from pyramid_zcml import with_context
+ config = with_context(_context)
+ config.set_authentication_policy(policy)
View
1  setup.cfg
@@ -10,3 +10,4 @@ cover-erase=1
[aliases]
dev = develop easy_install pyramid_who[zcml] pyramid_who[testing]
+docs = develop easy_install pyramid_who[docs]
View
1  setup.py
@@ -55,5 +55,6 @@
extras_require = {
'zcml': 'pyramid_zcml',
'testing': ['nose', 'coverage'],
+ 'docs':['Sphinx'],
},
)
Please sign in to comment.
Something went wrong with that request. Please try again.