[Grok-dev] Upgrade problem "type object 'IRole' has no attribute '__iro__'"

Sebastian Ware sebastian at urbantalk.se
Wed May 28 09:32:14 EDT 2008


This is the code where the problem occurs:

     def init_extendors(self):
         self._extendors = {}
         for p in self._registry._provided:
             self.add_extendor(p)

     def add_extendor(self, provided):
         _extendors = self._extendors
         for i in provided.__iro__:   <======= THIS IS WHERE THE ERROR  
OCCURS!
             extendors = _extendors.get(i, ())
             _extendors[i] = (
                 [e for e in extendors if provided.isOrExtends(e)]
                 +
                 [provided]
                 +
                 [e for e in extendors if not provided.isOrExtends(e)]
                 )

     def remove_extendor(self, provided):
         _extendors = self._extendors
         for i in provided.__iro__:
             _extendors[i] = [e for e in _extendors.get(i, ())
                              if e != provided]

I have tracked down the code that should set this in [class  
Specification] (zope/interface/interface.py). Maybe I could solve this  
problem if I somehow could tell all the offending objects that they  
have changed (I am guessing the problem is related to more than one  
object). But how?

class Specification(SpecificationBase):

     [snip]

     def changed(self, originally_changed):
         """We, or something we depend on, have changed
         """

         implied = self._implied
         implied.clear()

         ancestors = ro(self)

         try:
             if Interface not in ancestors:
                 ancestors.append(Interface)
         except NameError:
             pass # defining Interface itself

         self.__sro__ = tuple(ancestors)
         self.__iro__ = tuple([ancestor for ancestor in ancestors
                               if isinstance(ancestor, InterfaceClass)
                               ])

         for ancestor in ancestors:
             # We directly imply our ancestors:
             implied[ancestor] = ()

         # Now, advise our dependents of change:
         for dependent in self.dependents.keys():
             dependent.changed(originally_changed)


Mvh Sebastian

28 maj 2008 kl. 12.43 skrev Sebastian Ware:

> My problem is that this prevents me from updating my customers  
> project without exporting and importing all the data, something that  
> isn't very easy at the current state of Grok.
>
> I hope someone can give me some hints on this.
>
> Mvh Sebastian
>
> 28 maj 2008 kl. 12.02 skrev Wichert Akkerman:
>
>> Previously Sebastian Ware wrote:
>>> When upgrading a live grok-0.10 app to grok-0.12 I get the following
>>> error:
>>>
>>> AttributeError: type object 'IRole' has no attribute '__iro__'
>>>
>>> I am guessing it has to do with the move of zope.securitypolicy, but
>>> how do I resolve this?
>>
>> The last few times I've seen that __iro__ error it apparently had
>> something to do with persisted interface. I've never been able to  
>> find a
>> fix for it, or reliably reproduce it.
>>
>> Wichert.
>>
>> -- 
>> Wichert Akkerman <wichert at wiggy.net>    It is simple to make things.
>> http://www.wiggy.net/                   It is hard to make things  
>> simple.
>
> _______________________________________________
> Grok-dev mailing list
> Grok-dev at zope.org
> http://mail.zope.org/mailman/listinfo/grok-dev



More information about the Grok-dev mailing list