Re: [Zope-dev] TransWarp preview release (AOP tools only)
"Phillip J. Eby" wrote:
At 12:39 PM 3/2/01 -0500, Shane Hathaway wrote:
This could be achieved by generating a new Python module for each portal instance, but that would mean sys.modules would have to be pre-loaded with the information about each portal instance and that's not the ZODB way. It would be better to create a new class loader that can weave a new class on the fly based on persisted component metadata. Note that class loading is currently quite simple; see lib/python/Zope/ClassLoader.py (sp?). It could bear some complexity. :-)
There's actually a simpler way. Aspect objects can be pickled as long as all the objects in them can be pickled. Which means that as long as all their methods are Zope objects, and all the nested classes are also Aspect objects, you can save an aspect into the ZODB, and load it at a future time. Further, since adding aspects together makes new aspects, you can save the combined aspects, so you only have to perform one call to transform the aspect into a family of classes. That still means some load-time complexity, however.
Perhaps... but as I see it, pickling the aspect weaving information into each object makes it harder to vary the aspect weaving after objects have been created. I would want to be able to create a portal, add some content, then change the aspects that apply to the content after it has been created. That means that either the objects have a class definition that references a centralized component or all content objects have to be re-woven every time you change the centralized component. I'm also planning outside the ZODB. The goal is to design apps using pure and simple ZODB and not be required to do anything special to make it work later with other forms of storage. Other databases will not be able to store aspect information.
It would be interesting if you could take an arbitrary Zope service object (like a portal), and go to its "Aspects" tab, and add or remove aspects to be woven with its class family. But I suspect it will be a long time before I'll have a need for that personally or professionally, as I am focused primarily on TransWarp as a CASE tool and Python application toolkit at present.
That's actually the kind of functionality we have now, but we're using subobjects rather than tabs and we achieve many of the things AOP would give us through simple delegation. You should check out the CMF as soon as the beta is released. Shane
At 10:52 AM 3/6/01 -0500, Shane Hathaway wrote:
"Phillip J. Eby" wrote:
There's actually a simpler way. Aspect objects can be pickled as long as all the objects in them can be pickled. Which means that as long as all their methods are Zope objects, and all the nested classes are also Aspect objects, you can save an aspect into the ZODB, and load it at a future time. Further, since adding aspects together makes new aspects, you can save the combined aspects, so you only have to perform one call to transform the aspect into a family of classes. That still means some load-time complexity, however.
Perhaps... but as I see it, pickling the aspect weaving information into each object makes it harder to vary the aspect weaving after objects have been created.
That's not what I said. *Aspect objects* can be pickled. You're talking about *instances* of *classes* created by weaving the aspects, and that's a whole different kettle of fish. Check out the "AOPTutorial" in the Wiki, which sorts out the differences between the three.
I would want to be able to create a portal, add some content, then change the aspects that apply to the content after it has been created.
Of course, just as you can currently upgrade a class that has instances in the ZODB. Regenerating the class from different aspects would have exactly the same pros and cons as upgrading a .py module containing a class that's used in the ZODB.
I'm also planning outside the ZODB. The goal is to design apps using pure and simple ZODB and not be required to do anything special to make it work later with other forms of storage. Other databases will not be able to store aspect information.
Again, this is a confusion of instance and class. Aspect information is *not* per-instance - heck, even *classes* in TW don't know what Aspects they were woven from. The aspects are like flour and eggs that go into making a cake (class or set of classes). Once it's baked, the ingredients are no longer visible. :)
That's actually the kind of functionality we have now, but we're using subobjects rather than tabs and we achieve many of the things AOP would give us through simple delegation. You should check out the CMF as soon as the beta is released.
One of the interesting things I learned at the Python conference this year (through some of the papers, like the Virtual Worlds and Thin Client projects) was where the best trade-offs between a delegation approach and an AOP-style approach are. The spectrum seems to be that if your instances need to make lots of different choices, or if they need to be able to add and remove aspects on an ongoing basis, then some type of delegation is probably the way to go. If your choices are more about *configuration* that applies to *multiple classes*, then aspects are probably more appropriate. By the way, I have never tried to promote AOP as even being relevant to the CMF. :) AOP is mostly about *reuse*, so any single run-time environment (such as CMF or even Zope as a whole) will not see much benefit that you can't get through delegation. ZPatterns, for another example, is one gigantic web of delegation internally. AOP is of more relevance to the developer who has a piece of code they would like to use for the CMF, *and* for a command line tool, *and* a testing tool, *and*.... And thus they need to be able to assemble their code into a variety of useful configurations. After Michel's presentation the other day, I understand a lot better how Zope will address this issue with "adapters", and that will help *a lot* with a lot of things. However, people may also have other environments besides Zope to use their code in, or other configuration choices to be addressed that are not exposed to Zope (such as the database schema), and having AOP available will presumably be helpful to them.
"Phillip J. Eby" wrote:
At 10:52 AM 3/6/01 -0500, Shane Hathaway wrote:
Perhaps... but as I see it, pickling the aspect weaving information into each object makes it harder to vary the aspect weaving after objects have been created.
That's not what I said. *Aspect objects* can be pickled. You're talking about *instances* of *classes* created by weaving the aspects, and that's a whole different kettle of fish. Check out the "AOPTutorial" in the Wiki, which sorts out the differences between the three.
I understand. What I'm saying is that for this application, sys.modules will not contain the information necessary for reassembling the aspects. So you have to either put that information in the pickled objects or in a centralized pickled object. I thought you had suggested putting the information in the pickled objects and we agree that is probably not the right approach. Instead the objects will contain a reference to a centralized pickled object that can supply the weaving information. I know I'm not using perfect terminology.
I'm also planning outside the ZODB. The goal is to design apps using pure and simple ZODB and not be required to do anything special to make it work later with other forms of storage. Other databases will not be able to store aspect information.
Again, this is a confusion of instance and class. Aspect information is *not* per-instance - heck, even *classes* in TW don't know what Aspects they were woven from. The aspects are like flour and eggs that go into making a cake (class or set of classes). Once it's baked, the ingredients are no longer visible. :)
ZODB creates two pickles for every object: the class of the object and the object state. One could conceivably store the aspect weaving information in that first pickle. (Normally the first pickle is very simple, containing only the name of the module and the name of the class, but it can in fact be as complex as you want.) In fact, depending on how you coded TW, that's just what ZODB might try to do and it might even work. But for this application I wouldn't want it to do that. BTW in Python, classes are really just instances of class classes (or type classes, or class types, or class class classes etc...) ;-)
By the way, I have never tried to promote AOP as even being relevant to the CMF. :)
I know. I'm justing trying to "weave" your work in to Zope.
AOP is mostly about *reuse*, so any single run-time environment (such as CMF or even Zope as a whole) will not see much benefit that you can't get through delegation. ZPatterns, for another example, is one gigantic web of delegation internally. AOP is of more relevance to the developer who has a piece of code they would like to use for the CMF, *and* for a command line tool, *and* a testing tool, *and*.... And thus they need to be able to assemble their code into a variety of useful configurations.
I see. I'll try to keep that in the back of my mind.
After Michel's presentation the other day, I understand a lot better how Zope will address this issue with "adapters", and that will help *a lot* with a lot of things. However, people may also have other environments besides Zope to use their code in, or other configuration choices to be addressed that are not exposed to Zope (such as the database schema), and having AOP available will presumably be helpful to them.
Agreed (though I've been working on a delegation-capable storage...) :-) Shane
participants (2)
-
Phillip J. Eby -
Shane Hathaway