[Zope3-dev] ContextAware gone, xmldom broken

Steve Alexander steve@cat-box.net
Sat, 07 Jun 2003 22:09:01 +0300


>>I'll write a new ContextAware base class for you.
> 
> Thanks! I realized that was the plan anyway

Right. But, I didn't realize anyone was using the old ContextAware 
class. There were only a couple of examples of its use in the Zope3 code.

> it was just a rather
> unfortunate coincidence (and amusing) that I checked this in finally
> and then you went ahead and promptly (and inadvertently) broke it all. Since 
> I didn't want to come across as someone who checks in code *that* badly broken 
> I thought I'd bring it up. :)

I've checked in a ContextAware marker class.

This one works a little differently than the old one. Here's my checkin 
message:

----
Added a ContextAware class. This takes a different approach than the 
ContextAware marker class that had been used up until a few days ago.

The problem with the marker class is that its effects were apparent even 
if your class derives from ContextAware via some hierarchy of base 
classes. The approach in this checkin uses a metaclass that proxies 
descriptors defined in a class with appropriate ContextDescriptors. 
ContextAware must be present explicitly and visibly in a class' 
base-classes to trigger this context-aware behaviour.

If this appears to be too odd a behaviour for a base class, then another 
approach is to make ContextAware not a base class, but instead a form of 
"class advice", like implements() from zope.interface.

So, something like this:

class Foo:
   thingsDefinedInThisClassShallBeContextAware()

----

All of your xmldom tests now pass.

--
Steve Alexander