Re: [Zope-dev] Designing ZPatterns/Python-product-based, reusable applications - take 2
Itai Tavor wrote: This brings up another thing that bothers me: When I started learning object models and ZPatterns everyone advocated using Coad notation. Now Peter Coad himself is using UML and you're building TransWarp around UML. Is this a conspiracy to confuse me? ZPatterns is very much about objects and collaborations between objects. The Coad notation is very good for talking about objects like this. TransWarp is more about classes, and generating customized classes from a mixture of existing classes and aspects. You can understand aspects as declarations about how to handle certain kinds of behaviour. UML is very good for talking about classes and the relationships that can exist between objects of particular classes. Often, I tend to think in Coad, but write in UML. -- Steve Alexander Software Engineer Cat-Box limited ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] Designing ZPatterns/Python-product-based, reusable applications - take 2
Phillip J. Eby wrote: At 10:24 AM 3/11/01 +1100, Itai Tavor wrote: Then I need Specialists to manage collections of PD classes. I think that these would also benefit from being product-based, so I subclass Specialist to create a manager for each role in the application. Now, since an existing application might be expanded, the Specialists all need factory methods and will all show up in Zope's Add New Object menu. Or you may want to just create one factory method that creates an entire family of related Specialists. Specialists do support TTW overriding of their methods, if you set up the methods properly in your Python code. (I forget how this works, though, you'll probably need to check the source code.) The reason I think I need factory methods for all Specialists is that it would enable adding features to an existing site - so it would support multiphase development. About TTW overriding of Specialist methods - didn't even think to look for such an option. I'll check the code. It could be very useful. - Many of the classes will also have web user UI, and since this has to be designed to fit the design of the web site in which the application is used, the UI methods will have to be located where designers can modify them - in the ZODB. For the Specialists, I can install a default set of UI methods when an instance of the Specialist is installed. But where do I store PD class UI methods? EMarket's solution is to store them in the Specialist, but this not only breaks O-O rules, it can also be very ugly. Say I have a Specialist managing 3 PD classes. Instead of an index_html method for each class, I'll need class1index_html, class2index_html, class3index_html in the Specialist. And each class would have to define: def index_html(self, REQUEST, RESPONSE, **kw): return self.class1index_html(REQUEST, RESPONSE, kw) This is unacceptably ugly. But the only other thing I can think of doing is creating a ZClass for each PD class and store the UI methods there. But that's also pretty unacceptable. Is there a better solution? Yes. Use "class_default_for_X" methods. (e.g. "def class_default_for_index_html"). This will make them capable of being overridden with a Class Extender in the Rack or Specialist. Class Extenders! Wow! I mean, Wow! I mean, this is great! Let me catch my breath... I got to learn to look under my nose more often. I just assumed that everything in the DataPlugins Add menu (other than Link to Parent Plugin) was made redundant by the use of SkinScripts. Just got to figure out the best way to use them... with class_default_for_X there won't be any ZODB-accessible default code to develop on, so for UI methods, creating the Class Extender along with the Rack, and filling it with default DTML methods might be a better idea. Next, I need object connections - these are created using SkinScripts. And as far as I can tell, I can't manage SkinScript in the product - they have to be in the ZODB. Which is ok in O-O land as they're not strictly part of the PD classes, but this means that PD classes don't actually work at all until someone comes and fills in the SkinScripts - so the class actually misses a lot of the code it requires to function. Also, it means SkinScript code can't be reused with the rest of the application's components (except by cutting and pasting code pieces from an existing application). Your factory code can set this up, although I admit it's ugly. But when I run the factory code the SkinScripts don't exist yet... I create my DataSkins and install my Specialists and Racks first, then develop the SkinScript required by them... so the Python product never contains all the application code... unless I copy the SkinScripts back into the product. The problem here is that I don't write a general-purpose app that will later be customized into a working project - I write a custom app for a specific project, which I will later want to reuse. So when I finish development of the first app, parts of it are in the ZODB. At this point, copying them back into the product makes sense for the purpose of instantiating new copies of the product, but not for that app itself, because maintenance/bug fixes will still be done on the ZODB copies. Finally, I need to wrap the whole thing up as an application. So I create a Folderish class which installs instances of all Specialists, and add application-wide utility methods. Or do I simply place all Specialists in a Folder? Placing them in a folder would be fine. Actually, it would suffice simply to install a meta type which creates all the Specialists in the selected folder. Note that Zope does not require that a meta type correspond to some physical class, or that an add operation result in a single object being added to a container; you can add as many objects as you want in the same operation. Never thought about doing things that way... interesting. Now, about reuse. O-O reuse,
[Zope-dev] Designing ZPatterns/Python-product-based, reusable applications -take 2
Hi, I didn't get very far asking this question a little while ago, so I'm going to try again. I started developing ZPatterns applications in the ZODB. Then I figured there would be advantages to moving instead to python product-based development. My goal is to create applications that can be reused easily, but I'm having problems deciding on the best way to structure the application, how the requirement of reusability affects the structure, and how reuse will actually take place. The starting point is an object-model based application, so unlike applications like zCommerce and EMarket, where you start from an API, template, or skeleton and build on that, I'll be trying to reuse parts of an actual, complete, live application. Starting with PD classes: Those would be DataSkin-subclassed python classes. Reuse would involve either using these classes as-is, or subclassing them where changes are needed. No problem here. Then I need Specialists to manage collections of PD classes. I think that these would also benefit from being product-based, so I subclass Specialist to create a manager for each role in the application. Now, since an existing application might be expanded, the Specialists all need factory methods and will all show up in Zope's Add New Object menu. Now consider UI: - Both PD and manager classes will have administrator UI. This would not have to change unless the class is subclassed, so the UI methods can stay in the product and loaded using HTMLFile. - Many of the classes will also have web user UI, and since this has to be designed to fit the design of the web site in which the application is used, the UI methods will have to be located where designers can modify them - in the ZODB. For the Specialists, I can install a default set of UI methods when an instance of the Specialist is installed. But where do I store PD class UI methods? EMarket's solution is to store them in the Specialist, but this not only breaks O-O rules, it can also be very ugly. Say I have a Specialist managing 3 PD classes. Instead of an index_html method for each class, I'll need class1index_html, class2index_html, class3index_html in the Specialist. And each class would have to define: def index_html(self, REQUEST, RESPONSE, **kw): return self.class1index_html(REQUEST, RESPONSE, kw) This is unacceptably ugly. But the only other thing I can think of doing is creating a ZClass for each PD class and store the UI methods there. But that's also pretty unacceptable. Is there a better solution? Next, I need object connections - these are created using SkinScripts. And as far as I can tell, I can't manage SkinScript in the product - they have to be in the ZODB. Which is ok in O-O land as they're not strictly part of the PD classes, but this means that PD classes don't actually work at all until someone comes and fills in the SkinScripts - so the class actually misses a lot of the code it requires to function. Also, it means SkinScript code can't be reused with the rest of the application's components (except by cutting and pasting code pieces from an existing application). I also need storage management - which is done with Rack methods and SkinScripts in the Racks. The SkinScripts present the same problem as the ones used for object connections. Rack methods can be ZODB-based, in which case again they can't be easily reused and need to be manually created before the objects start doing anything, or they can be created in Rack-subclassed classes, but that creates a problem for RDBM storage - unless it's possible to store SQL methods in a python product. Finally, I need to wrap the whole thing up as an application. So I create a Folderish class which installs instances of all Specialists, and add application-wide utility methods. Or do I simply place all Specialists in a Folder? Now, about reuse. O-O reuse, as far as I understand it, takes place at the class level. So how do I start a new application? Do I subclass its main container class and and my own init method that adds any added or subclassed Specialists I use? Or do I create my own application class and import PD classes from the old application? Do I copy the old classes into my new product, or do I import them from the old product, which then would require that the old product is kept on the server, even if the application that product defines isn't used on this server? And, as mentioned above, how do I reuse SkinScripts, Rack methods and SQL methods? Copy and paste? It seems funny that if I create a new instance of the product, I don't get a new copy of a working application... That's it. Sorry it's so long and complex. What would be great is if someone posted a description of the structure of a working application. I'm sure this is something many people are likely to struggle with - it almost could be a HowTo. I hope, now everyone are back from the conference ,
Re: [Zope-dev] Designing ZPatterns/Python-product-based, reusable applications - take 2
At 10:24 AM 3/11/01 +1100, Itai Tavor wrote: Then I need Specialists to manage collections of PD classes. I think that these would also benefit from being product-based, so I subclass Specialist to create a manager for each role in the application. Now, since an existing application might be expanded, the Specialists all need factory methods and will all show up in Zope's Add New Object menu. Or you may want to just create one factory method that creates an entire family of related Specialists. Specialists do support TTW overriding of their methods, if you set up the methods properly in your Python code. (I forget how this works, though, you'll probably need to check the source code.) - Many of the classes will also have web user UI, and since this has to be designed to fit the design of the web site in which the application is used, the UI methods will have to be located where designers can modify them - in the ZODB. For the Specialists, I can install a default set of UI methods when an instance of the Specialist is installed. But where do I store PD class UI methods? EMarket's solution is to store them in the Specialist, but this not only breaks O-O rules, it can also be very ugly. Say I have a Specialist managing 3 PD classes. Instead of an index_html method for each class, I'll need class1index_html, class2index_html, class3index_html in the Specialist. And each class would have to define: def index_html(self, REQUEST, RESPONSE, **kw): return self.class1index_html(REQUEST, RESPONSE, kw) This is unacceptably ugly. But the only other thing I can think of doing is creating a ZClass for each PD class and store the UI methods there. But that's also pretty unacceptable. Is there a better solution? Yes. Use "class_default_for_X" methods. (e.g. "def class_default_for_index_html"). This will make them capable of being overridden with a Class Extender in the Rack or Specialist. Next, I need object connections - these are created using SkinScripts. And as far as I can tell, I can't manage SkinScript in the product - they have to be in the ZODB. Which is ok in O-O land as they're not strictly part of the PD classes, but this means that PD classes don't actually work at all until someone comes and fills in the SkinScripts - so the class actually misses a lot of the code it requires to function. Also, it means SkinScript code can't be reused with the rest of the application's components (except by cutting and pasting code pieces from an existing application). Your factory code can set this up, although I admit it's ugly. Finally, I need to wrap the whole thing up as an application. So I create a Folderish class which installs instances of all Specialists, and add application-wide utility methods. Or do I simply place all Specialists in a Folder? Placing them in a folder would be fine. Actually, it would suffice simply to install a meta type which creates all the Specialists in the selected folder. Note that Zope does not require that a meta type correspond to some physical class, or that an add operation result in a single object being added to a container; you can add as many objects as you want in the same operation. Now, about reuse. O-O reuse, as far as I understand it, takes place at the class level. So how do I start a new application? Do I subclass its main container class and and my own init method that adds any added or subclassed Specialists I use? Or do I create my own application class and import PD classes from the old application? Do I copy the old classes into my new product, or do I import them from the old product, which then would require that the old product is kept on the server, even if the application that product defines isn't used on this server? If I understand you correctly, then you'd just instantiate another instance of the application metatype, and then customize whatever needed to be customized. And, as mentioned above, how do I reuse SkinScripts, Rack methods and SQL methods? Copy and paste? It seems funny that if I create a new instance of the product, I don't get a new copy of a working application... If your factory methods set this stuff up, then you're okay. On the other hand, considering that ZPatterns is now being superceded before it even had a chance to mature, maybe nobody cares to hear about it anymore :-( But more on that in a separate post. IMHO, ZPatterns is actually pretty mature - in terms of its code. By that I mean, it has gone about as far in capabilities as its internal architecture will allow. There are many minor improvements that could be made, but they would be costly compared to their benefit. I would rather invest the effort in something that will produce a greater gain for me and the rest of the community. TransWarp will be much better for filesystem-based, Python products than ZPatterns, which is almost 100% through-the-web focused. The key phrase, though, is