-------- Original Message -------- Subject: Re: [Zope3-Users] Getting the content object from a widget Date: Mon, 14 Nov 2005 14:14:02 +0100 From: Johan Carlsson <[EMAIL PROTECTED]> To: Johan Carlsson <[EMAIL PROTECTED]> References: <[EMAIL PROTECTED]> Johan Carlsson wrote: Well, I extended the search loop to look like this: def _getParent(self): curr=self while hasattr(curr, 'context') and \ (IField.providedBy(curr) or \ IInputWidget.providedBy(curr)): curr=curr.context return curr Which means that it returnes the first non field non widget it finds. It kind of does the trick. One would have though I could just use: def _getParent(self): field=self.context content=field.context return content But there is situations where a widget has a widget as it's context. For instance the default ObjectWidget uses an ObjectWidgetView as it's view class and when ObjectWidget sets it up it supplies context=self (e.g. a widget as context). I don't know why it's designed this way, in my ImageWidget, which is based on ObjectWidget, I've cut out the ObjectWidgetView and does every thing in the first view class. I did need to change the page template to use view instead of context but othervice it works ok (so far). If anyones interested I can make the ImageField code available. Regards, Johan -- Johan Carlsson Tel: + 46 8 31 24 94 Colliberty Mob: + 46 70 558 25 24 Torsgatan 72 Email: [EMAIL PROTECTED] SE-113 37 STOCKHOLM -- Johan Carlsson Tel: + 46 8 31 24 94 Colliberty Mob: + 46 70 558 25 24 Torsgatan 72 Email: [EMAIL PROTECTED] SE-113 37 STOCKHOLM _______________________________________________ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users