diff options
| author | Chris McDonough <chrism@plope.com> | 2011-12-04 19:11:14 -0500 |
|---|---|---|
| committer | Chris McDonough <chrism@plope.com> | 2011-12-04 19:11:14 -0500 |
| commit | 4a4ef4f7ac6d94e00b6beb2a97472ed6d7bdddd8 (patch) | |
| tree | 4472f52f050c0ca4a445326dc68d0a578c3be95e | |
| parent | 7d109d6522353bf5f5f3ca4f29bc2b27542f2ef2 (diff) | |
| download | pyramid-4a4ef4f7ac6d94e00b6beb2a97472ed6d7bdddd8.tar.gz pyramid-4a4ef4f7ac6d94e00b6beb2a97472ed6d7bdddd8.tar.bz2 pyramid-4a4ef4f7ac6d94e00b6beb2a97472ed6d7bdddd8.zip | |
simplify actioninfo interface; fix actioninfos passed as tuple via _info
| -rw-r--r-- | TODO.txt | 6 | ||||
| -rw-r--r-- | pyramid/config/util.py | 16 | ||||
| -rw-r--r-- | pyramid/interfaces.py | 9 | ||||
| -rw-r--r-- | pyramid/registry.py | 1 | ||||
| -rw-r--r-- | pyramid/tests/test_config/test_init.py | 2 | ||||
| -rw-r--r-- | pyramid/tests/test_config/test_util.py | 8 |
6 files changed, 17 insertions, 25 deletions
@@ -6,12 +6,16 @@ Must-Have - Introspection: - * Narrative docs. + * Why do translation directories report weird actioninfo? + + * Review narrative docs. * ``default root factory`` category? * ``default view mapper`` category? + * get rid of "tweens" category (can't sort properly?) + * implement ptweens and proutes based on introspection instead of current state of affairs. diff --git a/pyramid/config/util.py b/pyramid/config/util.py index 81c5d8176..3a2f911dc 100644 --- a/pyramid/config/util.py +++ b/pyramid/config/util.py @@ -26,20 +26,15 @@ DEFAULT_PHASH = md5().hexdigest() @implementer(IActionInfo) class ActionInfo(object): def __init__(self, file, line, function, src): - line = line or 0 - src = src or '' - srclines = src.split('\n') - src = '\n'.join(' %s' % x for x in srclines) - self._src = src self.file = file self.line = line - self.column = None - self.eline = None - self.ecolumn = None self.function = function + self.src = src def __str__(self): - return 'Line %s of file %s:\n%s' % (self.line, self.file, self._src) + srclines = self.src.split('\n') + src = '\n'.join(' %s' % x for x in srclines) + return 'Line %s of file %s:\n%s' % (self.line, self.file, src) def action_method(wrapped): """ Wrapper to provide the right conflict info report data when a method @@ -48,6 +43,9 @@ def action_method(wrapped): if self._ainfo is None: self._ainfo = [] info = kw.pop('_info', None) + if is_nonstr_iter(info) and len(info) == 4: + # _info permitted as extract_stack tuple + info = ActionInfo(*info) if info is None: try: f = traceback.extract_stack(limit=3) diff --git a/pyramid/interfaces.py b/pyramid/interfaces.py index c656c3510..0261ae3db 100644 --- a/pyramid/interfaces.py +++ b/pyramid/interfaces.py @@ -1008,15 +1008,6 @@ class IActionInfo(Interface): line = Attribute( 'Starting line number in file (as an integer) of action-invoking code.' 'This will be ``None`` if the value could not be determined.') - column = Attribute( - 'Starting column number in file (as an integer) of action-invoking ' - 'code. This will be ``None`` if the value could not be determined.') - eline = Attribute( - 'Ending line number in file (as an integer) of action-invoking code.' - 'This will be ``None`` if the value could not be determined.') - ecolumn = Attribute( - 'Ending column number in file (as an integer) of action-invoking code.' - 'This will be ``None`` if the value could not be determined.') def __str__(): """ Return a representation of the action information (including diff --git a/pyramid/registry.py b/pyramid/registry.py index d594ae910..7e373b58a 100644 --- a/pyramid/registry.py +++ b/pyramid/registry.py @@ -243,5 +243,4 @@ class Introspectable(dict): (category_name, discriminator) ) - global_registry = Registry('global') diff --git a/pyramid/tests/test_config/test_init.py b/pyramid/tests/test_config/test_init.py index c2b63dfc0..17dacdc5b 100644 --- a/pyramid/tests/test_config/test_init.py +++ b/pyramid/tests/test_config/test_init.py @@ -976,7 +976,7 @@ pyramid.tests.test_config.dummy_include2""", conflicts = e._conflicts.values() for conflict in conflicts: for confinst in conflict: - yield confinst[3] + yield confinst.src which = list(scanconflicts(why)) self.assertEqual(len(which), 4) self.assertTrue("@view_config(renderer='string')" in which) diff --git a/pyramid/tests/test_config/test_util.py b/pyramid/tests/test_config/test_util.py index 12d3055d0..1180e7e29 100644 --- a/pyramid/tests/test_config/test_util.py +++ b/pyramid/tests/test_config/test_util.py @@ -331,11 +331,11 @@ class TestActionInfo(unittest.TestCase): verifyObject(IActionInfo, self._makeOne('f', 0, 'f', 'f')) def test_ctor(self): - inst = self._makeOne('filename', 10, 'function', ' linerepr\n\nfoo') + inst = self._makeOne('filename', 10, 'function', 'src') + self.assertEqual(inst.file, 'filename') self.assertEqual(inst.line, 10) - self.assertEqual(inst.column, None) - self.assertEqual(inst.eline, None) - self.assertEqual(inst.ecolumn, None) + self.assertEqual(inst.function, 'function') + self.assertEqual(inst.src, 'src') def test___str__(self): inst = self._makeOne('filename', 0, 'function', ' linerepr ') |
