Re: [Zope] problems with testing (PloneMailBoxer)
robert rottermann wrote at 2005-6-24 05:41 +0200: ... security.declareProtected('Access contents information', 'getValueFor') def getValueFor(self, key): # Returns value for property; # if available, a dynamic getter will be used # we can not use MailBoxers getValueFor since # it does not work with skin elements on the FS getter = self.getProperty('getter') if getter: getterHandler = self.unrestrictedTraverse(getter, default=None) if getterHandler is not None: try: result = getterHandler(key) if result is not None: return result except: pass # Our stored properties are the default return self.getProperty(key) [DM] It this function returns None, then self.getProperty(key) (among others) must return None. it does not. It does -- in the failing case. If you look (carefully) at your code, you see that it can return None only when also self.getProperty(key) returns None. Some other things, too, have evaluated to some false value, in this case. To analyse such problems, put import pdb; pdb.set_trace() in the surprising code. The effect will be that the code enters pdb at this line and allows you to single step through the code and see precisely what goes on. Of course, you can also use a different debugger... -- Dieter ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
[Zope] problems with testing (PloneMailBoxer)
Hi there, I have a problem testing PloneMailBoxer I am using the Method added at the end getter = self.getProperty('getter') getterHandler = self.unrestrictedTraverse(getter, default=None) Calling the method in a test case I allways get None. In a real Plone setup it works fine. can somebody tell me why that is so? (Or where to look for a solution) thanks Robert security.declareProtected('Access contents information', 'getValueFor') def getValueFor(self, key): # Returns value for property; # if available, a dynamic getter will be used # we can not use MailBoxers getValueFor since # it does not work with skin elements on the FS getter = self.getProperty('getter') if getter: getterHandler = self.unrestrictedTraverse(getter, default=None) if getterHandler is not None: try: result = getterHandler(key) if result is not None: return result except: pass # Our stored properties are the default return self.getProperty(key) ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] problems with testing (PloneMailBoxer)
robert rottermann wrote at 2005-6-23 09:16 +0200: ... Calling the method in a test case I allways get None. ... security.declareProtected('Access contents information', 'getValueFor') def getValueFor(self, key): # Returns value for property; # if available, a dynamic getter will be used # we can not use MailBoxers getValueFor since # it does not work with skin elements on the FS getter = self.getProperty('getter') I expect that your mail composer distorted indentation in the line above. As it stands here, it is a SyntaxError. if getter: getterHandler = self.unrestrictedTraverse(getter, default=None) if getterHandler is not None: try: result = getterHandler(key) if result is not None: return result except: pass # Our stored properties are the default return self.getProperty(key) It this function returns None, then self.getProperty(key) (among others) must return None. If unrestrictedTraverse returns None, remove the default= argument an look at the resulting exception... -- Dieter ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] problems with testing (PloneMailBoxer)
thanks Dieter, Dieter Maurer wrote: robert rottermann wrote at 2005-6-23 09:16 +0200: ... Calling the method in a test case I allways get None. ... security.declareProtected('Access contents information', 'getValueFor') def getValueFor(self, key): # Returns value for property; # if available, a dynamic getter will be used # we can not use MailBoxers getValueFor since # it does not work with skin elements on the FS getter = self.getProperty('getter') I expect that your mail composer distorted indentation in the line above. As it stands here, it is a SyntaxError. if getter: getterHandler = self.unrestrictedTraverse(getter, default=None) if getterHandler is not None: try: result = getterHandler(key) if result is not None: return result except: pass # Our stored properties are the default return self.getProperty(key) It this function returns None, then self.getProperty(key) (among others) must return None. it does not. I checked I returns the name of an a skinned python script on the FS If unrestrictedTraverse returns None, remove the default= argument an look at the resulting exception... It complains that it does not find the objekt. This means that in the testing environment the skind element is not found. In the real enviroment however it is. But why? Robert ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )