On Tue, Feb 17, 2009 at 3:47 PM, chris van <[email protected]> wrote: > Thanks for the response Mike, > > I used print only as an example, my actual application code doesn't use > print at all. I replaced the print statement with a call to log.debug such > that the code now looks like this: > ... > for i in range(10) > log.debug(i) > ... > > I am now getting the same error as before, though the trace is different: > > Module ddx.controllers.ddxform:49 in storeddx > << vlist = model.ls() > for i in range(10): > log.debug(i) > log.debug("after for loop") > for cx in vlist: >>> log.debug(i) > Module logging:970 in debug > << if self.manager.disable >= DEBUG: > return > if DEBUG >= self.getEffectiveLevel(): > apply(self._log, (DEBUG, msg, args), kwargs) >>> if DEBUG >= self.getEffectiveLevel(): > Module logging:1166 in getEffectiveLevel > << """ > logger = self > while logger: > if logger.level: > return logger.level >>> while logger: > ValueError: Cannot set attribute to this value > > adding extra lines of harmless code above and/or below the for loop does > not change the location at which the error is reported. > > Does anyone have any examples of the use of for loops in a controller? A > quick look around the web reveals a distinct lack of published examples > where for loops appear in controllers, is there a reason for this? For loops > in controllers do not need to be ended like they do in templates, correct?
There's nothing special about for loops in controllers. What *can* you get a controller to do? Does an action that merely 'return "Hello"' work? What about one with a single log.debug() statement? The trouble is, we don't know if the traceback is even reporting the right module, and I don't know if you can insert the Python debugger into the middle of an action. You may be able to put "import pdb; pdb.set_trace()" just before the error and get into the debugger at the console. Then... look around at what local variables are defined I guess. The problem is we don't know what Python function is being called to trigger the error, so we don't know which variable to check. But if you type 'c' in the debugger, it *should* break again when the error occurs, and be at the actual location of the error. Unless the original error is being caught and another error raised, then the original context is lost. My first suspicion was that it's trying to assign a new attribute to an object with __slots__, but normally that would raise "AttributeError: X type object has no attribute 'foo'". I've never seen a Python error message like this, which may mean it's customized. I did a grep over my entire site-packages though for "Cannot set attribute" and couldn't find it. Another possibility is it's inside a C module. Stack frames inside C routines don't seem to be included in tracebacks, which can give a misleading impression of where an error occurs. Another possibility is the error is occurring in a dynamically-compiled template (Mako code), which may throw the traceback off too. Make sure you're not using render() while troubleshooting. -- Mike Orr <[email protected]> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~----------~----~----~----~------~----~------~--~---
