Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

simplify actioninfo interface; fix actioninfos passed as tuple via _info

  • Loading branch information...
commit 4a4ef4f7ac6d94e00b6beb2a97472ed6d7bdddd8 1 parent 7d109d6
@mcdonc mcdonc authored
View
6 TODO.txt
@@ -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.
View
16 pyramid/config/util.py
@@ -26,20 +26,15 @@
@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 wrapper(self, *arg, **kw):
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)
View
9 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
View
1  pyramid/registry.py
@@ -243,5 +243,4 @@ def register(self, introspector, action_info):
(category_name, discriminator)
)
-
global_registry = Registry('global')
View
2  pyramid/tests/test_config/test_init.py
@@ -976,7 +976,7 @@ def scanconflicts(e):
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)
View
8 pyramid/tests/test_config/test_util.py
@@ -331,11 +331,11 @@ def test_instance_conforms(self):
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 ')
Please sign in to comment.
Something went wrong with that request. Please try again.