Re: [Zope-dev] compiling Zope 2.4.1 on Mac OS 10.1
Has anyone managed to do this procedure with Python 2.0? The -flat_namespace flag does not help and I'm still getting twolevel_namespace errors. I'm running Zope 2.3.2 and I'd like to avoid the startup warnings, as well as any possible incompatibilities with Python 2.1/2.2. Itai Jens Vagelpohl wrote: i think i found a working solution. since my knowledge of compilers and linkers isn't the greatest i'll just explain what i did. trying to compile python2.1.1 on OS X 10.1 failed for me displaying the very same error. searching through apple's discussion i found the following link: http://fink.sourceforge.net/doc/porting/shared.php it explains that some linker/compiler default options have changed. in order to get python compiled and running i edited the toplevel Makefile after running ./configure and edited the lines starting with LDSHARED and BLDSHARED, this is what they look like now in my setup: LDSHARED= $(CC) $(LDFLAGS) -bundle -flat_namespace -undefined suppress BLDSHARED= $(CC) $(LDFLAGS) -bundle -flat_namespace -undefined suppress notice the -flat_namespace switch, this gets rid of the new default twolevel_namespace that complains about undefined warning. running make was now successful and i was able to compile and run Zope 2.4.1. you will probably have to recompile your python to set that switch under 10.1. i only did some light testing, no guarantees and before using this in production you might want to read up on those compiler/linker options... jens -- -- Itai Tavor -- Je sautille, donc je suis.-- [EMAIL PROTECTED]-- - Kermit the Frog -- -- -- -- If you haven't got your health, you haven't got anything -- ___ 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 )
[Zope-dev] Using PropertySheet properties in Python-based DataSkin product
Hi, I'm building a custom DataSkin in a Python product, and I need to have different permissions for different properties. I've traced the way this is done in ZClasses but I'm not sure how to implement it in Python or what classes and methods to use. First, there's DataSkinSheet, ZCommonSheet, and PropertySheet. Would a PropertySheet work on a Rack? The interfaces added by ZCommonSheet seem to be aimed at using it in a ZClass, so I guess they aren't needed, but the v_self method added by DataSkinSheet might be needed? Then I need to assign permissions to the sheet. Do I modify the __ac_permissions__ of PropertySheet? I don't think I can use ZCommonSheet.manage_setPermissionMapping as it uses ZClass permissions mappings... or is there another way to do this? Also, to add properties to the sheet, do I need to call _setProperty for each property in the class __init__ method? Or is there a simpler/quicker way? TIA, Itai -- -- Itai Tavor -- Je sautille, donc je suis.-- [EMAIL PROTECTED]-- - Kermit the Frog -- -- What he needs now is understanding... and a confederate victory -- -- Dr. Jacobi, Twin Peaks -- ___ 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] How do I call an HTMLFile in context provided by apath
Tres Seaver wrote: Itai Tavor [EMAIL PROTECTED] wrote: Dieter Maurer wrote: Itai Tavor writes: P.S Now that aq_parent is working... why can't I do absolute_url() on DTMLFiles :-( "absolute_url" is provided by the class "OFS.Traverable". Apparently, "DTMLFile" is not derived from it. Dieter Well, obviously... the question is why nobody saw the need to add Traversable to DTMLFiles... DTMLFiles are supposed to function as *methods* of their classes; methods *don't* have their own 'absolute_url', but return the url of the object on which they are called. DTMLMethods have exactly the same semantics: dtml-var absolute_url returns the folder/context object's URL, by design. Tres. Thanks for replying, and sorry for getting so long to get back to your answer. Had a fun week recovering from a hack attack. Ok, so DTMLFile.absolute_url() should return its container. Except... DTMLFiles simply don't have absolute_url - their own or inherited. They return an attribute error. I was going to post a feature request to the collector, but if absolute_url on a DTMLFile will return the container, then it's pretty useless. Itai -- -- Itai Tavor -- "Je sautille, donc je suis."-- [EMAIL PROTECTED]-- - Kermit the Frog -- -- -- -- "If you haven't got your health, you haven't got anything" -- ___ 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 )
[Zope-dev] Re: Zope-Dev digest, Vol 1 #1057 - 3 msgs
Martijn Pieters wrote: On Tue, Apr 17, 2001 at 07:44:47AM -0700, Michael R. Bernstein wrote: Mr. Bernstein had packaged up the file as a gzipped tarball indeed, but then his mailer must've wrapped it up in a BinHex wrapper. Wasn't me. :-) Whoops, sorry, case of bleary sleepy eyes. The finger should point to Itai Tavor :) Yes, it should. Apologies for the mess. I forgot to disable BinHex in my mailer. I'd have posted a fixed attachment myself but I'm timezone challenged. Thanks for cleaning up after me, Martijn. Itai -- -- Itai Tavor -- "Je sautille, donc je suis."-- [EMAIL PROTECTED]-- - Kermit the Frog -- -- -- -- "If you haven't got your health, you haven't got anything" -- ___ 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 )
[Zope-dev] Re: RackImage
Michael R. Bernstein wrote: Itai Tavor wrote: Thanks, Michael! Turns out I just had to make a few small changes in my product to get it to work, which I discovered looking at yours. Don't know if anything in my product that it would be interesting to add to yours... it's aimed at storing photos for a product catalog, most of what it adds to Image is methods for creating a photo based on another photo, used for creating a thumbnail. Sure, I'll take a look at it. Here it is. Hope any of it is any help. Photo.py.tgz -- -- Itai Tavor -- "Je sautille, donc je suis."-- [EMAIL PROTECTED]-- - Kermit the Frog -- -- -- -- "If you haven't got your health, you haven't got anything" --
Re: [Zope-dev] How do I call an HTMLFile in context provided by apath?
Dieter Maurer wrote: Itai Tavor writes: P.S Now that aq_parent is working... why can't I do absolute_url() on DTMLFiles :-( "absolute_url" is provided by the class "OFS.Traverable". Apparently, "DTMLFile" is not derived from it. Dieter Well, obviously... the question is why nobody saw the need to add Traversable to DTMLFiles... -- -- Itai Tavor -- "Je sautille, donc je suis."-- [EMAIL PROTECTED]-- - Kermit the Frog -- -- -- -- "If you haven't got your health, you haven't got anything" -- ___ 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 )
[Zope-dev] Re: RackImage
Michael R. Bernstein wrote: Itai Tavor wrote: Could I get a copy of this product? I'm trying to create a Rack-mountable Image class but I'm having a lot of trouble getting a class subclassed from Image and DataSkin to work. Having some working code could save me some trouble. I only need the basic RackImage, without all the later stuff you added relating to Renderings. Itai, I am attaching a tar file that needs to be untarred in the Products directory. RackImage is a little rough around the edges, and still has some cruft left over from Photo. It is dependent on PIL, which may be unneccessary at this point. Please send me any modifications you make. (this will be released GPL). Michael. Thanks, Michael! Turns out I just had to make a few small changes in my product to get it to work, which I discovered looking at yours. Don't know if anything in my product that it would be interesting to add to yours... it's aimed at storing photos for a product catalog, most of what it adds to Image is methods for creating a photo based on another photo, used for creating a thumbnail. Itai -- -- Itai Tavor -- "Je sautille, donc je suis."-- [EMAIL PROTECTED]-- - Kermit the Frog -- -- -- -- "If you haven't got your health, you haven't got anything" -- ___ 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 )
[Zope-dev] How do I call an HTMLFile in context provided by a path?
Hi, I have a method that receives a path: '/MyApp/SomeSpecialist/some_id/edit_html' and has to call edit_html in the context of some_id. If edit_html is a DTML Method, I can do this: obj = REQUEST.traverse(path) return obj(obj.aq_parent, REQUEST) But when edit_html is an HTMLFile in a Python Product, obj.aq_parent doesn't work. And trying to get some_id using REQUEST.traverse('/MyApp/SomeSpecialist/some_id') returns the index_html method of some_id, instead of the object itself. Any ideas how I can fix this? TIA, Itai -- -- Itai Tavor -- "Je sautille, donc je suis."-- [EMAIL PROTECTED]-- - Kermit the Frog -- -- "What he needs now is understanding... and a confederate victory" -- -- Dr. Jacobi, Twin Peaks -- ___ 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] How do I call an HTMLFile in context provided by apath?
Dieter Maurer wrote: Itai Tavor writes: I have a method that receives a path: '/MyApp/SomeSpecialist/some_id/edit_html' and has to call edit_html in the context of some_id. If edit_html is a DTML Method, I can do this: obj = REQUEST.traverse(path) I would use "restrictedTraverse" instead of "REQUEST.traverse" as it uses less magic. Thanks for the tip... I thought restrictedTraverse is slower because it has to do security checks? ... But when edit_html is an HTMLFile in a Python Product, obj.aq_parent doesn't work. Why not? It causes this exception: Error Type: AttributeError Error Value: edit_htmlaq_parent This would mean that either your product is not derived from ExtensionClass.Base or that "HTMLFile" is not derived from "Acquisition.Implicit". My product inherit does have implicit acquisition. But HTMLFile doesn't - that's the whole problem. Replacing HTMLFile with DTMLFile solves the problem, as DTMLFile derives from Acquisition.Explicit. Thanks for pointing me in the right direction. P.S Now that aq_parent is working... why can't I do absolute_url() on DTMLFiles :-( -- -- Itai Tavor -- "Je sautille, donc je suis."-- [EMAIL PROTECTED]-- - Kermit the Frog -- -- "What he needs now is understanding... and a confederate victory" -- -- Dr. Jacobi, Twin Peaks -- ___ 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] ZPatterns, DataSkins, forms and errorchecking/handling
Kapil wrote: Thanks, Kapil. I did look at dtml-contract, and it wasn't hard to understand it from the docs. But the problem is that it can't cover all the required tests - like dependencies between several form fields (such as with two password fields) or tests outside the form content (such as ensuring that a new product doesn't have an SKU that already exists, or that a user does not register with an existing email address). So a specific validation is required anyway. Also, all my form action is done in methods of Python Products where dtml-contract is not usable. Itai On Tuesday 27 March 2001 17:40, Itai Tavor wrote: Hi, I'm trying to work out the best way to check for and report errors when DataSkin objects are created/edited, but I'm having a lot of problems. For form validation, Zope's build-in constraints are pretty useless... things like ValueHandler are a little better, but IMO not good enough. When a user types incorrect data in a form, I don't want to display a page with a list of errors and say "click Back to fix your errors". I want to return the form, with a list of errors and the bad fields highlighted. So I need to perform field checks in the form action method and in case of errors call the original form, giving it an error list. I know that to ensure that object data is always valid I should validate the object in a SkinScript, using WHEN OBJECT ADDED,CHANGED call self.validate(), and raise an exception in validate in case of a problem. But this can't deal with returning the original form. It can only display error pages, and to display nicely formatted error pages it has to return a DTML Method so I can use dtml-raise, rather than directly do raise in validate. So I'm looking at a validate method for use at commit time, a show_errors DTML Method, and a validate_form to call from the form action method... The validate_form method is defined in the DataSkin class. But it is also used when a new object is created from a form, so it needs to be called from a Specialist before the object is created, so I need to import it in the Specialist. But this method might use other methods of the DataSkin class, so I need to import those too... So, to sum up, I need a method used in commit time, that renders a DTML method to raise an error message, another method to verify form submissions and return the form with error messages, and I need to import that method and all other methods it uses into the Specialist. This seems too much work... Can anyone suggest a simpler approach (one that still retains the ability to return the original form in case of errors)? check out dtml-contract. sample form processor with dtml contract dtml-contract this page retrieves records from the db based on user input dtml-params foo:int,optional bar:date foobar:range(int, 0,10) dtml-exceptions bad_user_input /dtml-contract user gets redirected if bar is not a valid date string, and foobar is not a integer compatible string between 0 and 10. if foo is present it must be a integer compatible string (compatible means coercible via int(foo)). if any of these things does not happen than all the collected errors for the page are sent to the error handler bad_user_input. this is not a redirect, the error handler is evaluated in the context of the page with an additonal value added to the namespace to denote the list of errors. page processing stops after evaluation of the tag if an error occurs. this may be clear as mud, i don't know, i tried to make the included documentation pretty inclusive and readable, its not completely insync with the code but it does elaborate on the feature set pretty well. if you have specific questions feel free to ask. so in your case you can just use the original form as the error handler and add logic to it to insert the values if they already exist in the request, and display error messages to the user on the particular vars that have problems based on the existence of the special error variable. hth kapil TIA, Itai -- -- Itai Tavor -- "Je sautille, donc je suis."-- [EMAIL PROTECTED]-- - Kermit the Frog -- -- -- -- "If you haven't got your health, you haven't got anything" -- ___ 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 )
[Zope-dev] Form error handling for Rack-stored PD classes in O-O application
Hi, I often have more luck the second time I ask a question... let's see if this rule holds. I'm struggling with checking and reporting errors in forms that create or modify properties of PD classes in a ZPatterns application. Automatic checks using Zope's built-in constraints or something like ValueHandler won't cut it, because they can't cover all the required rules - for example, checking if a Product SKU is being set to an existing SKU, or that a Customer is trying to use an email address already in use (and also because I want to return the form page with the errors indicated, rather than a generic error page). So I need a specific verification method for each class. This method will be used both when an object is edited and when its created. To use the method when creating an object, I either have to place it in the Specialist - which is bad, because the PD class should provide its validation code, or call it at commit time, using a SkinScript WHEN OBJECT CREATED,CHANGED clause. But verification methods called at commit time do their checks on the object properties, not on any submitted form field values. So they can test that a password is reasonably secure, but can't check that passwords typed in two form fields are identical. One thing I can do is define a editInstance method which would verify the values in REQUEST.form and then call manage_changeProperties, or store a list of errors in the REQUEST and raise a 'FormError' exception. But I can't let this exception propagate freely, I have to catch it so I can display an appropriate error page. Also, if a form results in the creation of more than one object, I want to display all the errors that result from the creation of all the objects, but if the first object raises an exception, I can't create the second one (especially if the second one expects to get the id of the first). Or I could forget about exceptions and simply return an error list from editInstance. Then it would be up to the method calling editInstance to raise an exception to roll back the created objects. This is the only workable solution I got at the moment... I can get it to work, but I've chased solutions in the past that seemed good but ended up crashing... so I'd really appreciate any comments on possible flaws or problems I'm not seeing, or any other, better solutions. This is what it would look like (just an example, not showing cases where more complex stuff happens, like 2 objects being created with a single form): In Customer (DataSkin PD class): def editInstance(self, REQUEST, errors): err = self.verify(REQUEST) if err != {}: errors.update(err) else: self.manage_changeProperties(REQUEST) def editInstance_html(self, REQUEST, RESPONSE): """Action method for editInstanceForm_html""" errors = {} self.editInstance(REQUEST, errors) if errors != {}: html = self.editInstanceForm_html(self, REQUEST, errors=errors) raise 'FormError', html RESPONSE.redirect('editInstanceForm_html?message=Changes%20saved.') def verify(self, REQUEST): errors = {} if REQUEST['name'] == '': errors['name'] = 'Please provide a name' return errors In CustomerManager (Specialist): addCustomer(self, REQUEST, errors): ni = self.defaultRack.newItem() ni.editInstance(REQUEST, errors) return ni addCustomer_html(self, REQUEST, RESPONSE): """Action method for addCustomerForm_html""" errors = {} ni = self.addCustomer(REQUEST, errors) if errors != {}: html = self.addCustomerForm_html(self, REQUEST, errors=errors) raise 'FormError', html RESPONSE.redirect('manageInstances_html?message=New%20customer%20created.') And, of course, I can also have WHEN OBJECT ADDED,CHANGED CALL self.ensure_valid(), to catch anything that might get by the above checks. ensure_valid will raise its own error page, independent of the above. TIA for any help/comments Itai -- -- Itai Tavor -- "Je sautille, donc je suis."-- [EMAIL PROTECTED]-- - Kermit the Frog -- -- 'Supposing a tree fell down, Pooh, when we were underneath it?' -- -- 'Supposing it didn't,' said Pooh after careful thought. -- ___ 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 )
[Zope-dev] ZPatterns, DataSkins, forms and error checking/handling
Hi, I'm trying to work out the best way to check for and report errors when DataSkin objects are created/edited, but I'm having a lot of problems. For form validation, Zope's build-in constraints are pretty useless... things like ValueHandler are a little better, but IMO not good enough. When a user types incorrect data in a form, I don't want to display a page with a list of errors and say "click Back to fix your errors". I want to return the form, with a list of errors and the bad fields highlighted. So I need to perform field checks in the form action method and in case of errors call the original form, giving it an error list. I know that to ensure that object data is always valid I should validate the object in a SkinScript, using WHEN OBJECT ADDED,CHANGED call self.validate(), and raise an exception in validate in case of a problem. But this can't deal with returning the original form. It can only display error pages, and to display nicely formatted error pages it has to return a DTML Method so I can use dtml-raise, rather than directly do raise in validate. So I'm looking at a validate method for use at commit time, a show_errors DTML Method, and a validate_form to call from the form action method... The validate_form method is defined in the DataSkin class. But it is also used when a new object is created from a form, so it needs to be called from a Specialist before the object is created, so I need to import it in the Specialist. But this method might use other methods of the DataSkin class, so I need to import those too... So, to sum up, I need a method used in commit time, that renders a DTML method to raise an error message, another method to verify form submissions and return the form with error messages, and I need to import that method and all other methods it uses into the Specialist. This seems too much work... Can anyone suggest a simpler approach (one that still retains the ability to return the original form in case of errors)? TIA, Itai -- -- Itai Tavor -- "Je sautille, donc je suis."-- [EMAIL PROTECTED]-- - Kermit the Frog -- -- -- -- "If you haven't got your health, you haven't got anything" -- ___ 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] Organizing modules in a python product
Thanks, Dieter. You're right, I definitely wouldn't want to use this solution. I was hoping for something that can be done inside the product :-( Dieter Maurer wrote: Itai Tavor writes: ... abbreviated references to sibling subproducts ... Is there any way to set this up so imports like 'import Utils' and 'import Module2' would work in Module1? As a bonus, can I also get __init__.py files in each module directory to be executed? You can manipulate (extend) "sys.path" in your (top level) "__init__.py" file. Python starts its package/module lookup from the elements in "sys.path". However, I doubt very much, that you should do this! You will lose the namespace isolation provided by packages. Dieter -- -- Itai Tavor -- "Je sautille, donc je suis."-- [EMAIL PROTECTED]-- - Kermit the Frog -- -- "What he needs now is understanding... and a confederate victory" -- -- Dr. Jacobi, Twin Peaks -- ___ 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 )
[Zope-dev] Organizing modules in a python product
Hi, I'm writing a python product containing around 40-50 modules, each one with some dtml files. At the moment I got all the modules .py files in the product directory, and a www directory with subdirectories for each module. Products | -- MyProduct |-- Module1.py |-- Module2.py | www |-- Module1 |-- addModuleForm.dtml |-- Module2 |-- index.dtml |-- Utils.py I want to change this to a layout where all the files for a module are grouped together: Products |-- MyProduct |-- Module1 |-- Module1.py |-- www |-- addModuleForm.dtml |-- Module2 |-- Module2.py |-- www |-- index.dtml |-- Utils.py But I'm finding this very hard to work with. In Module1, importing from Utils require doing 'from Products.MyProduct.Utils', and importing from another Module2 requires 'from Products.MyProduct.Module2.Module2'. Is there any way to set this up so imports like 'import Utils' and 'import Module2' would work in Module1? As a bonus, can I also get __init__.py files in each module directory to be executed? TIA Itai -- Itai Tavor -- "Je sautille, donc je suis."-- [EMAIL PROTECTED]-- - Kermit the Frog -- -- -- -- "Every day, once a day, give yourself a present" - Dale Cooper -- ___ 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 )
[Zope-dev] Re: State of ZPatterns
Jerry Spicklemire wrote: I don't pretend to fully "get" any of the stuff these guys, nor the DC crew, not to mention the PythonLabs team, and all the astounding folks on the lists are cooking up for the rest of us. All that I can say for certain is that based on past history, it will be even more amazing than the stuff that has me totally dazzled already. snip Thanks Phil, Ty, Jim, Brian, Paul, Shane, Tres, Michel, Amos, Guido, Tim, Ken, and way too many more to mention! Jerry S. Yeah, what he said. So, Zope's greatest strength is its Web-centricity, but it can also be it's Achille's heal, once the Web reaches maturity, and technology moves on. Something like TransWarp can assure that all the goodies that we build for Zope can continue to live on and remain viable, long after "The Web" is a quaint artifact, a footnote in the primitive history of an ubiquitous Global Communication System. True, but... technology in the real world tends to lag way behind technology in the developer's community. I believe I'll have clients asking me to give them shopping carts for quite a while longer, so I'm more interested in anything that will make that work easier, than in exploring The Web TNG, or whatever happens to come next. Itai -- -- Itai Tavor -- "Je sautille, donc je suis."-- [EMAIL PROTECTED]-- - Kermit the Frog -- -- -- -- "If you haven't got your health, you haven't got anything" -- ___ 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] State of ZPatterns
Phillip J. Eby wrote: At 10:16 AM 3/11/01 +1100, Itai Tavor wrote: I'm wondering where TransWarp leaves ZPatterns users. Until a couple of weeks ago ZPatterns was the best thing to happen in the Zope world since, well, Zope. Now it's described as a 'hack', Those things aren't mutually exclusive, you know. :) I realize that... I just got the impression that your own view of the value of ZPatterns suddenly took a nose dive. Guess I was wrong, and I'm happy to know that. demoted into 'maintenance only' mode, and superceded by something that is described as being as much better than ZPatterns as ZPatterns was better than standard Zope development. It hasn't been superceded. TransWarp has several layers of functionality planned; only one of those layers has been released to date. (By the way, I also don't recall ever saying even that TransWarp was "better" than ZPatterns, let alone that it was some giant leap forward. I did say that it expanded further on the model which was the basis for ZPatterns, however.) Sorry for putting words in your mouth. My understanding was, though, that TransWarp will replace ZPatterns as the best tool for object model based development, which means that the idea of developing ZPatterns code with a view for long term future reuse suddenly isn't that attractive. As for "maintenance only", ZPatterns hasn't had any changes in months, except for patches provided by its users. That's largely because it hasn't needed any. There's not much you can *add* to ZPatterns, without a major upheaval. I figure, let the major upheaval be directed at making something completely different, rather than have major reworking to make something only marginally better. I fully agree. I just didn't expect something with a 0.4.3b2 version number to remain unchanged. Also, I remember you mentioning that you're working on an SQL DataSkin. If that was really a possibility in the past, and it won't happen, then it's a major loss. Documentation/examples is another area that still needs to be improved (although the community can be considered to be responsible for that as much as yourself). So what do we do now? Wrap up current ZPatterns work, writing it off as a loss for future reuse? Or can we count on 'maintenance only' being sufficient to support continued reused of ZPatterns efforts long enough to justify the original development effort? Someone asked a similar question of me at the conference. I told them that if I needed to develop a web-based application today, I would use ZPatterns with Zope. It works, it's stable, it gets the job done. If you use it for production sites, that's good enough for me :-) Also, recall that the RIPP model concept was introduced to the Zope community last January, and it was many months before ZPatterns' first release, then many more before it was stable enough to be ready for production use. Expect the same to be true of TransWarp. The tools released so far are rock solid, but there isn't anywhere near enough there to compete with ZPatterns yet. This is ok as long as you're choosing a tool per project. But I'm hate repeating work, and I expect the ZPatterns-based e-commerce app I'm building today to make the e-commerce app I build in 12 months a lot easier to build. So any changes in the basic tools I use bother me. Anyway, you did well calming my concerns. Thanks for that, and for releasing ZPatterns in the first place. -- -- Itai Tavor -- "Je sautille, donc je suis."-- [EMAIL PROTECTED]-- - Kermit the Frog -- -- -- -- "If you haven't got your health, you haven't got anything" -- ___ 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, ab
[Zope-dev] Designing ZPatterns/Python-product-based, reusable applications -take 2
, that I'd have more luck getting some help :-) 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. TIA Itai -- -- Itai Tavor -- "Je sautille, donc je suis."-- [EMAIL PROTECTED]-- - Kermit the Frog -- -- -- -- "If you haven't got your health, you haven't got anything" -- ___ 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 )
[Zope-dev] State of ZPatterns
Hi, I'm wondering where TransWarp leaves ZPatterns users. Until a couple of weeks ago ZPatterns was the best thing to happen in the Zope world since, well, Zope. Now it's described as a 'hack', demoted into 'maintenance only' mode, and superceded by something that is described as being as much better than ZPatterns as ZPatterns was better than standard Zope development. So what do we do now? Wrap up current ZPatterns work, writing it off as a loss for future reuse? Or can we count on 'maintenance only' being sufficient to support continued reused of ZPatterns efforts long enough to justify the original development effort? Do any other ZPatterns users share these concerns? Itai -- -- Itai Tavor -- "Je sautille, donc je suis."-- [EMAIL PROTECTED]-- - Kermit the Frog -- -- -- -- "If you haven't got your health, you haven't got anything" -- ___ 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] ZDebug conflicts with MailHost?
Shane Hathaway wrote: Dieter Maurer wrote: Itai Tavor writes: On Zope 2.3.0 and 2.3.1b1, the following method produces an error when ZDebug is installed; If I remove ZDebug, it works fine. A long time ago, there was firm evidence that ZDebug does not play well with "sendmail" (- list archives). But, I had thought, this had been fixed. It looks like an old feature was making bad vibes with dtml-sendmail. I traced the problem to an attempt to retrofit DTML with debugging information after it had been parsed. This is no longer necessary (if it ever really was), and when I removed it all was well. Thanks! http://www.zope.org/Members/hathawsh/ZDebug/ZDebug-0.2.1.tar.gz/view Shane Thanks for the fix. Works fine here. And sorry for not checking the archives :-) -- -- Itai Tavor -- "Je sautille, donc je suis."-- [EMAIL PROTECTED]-- - Kermit the Frog -- -- -- -- "If you haven't got your health, you haven't got anything" -- ___ 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 )
[Zope-dev] ZDebug conflicts with MailHost?
Hi, On Zope 2.3.0 and 2.3.1b1, the following method produces an error when ZDebug is installed; If I remove ZDebug, it works fine. dtml-sendmail mailhost=MailHost To: [EMAIL PROTECTED] From: [EMAIL PROTECTED] Subject: Test This is a test /dtml-sendmail With ZDebug the content of the sendmail tag is ignored; sendmail.send is called with all arguments empty. Traceback: Error type: TypeError Error value: len() of unsized object Traceback (innermost last): File /opt/Zope-2.3.0-linux2-x86/lib/python/ZPublisher/Publish.py, line 222, in publish_module File /opt/Zope-2.3.0-linux2-x86/lib/python/ZPublisher/Publish.py, line 187, in publish File /opt/Zope-2.3.0-linux2-x86/lib/python/Zope/__init__.py, line 221, in zpublisher_exception_hook (Object: ApplicationDefaultPermissions) File /opt/Zope-2.3.0-linux2-x86/lib/python/ZPublisher/Publish.py, line 171, in publish File /opt/Zope-2.3.0-linux2-x86/lib/python/ZPublisher/mapply.py, line 160, in mapply (Object: mailtest) File /opt/Zope-2.3.0-linux2-x86/lib/python/ZPublisher/Publish.py, line 112, in call_object (Object: mailtest) File /opt/Zope-2.3.0-linux2-x86/lib/python/OFS/DTMLMethod.py, line 189, in __call__ (Object: mailtest) File /opt/Zope/lib/python/Products/ZDebug/DTMLLocator.py, line 103, in __call__ (Object: mailtest) File /opt/Zope-2.3.0-linux2-x86/lib/python/DocumentTemplate/DT_String.py, line 538, in __call__ (Object: mailtest) File /opt/Zope/lib/python/Products/ZDebug/DTMLDebug.py, line 307, in debug_render_blocks File /opt/Zope/lib/python/Products/ZDebug/DTMLDebug.py, line 239, in debugException (Object: MailHost) File /opt/Zope/lib/python/Products/ZDebug/DTMLDebug.py, line 305, in debug_render_blocks File /opt/Zope-2.3.0-linux2-x86/lib/python/Products/MailHost/SendMailTag.py, line 188, in render (Object: MailHost) File /opt/Zope-2.3.0-linux2-x86/lib/python/Products/MailHost/MailHost.py, line 222, in send (Object: MailHost) File /opt/Zope-2.3.0-linux2-x86/lib/python1.5/smtplib.py, line 465, in sendmail File /opt/Zope-2.3.0-linux2-x86/lib/python1.5/smtplib.py, line 349, in mail File /opt/Zope-2.3.0-linux2-x86/lib/python1.5/smtplib.py, line 118, in quoteaddr File /opt/Zope-2.3.0-linux2-x86/lib/python1.5/rfc822.py, line 451, in parseaddr File /opt/Zope-2.3.0-linux2-x86/lib/python1.5/rfc822.py, line 496, in getaddrlist File /opt/Zope-2.3.0-linux2-x86/lib/python1.5/rfc822.py, line 504, in getaddress File /opt/Zope-2.3.0-linux2-x86/lib/python1.5/rfc822.py, line 484, in gotonext TypeError: (see above) -- -- Itai Tavor -- "Je sautille, donc je suis."-- [EMAIL PROTECTED]-- - Kermit the Frog -- -- -- -- "If you haven't got your health, you haven't got anything" -- ___ 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] DTML Documents/Folders in ZClasses fail to accessanything
Steve Alexander wrote: Itai Tavor wrote: Hi, I got a ZClass 'Test', with a DTML Method 'view' containing dtml-var id, and a DTML Document 'view2' with the same line. instance/view works. instance/view2 returns (ZDebug output): From SimpleItem.py: """Direct use of the 'id' attribute is deprecated - use getId()""" The difference you're seeing is because the DTML Method is acquiring the id attribute, whereas you're getting the DTML Document's own id attribute. Thanks, but it's got nothing to do with getId... I just used id because it's easy to write. I get the same behavior if I try to view meta_type, or a property that is defined on a propertysheet in the ZClass. And the fact that the DTML Document uses its own attributes shouldn't cause Unauthorized, should it? It should just show a different attribute, or acquire the attribute if it doesn't have it. I just tried it again with a clean install of Zope 2.3.0. In a DTML Document, this works (name is a property in the ZClass propertysheet): dtml-with "PARENTS[0]" dtml-var name dtml-var meta_type /dtml-with But these fail with Unauthorized: dtml-var name, dtml-var meta_type. The dtml-var title_or_id in standard_html_header fails as well. I also repeated the folder test: In a DTML Method stored inside a folder in the ZClass, dtml-var name works, but dtml-var title_or_id fails. So what do we have? I can't use title_or_id on DTML Documents, so it's useless for use in standard_html_header (and title_or_id uses getId, so it should work). I can't access ZClass properties from the DTML Document unless I use dtml-with - meaning no acquisition. And I can't access properties of the DTML Document (like meta_type) unless they are accessed using a method call (like getId()). This can't be right. I find it hard to believe that if this is really a bug, it didn't bother anybody else until now. On the other hand, these tests seem to show a problem with security checks on objects in ZClasses that create their own context. So what am I still missing here? Itai -- -- Itai Tavor -- "Je sautille, donc je suis."-- [EMAIL PROTECTED]-- - Kermit the Frog -- -- -- -- "If you haven't got your health, you haven't got anything" -- ___ 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 )
[Zope-dev] DTML Documents/Folders in ZClasses fail to access anything
Hi, I got a ZClass 'Test', with a DTML Method 'view' containing dtml-var id, and a DTML Document 'view2' with the same line. instance/view works. instance/view2 returns (ZDebug output): Error type: Unauthorized Error value: The object /test/view2, which is contained in /test/view2, is marked as private. Traceback (innermost last): File /opt/Zope-2.3.0-linux2-x86/lib/python/ZPublisher/Publish.py, line 222, in publish_module File /opt/Zope-2.3.0-linux2-x86/lib/python/ZPublisher/Publish.py, line 187, in publish File /opt/Zope-2.3.0-linux2-x86/lib/python/ZPublisher/Publish.py, line 171, in publish File /opt/Zope-2.3.0-linux2-x86/lib/python/ZPublisher/mapply.py, line 160, in mapply (Object: view2) File /opt/Zope-2.3.0-linux2-x86/lib/python/ZPublisher/Publish.py, line 112, in call_object (Object: view2) File /opt/Zope-2.3.0-linux2-x86/lib/python/OFS/DTMLDocument.py, line 189, in __call__ (Object: view2) File /opt/Zope/lib/python/Products/ZDebug/DTMLLocator.py, line 103, in __call__ (Object: view2) File /opt/Zope-2.3.0-linux2-x86/lib/python/DocumentTemplate/DT_String.py, line 538, in __call__ (Object: view2) File /opt/Zope/lib/python/Products/ZDebug/DTMLDebug.py, line 259, in debug_render_blocks File /opt/Zope/lib/python/Products/ZDebug/DTMLDebug.py, line 239, in debugException File /opt/Zope/lib/python/Products/ZDebug/DTMLDebug.py, line 256, in debug_render_blocks File /opt/Zope-2.3.0-linux2-x86/lib/python/OFS/DTMLMethod.py, line 261, in validate (Object: view2) File /opt/Zope-2.3.0-linux2-x86/lib/python/AccessControl/SecurityManager.py, line 144, in validate File /opt/Zope/lib/python/Products/ZDebug/DebugSecurityPolicy.py, line 304, in validate Unauthorized: (see above) The same happens if I place a copy of 'view' inside a Folder in the ZClass and call instance/folder/view, except that this time the Folder is flagged as the 'private' object. Why? What? Is this a bug? Or is it supposed to work this way and I just don't get it? Did I fall behind on my sheep sacrifices? Or was it changed to goats and I missed the memo? Environment: Zope 2.3.0, ZClass subclassing only ZObject, using stock acl_users and storing the instance in a standard Folder. -- -- Itai Tavor -- "Je sautille, donc je suis."-- [EMAIL PROTECTED]-- - Kermit the Frog -- -- -- -- "If you haven't got your health, you haven't got anything" -- ___ 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 )
[Zope-dev] ZPatterns goes crazy after ZClass change
Hi, I have a Rack which uses ZClass Company for storage. I renamed Company to CompanyX and created a new Company ZClass, giving it the same methods, propertysheets and properties as CompanyX. When I tried to view editInstanceForm_html of an instance of this class, I got the method stored in CompanyX. So I deleted CompanyX from the control panel. I still got the CompanyX method. I used the Rack's Storage tab to select another ZClass. Still got the method from CompanyX. when I click Remove Orphaned Slots on this Rack, I get: AttributeError _setRack Traceback (innermost last): File /opt/Zope-2.3.0-linux2-x86/lib/python/ZPublisher/Publish.py, line 222, in publish_module File /opt/Zope-2.3.0-linux2-x86/lib/python/ZPublisher/Publish.py, line 187, in publish File /opt/Zope-2.3.0-linux2-x86/lib/python/Zope/__init__.py, line 221, in zpublisher_exception_hook (Object: ProviderContainer) File /opt/Zope-2.3.0-linux2-x86/lib/python/ZPublisher/Publish.py, line 171, in publish File /opt/Zope-2.3.0-linux2-x86/lib/python/ZPublisher/mapply.py, line 160, in mapply (Object: manage_pack) File /opt/Zope-2.3.0-linux2-x86/lib/python/ZPublisher/Publish.py, line 112, in call_object (Object: manage_pack) File /opt/Zope/lib/python/Products/ZPatterns/Rack.py, line 418, in manage_pack (Object: ProviderContainer) File /opt/Zope/lib/python/Products/ZPatterns/Rack.py, line 59, in getItem (Object: ProviderContainer) File /opt/Zope/lib/python/Products/ZPatterns/Rack.py, line 114, in retrieveItem (Object: ProviderContainer) File /opt/Zope-2.3.0-linux2-x86/lib/python/OFS/Uninstalled.py, line 110, in __getattr__ (Object: broken) AttributeError: (see above) Any ideas how I can fix this without recreating the Rack and all my persistent data? -- -- Itai Tavor -- "Je sautille, donc je suis."-- [EMAIL PROTECTED]-- - Kermit the Frog -- -- -- -- "If you haven't got your health, you haven't got anything" -- ___ 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] AttributeError validate using the Visitor pattern
Hi David, You posted your questions 3 days ago, so maybe you found a solution by now... but this might still be useful to you. I just implemented a visitor similar to yours, with a few changes. It involves the following objects: Order and OrderLineItem. I created a Folder named 'displayItemVisitor' in Order containing: Order.displayItemsVisitor.displayItem (Python Script): paramsitem/params return item.accept(container, _) Order.displayItemsVisitor.visitLineItem (DTML Method): tddtml-qty;/td td class="price"dtml-var "getRetailAmount(qty, in_basket_date)" fmt=dollars-and-cents/td The 'accept' method of OrderLineItem is: paramsvisitor, _/params return visitor.visitLineItem(container, _) And the whole thing gets used in the DTML method that displays an order, using: dtml-in line_items dtml-var "displayItemsVisitor.displayItem(_['sequence-item'], _)" /dtml-in Interesting points: - I'm passing _ explicitly instead of relying on binding. I vaguely recall reading something about a problem binding the namespace. It might be fixed in the latest Python Scripts, I haven't tried the CVS version yet. - visitLineItem is called in the context of an OrderLineItem, so no dtml-with item is needed. - If you wanted the visitor to implement looping over the items (which is how the GoF do it) you could easily make something like: Order.displayItemsVisitor.displayItems (DTML Method): dtml-in line_items tr dtml-var "_['sequence-item'].accept(container, _)" /tr /dtml-in BTW, I never thought of using a visitor for this until you brought it up, so thanks! What I really like about it is that the same 'accept' method can be used by multiple visitors, each one implementing a different view of the object. So I can have displayItemsVisitor, displayItemsCompactVisitor, and displayItemsEditableVisitor, all calling item.accept(), and I avoid polluting my OrderLineItem class with multiple view methods. OTOH, it requires adding public access methods to OrderLineItem, because a view method in OrderLineItem can do dtml-var price, while the visitor must do dtml-var "getPrice()". Oh well, there's always a price to pay ;-) HTH, Itai R. David Murray wrote: OK, having helped me figure out how to work around the bug in accessing ZPatterns objects from a catalog, I've got a new challenge for you all. Now that I've got my list of objects, I want to generate a web page displaying them. The page has the structure of a series of table rows. Inside each row data about a single object is displayed, using a common format but with certain differences depending on the type of object. To implement this, I am trying to use the Visitor pattern from the Gang of Four book. So, I have a Folder displayItemList. This folder contains (at the moment) three methods: displayTable, visitAuthor, and visitBook. displayTable generates the html for the outer table, down to the tr/tr tags. Between those tags, it calls dtml-var "accept(me)", where me is this() for the displayTable method, and accept is a pythonscript method defined on each of the object type's Specialist. Each accept method is of the form: return visitor.visitBook(None,_,item=context) with _ bound to namespace on the bindings tab and 'visitor' being listed in the arguments line. visitBook begins with the line: dtml-with item Trying to display my list, I get an AttributeError on 'validate', and ZDebug flags the 'with' line as the error location. validate appears nowhere in my code, so from all I can figure from a certain amount of inspection of the source, Zope is looking for this method on the DTMLMethod and not finding it. ZDebug says the namespace stack consists of a single entry, which looks like the DTMLMethod itself (visitBook, presumably). Seems to me the namespace stack should be deeper than that. I've been poking at this for a couple hours now without making any more progress, so I'm going to quit for the day and come back to it tomorrow. If anybody has any bright ideas, or sees something obvious I'm doing wrong, please clue me in. Thanks! By the way, I also tried making accept be visitor.visitBook(context,_), but that produced the same error and ZDebug could only point to the call to accept as the error location. --RDM -- -- Itai Tavor -- "Je sautille, donc je suis."-- [EMAIL PROTECTED]-- - Kermit the Frog -- -- -- -- "If you haven't got your health, you haven't got anything" -- ___ 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 )
[Zope-dev] ZClass object on Rack retains old permission settings after beingchanged
Hi, I have an instance of a ZClass stored on a Rack.the ZClass contains a Folder named displayItemsVisitor. I changed the Folder's View permission to from 'View' to 'Manage Application Objects' which is a permission defined in my Product. I then gave viewOrder_html, which is a DTML Method that calls a method inside this Folder a proxy role which has the Manage Application Objects permission. Then I tried to view viewOrder_html. I got Unauthorized on access to displayItemsVisitor. Fine. I already know that ZClass permissions are a mine field, so I decided to give it up for now. So I returned everything to normal - set the View permission of displayItemsVisitor back to 'View' and removed the proxy role from viewOrder_html. When I tried to view viewOrder_html, I got the same Unauthorized error. So, I deleted displayItemsVisitor. Then I created a new one. Still Unauthorized. Cache problem? I set the Cache Target Size and Target max time to 0 and flushed the cache. Still Unauthorized. Interestingly, the cache page shows 1281 objects in the cache even after flushing. My best guess is that there is some cache problem with ZPatterns, where it continues to serve cached items and ignores object changes and cache flushing. In fact, I'm pretty sure there is a cache problem is ZPatterns, because on several occasions in the past ZPatterns continued to serve items after I deleted them from the database. So the question is, what do I do now? TIA, Itai -- -- Itai Tavor -- "Je sautille, donc je suis."-- [EMAIL PROTECTED]-- - Kermit the Frog -- -- -- -- "If you haven't got your health, you haven't got anything" -- ___ 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] Import Libraries into Python Script
Brian Lloyd wrote: What's wrong with: import imaplib imaplib.__allow_access_to_unprotected_subobjects__ = 1 Nothing is wrong with it per se - but using the SecurityInfo interfaces (even indirectly through the helper stuff I checked in to PythonScripts for 2.3.1) is more future-proof, in case the actual mechanics of protection change one day. Thanks for explaining. I read the release notes for 2.3.1 just hours after sending my question. Doing this with the new helper functions sounds like a good way. And, if the above is somehow bad or insecure, how would you use your method to allow access to specific methods in a module, as in: import re re.__allow_access_to_unprotected_subobjects__ = { 'sub': 1, } You can see a minimal example in the standard.py module in the PythonScripts package (though there is no helper shortcut for that method yet - there probably should be). A helper shortcut would be nice :) -- Itai Tavor -- "Je sautille, donc je suis."-- [EMAIL PROTECTED]-- - Kermit the Frog -- -- -- -- "Every day, once a day, give yourself a present" - Dale Cooper -- ___ 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] ZPatterns for Zope 2.3 convenience release
Steve Alexander wrote: Itai Tavor wrote: Steve Alexander wrote: Itai Tavor wrote: Steve, This release breaks access to the management screens of ZClasses stored on Racks. In Zpatterns-0.4.2a3, Specialist/item_id/manage returns the ZClass management screen. In your release it returns the Specialist Methods screen. Thanks. I'll look into this. As a workaround, you can use Specialist/item_id/manage_workspace instead. Yeah, that works. Thanks. What version of Zope have you seen the desired Specialist/item_id/manage behaviour with? 2.3, release version. item_id/manage gets redirected to item_id/manage_main which shows the ZClass management screen. BTW, this might be a good time to mention a related problem in the stock ZPatterns - even there item_id/manage doesn't work as expected - it brings up the ZClass management tabs with the first one selected, but the page content is actually an empty Methods screen. So a click on the first tab is required to actually get to the ZClass info. item_id/manage_workspace gets around that. Perhaps you can investigate this while you're looking at the other problem? Changing PlugIns.py, line 145 from manage_main = DTMLFile('www/main', globals()) to manage_main = HTMLFile('www/main', globals()) (make sure you've imported HTMLFile too) restores the behaviour of ZPatterns-0-4-3b2. Yep, it does. Thanks. If you try adding any normal ZClass in a normal folder, you get the behaviour that you're reporting as a bug for ZPatterns-convenience. Hmmm... you're right. Never noticed that before. Sorry for blaming your release. Therefore, I reckon the original behaviour with ZPatterns-0.4.3b2 is incorrect, and the behviour with ZPatterns-convenience-release is consistent with how ZClasses work in the rest of Zope. So it was a bug in ZPatterns, which resulted in useful behavior, but was then "fixed" by your release, so now the bug has to be put back in to return the erroneous but useful behavior :-) If you're not happy with the behaviour of a_zclass_instance/manage_main, then that will need changing for all Zope and not just ZPatterns. Stick a report in the Collector perhaps? Done. Maybe it's not such a huge problem but I think it's reasonable to expect /manage to do the same thing no matter what type of object you're accessing. -- Itai Tavor -- "Je sautille, donc je suis."-- [EMAIL PROTECTED]-- - Kermit the Frog -- -- -- -- "Every day, once a day, give yourself a present" - Dale Cooper -- ___ 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] ZPatterns for Zope 2.3 convenience release
Steve Alexander wrote: Itai Tavor wrote: Steve, This release breaks access to the management screens of ZClasses stored on Racks. In Zpatterns-0.4.2a3, Specialist/item_id/manage returns the ZClass management screen. In your release it returns the Specialist Methods screen. Thanks. I'll look into this. As a workaround, you can use Specialist/item_id/manage_workspace instead. Yeah, that works. Thanks. What version of Zope have you seen the desired Specialist/item_id/manage behaviour with? 2.3, release version. item_id/manage gets redirected to item_id/manage_main which shows the ZClass management screen. BTW, this might be a good time to mention a related problem in the stock ZPatterns - even there item_id/manage doesn't work as expected - it brings up the ZClass management tabs with the first one selected, but the page content is actually an empty Methods screen. So a click on the first tab is required to actually get to the ZClass info. item_id/manage_workspace gets around that. Perhaps you can investigate this while you're looking at the other problem? This looks to me more like something in Zope has changed, (probably to do with how __bobo_traverse__ works) as I don't think any of my changes to ZPatterns would cause the change you're reporting. It must be related to something you changed in your release because the behavior changes when I switch between the original ZPatterns and your release, on the same Zope. I'm definitely seeing what you describe on Zope 2.3 from CVS, with the ZPatterns convenience release. To check this, I'll try an unpatched ZPatterns-0.4.3b2 with Zope 2.3, and see if I can reproduce the bug with that. -- Steve Alexander Software Engineer Cat-Box limited http://www.cat-box.net -- Itai Tavor -- "Je sautille, donc je suis."-- [EMAIL PROTECTED]-- - Kermit the Frog -- -- -- -- "Every day, once a day, give yourself a present" - Dale Cooper -- ___ 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] ZDebug patch for 2.3.0
Thanks! Good to have ZDebug back. But... it kills LoginManager, which uses an exception to render the login page. This patch will fix the problem: --- DTMLDebug.py.old Fri Sep 15 09:25:14 2000 +++ DTMLDebug.pyTue Jan 30 10:45:43 2001 @@ -217,6 +217,9 @@ elif exc_type is DTReturn: # Return normally. raise +elif str(exc_type) == 'LoginRequired': +# Don't interfere with LoginManager. +raise else: debugWithNamespace(section, namespace, None, info) finally: Chris Withers wrote: The patch below got ZDebug working with Zope 2.3.0 for me. Hope I didn't miss anything ;-) cheers, Chris snip patch -- -- Itai Tavor -- "Je sautille, donc je suis."-- [EMAIL PROTECTED]-- - Kermit the Frog -- -- 'Supposing a tree fell down, Pooh, when we were underneath it?' -- -- 'Supposing it didn't,' said Pooh after careful thought. -- ___ 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] Possible TransparentFolders bug?
I thought this problem was gone, but I was wrong. I deleted everything from the database that isn't directly involved in this problem. I also deleted all Transparent Folders. http://yourserver:8080/method_A still works. http://yourserver:8080/method_A/manage_main shows the path as /method_A. Disabling the TransparentFolders patch and restarting, http://yourserver:8080/method_A returns Not Found. Renaming Folder_A to Folder_AX, http://yourserver:8080/method_A returns Not Found. Creating a new folder named Folder_A and copying everything from the original Folder_A into it, http://yourserver:8080/method_A still returns Not Found. So we're dealing with serious voodoo here. It seems that I can eliminate the problem by simply copying the project to a new directory. But I would very much like to know what is going on here, rather than just sweep the problem away. I just know it will come back to bite me if I do that. Itai The Infinitely Annoyed Shane Hathaway wrote: Itai Tavor wrote: The TransparentFolders Product seems to make everything transparent... not just transparent folders. Zope/ Folder_A/ method_A Folder_B/ (transparent folder) method_B I'd expect the only effect of the transparent folder to be that /Folder_A/method_B would work. But /method_A and /method_B also work. Tested in Zope 2.3b2 and 2.3b3 with TransparentFolders 0.3. Hmm... I can't get mine to do that. You're sure Folder_A isn't transparent also? Did you ever have a transparent folder by that name, in that same place? (Indicating a bug) Otherwise leaving things as they are, if you put a transparent folder at the root of the site, do you still get the same behavior? What path does it tell you if you visit http://yourserver:8080/method_{A|B}/manage_main? Shane -- -- Itai Tavor -- "Je sautille, donc je suis."-- [EMAIL PROTECTED]-- - Kermit the Frog -- -- 'Supposing a tree fell down, Pooh, when we were underneath it?' -- -- 'Supposing it didn't,' said Pooh after careful thought. -- ___ 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 )
[Zope-dev] LoginManager and Control_Panel - The Never Ending Story
Hi, I posted several questions about this problem, but got no replies. I thought I'd try again with a bit more information. The problem is accessing Control_Panel from a folder that contains a LoginManager. I tested the same setup using a plain acl_users and found one difference. Zope/ acl_users/ user_1 (Manager) Test1/ acl_users/ (User Folder) user_2 (Manager) cnt1 (owned by user_1, Manager proxy role) cnt2 (owned by user_2, Manager proxy role) Test2/ acl_users/ (LoginManager) user_3 (Manager) cnt1 (owned by user_1, Manager proxy role) cnt2 (owned by user_3, Manager proxy role) cnt1 and cnt2 are DTML Methods containg: dtml-var Control_Panel fmt=html-quote Logging in to /Test1/ with user_2, both /Test1/cnt1 and /Test1/cnt2 return the Control_Panel object. Loggin in to /Test2/ with user_3, /Test2/cnt1 return the Control_Panel object. /Test2/cnt2 returns KeyError: Control_Panel. ZDebug reports: Unauthorized: User itai, who is the owner of /OzCoasters/cnt2, is defined in the context of /OzCoasters, which is not an ancestor of /Control_Panel. Hope anyone can understand this... it's confusing the stuffing out of me. But basically, the Manager proxy role allows a method to access Control_Panel regardless of where its owner and the logged in user are defined. But with LoginManager, Control_Panel is only accessible if the owner is defined in a regular User Folder above the LoginManager. Any idea why this is happening? Any suggestions on how to test it? I know it's more likely to be a problem in my implementation of the user-supplied parts of LoginManager than a bug in LM... but my LM works in all other ways, and it doesn't seem to be doing anything wrong. Any help would be, er, helpful (To borrow the words of King Arthur. Hey, a python reference! Do I get points for that?) -- -- Itai Tavor -- "Je sautille, donc je suis."-- [EMAIL PROTECTED]-- - Kermit the Frog -- -- 'Supposing a tree fell down, Pooh, when we were underneath it?' -- -- 'Supposing it didn't,' said Pooh after careful thought. -- ___ 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] Possible TransparentFolders bug?
I can't reproduce this problem myself. In fact, as of this morning it doesn't happen anymore. Guess it was just one of those flukes the universe throws at me to try to convince me to move to another universe. Shane Hathaway wrote: Itai Tavor wrote: The TransparentFolders Product seems to make everything transparent... not just transparent folders. Zope/ Folder_A/ method_A Folder_B/ (transparent folder) method_B I'd expect the only effect of the transparent folder to be that /Folder_A/method_B would work. But /method_A and /method_B also work. Tested in Zope 2.3b2 and 2.3b3 with TransparentFolders 0.3. Hmm... I can't get mine to do that. You're sure Folder_A isn't transparent also? Did you ever have a transparent folder by that name, in that same place? (Indicating a bug) Otherwise leaving things as they are, if you put a transparent folder at the root of the site, do you still get the same behavior? What path does it tell you if you visit http://yourserver:8080/method_{A|B}/manage_main? Shane -- -- Itai Tavor -- "Je sautille, donc je suis."-- [EMAIL PROTECTED]-- - Kermit the Frog -- -- -- -- "If you haven't got your health, you haven't got anything" -- ___ 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] Local roles and security of ZClass instances inSpecialists
Hi Steve, This is a nice idea... but I can't get it to work. it works fine when changing properties: WHEN OBJECT CHANGED CALL self.checkForPermission(REQUEST) But is ignored for accessing properties: WITH self.checkForPermission(REQUEST) COMPUTE spam='eggs' simply fails to set spam if checkForPermission raises an exception, because ZPatterns catches all exceptions in COMPUTE clauses (I never understood the point of this, BTW. It just gets in the way of debugging. Wouldn't catching just AttributeError and KeyError be enough?) and the exception gets dumped to the console. Which could actually be considered to work, because the method doing the access will fail... but that would be ugly and definitely not what I want. Also, I want a solution that would work regardless of the storage method - I don't think this one won't work for ZODB storage. In a Rack using persistent storage and having a property 'spam', the SkinScript clause: WITH self COMPUTE spam='eggs' will be ignored. So the SkinScript can be used to control access only if it's already being used to load the properties. Which all comes down to having to do the security checks in all the methods that access the object :-( Unless you can show me something I missed? Steve Spicklemire wrote: Hi Itai, I'm sure there's something clever you could do here with an attribute provider for you user object that supplied __roles__ dynamically somehow, but I'd need to think about that more... one easy way to limit who can see different stuff is to use a wrapper around your access methods (e.g., SQL queries) that checks for security: e.g., WITH [ QUERY ] LookupAttributesAndCheckForPermission(REQUEST) COMPUTE foo, bar, baz where LookupAttributesAndCheckForPermission get's everything it needs out of the REQUEST. It's a crude tool.. but it's simple. When I get some time to think clearly.. I'll try to come up with something more general. Hopefully you'll also get some other suggestions... -steve "Itai" == Itai Tavor [EMAIL PROTECTED] writes: Itai Hi, Itai I'm trying to work out a security strategy for data stored Itai in Specialists, where specific users need access to specific Itai data instances. Itai For example: A Customer object is linked to a Person and Itai Address objects. The customer needs permission to edit the Itai her - and only her - Address object. Using the Owner local Itai role won't work, because customers can be registered by site Itai managers and customer support people, in which case Owner Itai won't be the customer. Itai I can solve this by giving the customer a local role when Itai creating her Address object: Itai Customers.addCustomer(REQUEST): ni = Itai container.addItem(some_id) Itai container.Addresses.addAddressFor(ni.id, REQUEST) Itai Addresses.addAddressFor(for_id, REQUEST): ni = Itai container.addItem(some_id) ni.manage_addLocalRole(for_id, Itai 'EditMyDetails') Itai But this can be a lot of work - If an Address object can Itai also be created for a CreditCard object, addCreditCard will Itai have to both set its own local role, and pass the customer Itai id on to Address... Itai But the main problem is that I'm not sure if it will work at Itai all - can local roles be set for DataSkins that aren't Itai stored in the ZODB? From what I can see ZPatterns doesn't Itai support this, so I'll have to do it Itai myself. __ac_local_roles__ can't be accessed in a SkinScript Itai - so will I have to override has_local_roles, Itai get_local_roles and get_local_roles_for_userid and call them Itai from the SkinScript? This is getting hairy... Itai Without local roles, all I can think of is explicitly Itai checking that the logged in user is the right customer in Itai all the methods that display and edit the object, which is Itai very ugly. Plus it would require Address to know a Itai customer_id even when it actually belongs to a CreditCard, Itai not a Customer... there goes Demeter. Or I can add a Itai findUserID to Address, CreditCard and Customer, all of which Itai pass the request upwards until one is reached that actually Itai knows the customer. Still ugly. Itai TIA for Any comments/suggestions. Itai Itai -- Itai Tavor "Je sautille, donc je suis." C3Works Itai [EMAIL PROTECTED] - Kermit the Frog Itai "If you haven't got your health, you haven't got anything" Itai ___ Zope-Dev Itai maillist - [EMAIL PROTECTED] Itai http://lists.zope.org/mailman/listinfo/zope-dev ** No cross Itai posts or HTML encoding! ** (Related lists - Itai http://lists.zope.org/mailman/listinfo/zope-announce Itai http://lists.zope.org/mailman/listinfo/zope ) -- -- Itai Tavor
[Zope-dev] Possible TransparentFolders bug?
Hi, The TransparentFolders Product seems to make everything transparent... not just transparent folders. Zope/ Folder_A/ method_A Folder_B/ (transparent folder) method_B I'd expect the only effect of the transparent folder to be that /Folder_A/method_B would work. But /method_A and /method_B also work. Tested in Zope 2.3b2 and 2.3b3 with TransparentFolders 0.3. -- -- Itai Tavor -- "Je sautille, donc je suis."-- [EMAIL PROTECTED]-- - Kermit the Frog -- -- 'Supposing a tree fell down, Pooh, when we were underneath it?' -- -- 'Supposing it didn't,' said Pooh after careful thought. -- ___ 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 )
[Zope-dev] Local roles and security of ZClass instances in Specialists
Hi, I'm trying to work out a security strategy for data stored in Specialists, where specific users need access to specific data instances. For example: A Customer object is linked to a Person and Address objects. The customer needs permission to edit the her - and only her - Address object. Using the Owner local role won't work, because customers can be registered by site managers and customer support people, in which case Owner won't be the customer. I can solve this by giving the customer a local role when creating her Address object: Customers.addCustomer(REQUEST): ni = container.addItem(some_id) container.Addresses.addAddressFor(ni.id, REQUEST) Addresses.addAddressFor(for_id, REQUEST): ni = container.addItem(some_id) ni.manage_addLocalRole(for_id, 'EditMyDetails') But this can be a lot of work - If an Address object can also be created for a CreditCard object, addCreditCard will have to both set its own local role, and pass the customer id on to Address... But the main problem is that I'm not sure if it will work at all - can local roles be set for DataSkins that aren't stored in the ZODB? From what I can see ZPatterns doesn't support this, so I'll have to do it myself. __ac_local_roles__ can't be accessed in a SkinScript - so will I have to override has_local_roles, get_local_roles and get_local_roles_for_userid and call them from the SkinScript? This is getting hairy... Without local roles, all I can think of is explicitly checking that the logged in user is the right customer in all the methods that display and edit the object, which is very ugly. Plus it would require Address to know a customer_id even when it actually belongs to a CreditCard, not a Customer... there goes Demeter. Or I can add a findUserID to Address, CreditCard and Customer, all of which pass the request upwards until one is reached that actually knows the customer. Still ugly. TIA for Any comments/suggestions. Itai -- Itai Tavor"Je sautille, donc je suis." C3Works[EMAIL PROTECTED] - Kermit the Frog "If you haven't got your health, you haven't got anything" ___ 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] ZPatterns, ZClasses, Specialists: Assigningresponsibilities
Phillip J. Eby wrote: At 05:13 PM 12/21/00 +1100, Itai Tavor wrote: I think you're right about this being an OrderLineItem. A couple of fine points, however... First, I don't think there needs to be an "OrderLineItemsWithGraphic" specialist, since there is nothing else that would talk to it. It's fine in this case to have the line item classes (either with graphic or without) handle their own UI snippets. UI delegation is for when an object needs to display UI for some *other* object than itself, since you can always use class extenders and other techniques to reshape the apparent class of an object retrieved from a specialist. The interface which other objects deal with is "OrderLineItem", and they simply expect a portion of the form to be rendered, and it's okay for the class to handle that. I got a bit confused here... the UI snippet for uploading a graphic actually comes from the Graphics Specialist. That's fine, but it should be by way of an object that's filling the OrderLineItem role, yes? But how can this work? If I ask for the graphic in Product.addMeToOrderForm, an OrderLineItem object doesn't exist yet. So Product has to ask the OrderLineItems Specialist for the UI snippet, and OrderLineItems gets it from the Graphics Specialist. Then Product.addMeToOrder can create a new OrderLineItem and hand it the form fields for the graphic. Although, to make it cleaner, Product would add OrderLineItems.newLineItemSnippet to the form, and OrderLineItems would decide what needs to be included in the form - so Product doesn't have to explicitly ask for a Graphic upload form. Or I could eliminate the problem by uploading the graphic from a form displayed by the order line item after it has been added. That's actually what I thought you were doing/intending. This is probably the best way... but it wasn't my original plan. I need to ask for a quantity for every added product, so I was going to have Product.addMeToOrderForm ask for quantity and for a graphic. But instead, I can add a quantity field to the product display page, next to the "Add to Order" button. Then addMeToOrderForm isn't needed at all, Product.addMeToOrder will create a new OrderLineItem object, which will then ask for the graphic if it's needed. Here's the question... how many behaviors are different in the order line item itself? Are you also using fulfillment line items? If the only difference to the order line item is that it references some additional data, then I'd say a single class would be fine. Most of the behavior probably comes in on the fulfillment line item, yes? Again, you can ask your FulfillmentLineItems specialist to create "newLineItemFor(orderLineItem)" and let it decide what kind of implementation to hand back. In this case, it probably will be a different class, while for the order line items, it may or may not buy you anything. I haven't thought of using fulfillment line items... not sure what they are for? An order is considered fulfilled once all items have been shipped, so order line items are responsible for tracking everything that happens until a ShipmentLineItem is created. The order line item for a customizable product tracks the product using state values like 'sent to factory', 'received from factory', etc. So it needs a new set of state values, as well as methods like 'sendManufacturingOrderToFactory'. What exactly does the fulfillment role you're referring to do? Does it do more than a shipment role? Fulfillment would be between ordering and shipping, covering such things as pulling items from the warehouse to customizing them with the graphic. I assumed that an order line item was only meaningful until you have a completed order. You may not need the complexity, but to me it seems like a seperate phase with a very different set of behaviors than what I would think of as an order line item. If I were doing an app like this, I'd at least have some sort of state/status objects to delegate these different behaviors to. But I'd say this could be left to the taste of the chef. :) This is confusing... because in all the E-com designs I've looked at, the order state machine covers everything up to 'order fulfilled'... you're suggesting stopping the order states at 'order authorized' and moving the fulfillment states to the fulfillment object? Also, what do you mean when you say 'state/status objects'? I can understand having OrderLineItem, FulfillmentLineItem and ShippingLineItem where each covers a different range of states, but are you suggesting having separate objects just for tracking the state? -- Itai Tavor"Je sautille, donc je suis." C3Works[EMAIL PROTECTED] - Kermit the Frog "If you haven't got your health, you haven't got anything" ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/m
Re: [Zope-dev] ZPatterns example update....
Steve Spicklemire wrote: Hi Folks, The Dumb ZPatterns example is updated. Now there is some more realistic object referencing going on, borrowing of code snippets between Specialists and suchlike. There is also more in the way of reasonable documentation, though everything is in flux, and it still doesn't resemble a truly completed product. I just feel the need to get things finished enough that I can stop thinking about them for a while. ;-) In particular there the ToDos now hold references to Doer and Deliverable, and no 'lists' are maintained. One thing I need to do is to have these references automatically 'fixed' when a 'referred to' entity is removed or modified in such a way that the link should be broken that's for the next version. If I'm not careful.. it won't be a 'simple' example anymore. There's got to be a line here somewhere (in the sand?). Nice work, Steve. Removing id lists looks good. I started building objects using getXForY(y_id), but the last one I made used an id list following the Dumb Example. I've just changed it to use getXForY, and it's much cleaner, plus it makes adding X from Y/editInstanceForm easier. I like the idea of naming all UI methods with '_html' - now, if you find yourself referencing a method which doesn't end in '_html' in your html code, you know you need to add an interface method. I just need to decide if I like it enough to change all my existing code... Some thoughts about the broken links handling problem: If an object depends on the existence of another (for example, if you wanted a ToDo to be tightly linked to a Deliverable) then it should be deleted when the Deliverable is deleted, right? You'd have WHEN OBJECT DELETED CALL ToDos.deleteInstances(myToDoIDs) in the Deliverable SkinScript, and you would never have ToDos floating around without a Deliverable. As for the Deliverable changing and invalidating the link, I think it would be solved if you used immutable ids for all objects, and stored the Deliverable title in a separate property. In case of weaker links, such as between ToDo and Doer, I guess it should be ToDo's responsibility to return None if the Doer referenced by doerID doesn't exist - treating it the same way as the case where no doer has been assigned. Maybe with this SkinScript: WITH Doers.getItem(self.doerID) CALCULATE self.doerID=RESULT.id or '' ? But I'm not really sure about this... I think you've managed very well to stay on the right side of the line in the sand... the problem is that complex real world applications have a lot of stuff on the other side of the line, and the challenge is to pull that stuff over the line. My personal problem is figuring out if the stuff I have on the wrong side of the line is necessitated by the complexity of the application, or if I'm just making things unnecessarily complicated... Itai -- Itai Tavor"Je sautille, donc je suis." C3Works[EMAIL PROTECTED] - Kermit the Frog "If you haven't got your health, you haven't got anything" ___ 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] ZPatterns, ZClasses, Specialists: Assigning responsibilities
o order line items are responsible for tracking everything that happens until a ShipmentLineItem is created. The order line item for a customizable product tracks the product using state values like 'sent to factory', 'received from factory', etc. So it needs a new set of state values, as well as methods like 'sendManufacturingOrderToFactory'. What exactly does the fulfillment role you're referring to do? Does it do more than a shipment role? Itai -- Itai Tavor"Je sautille, donc je suis." C3Works[EMAIL PROTECTED] - Kermit the Frog "If you haven't got your health, you haven't got anything" ___ 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] Re: ZPatterns, ObjectDomain, UML and all that.....
Hi Itai, Ok.. I'm working an DumbZPatternsExample V3.0 so this is exactly the sort of conversation that needs to take place for me. ;-) Godd to hear that (both that the discussion is helping you, and that you're working on a new dumb example :-) ) It seems to me that when you want a Reseller, or a Customer you certainly want to go to the Resellers or Customers Specialist and ask for the Participant. So.. since there is never more than one Actor for each Participant, I think I'd keep the information about the actor_id in the Participant. I might even suggest that you could use the actor_id as the participant_id, depending on how these id's are implemented. (it seems that it would be particularly nice if the ids are known to be globally unique that you could use this fact to help identifying relationships...) I'm already using globally unique ids, but still, doesn't using the same id for the Participant and the Actor make these objects too tightly coupled? Seems to me that Actors should provide an interface for finding actors to the rest of the application; other objects should not make assumptions about the internal storage of Actors, and particularly what ids they use. No? Now.. you seem to be asking how to run it the other way around. How do we get the correct Participant from the Actors specialist? Hmm... I'm not sure what the scenario would be that would require this, but it seems to me that it's a reasonable enough possibility. Well, Actors store user info such as login_name, password, and roles. So it's natural (I think) for acl_users to authenticate against Actors, rather than ask each Participant Specialist to search all the Actors associated with its Participants. So AUTHENTICATED_USER is an Actor. But the application needs to know the Participant - for example, if a Customer is placing an order, she will be asked to identify her Reseller. But if a Reseller is placing the order, the application already knows the Reseller, but it needs to ask for a Customer. So, from the Actor, I need to know the Participant type, id, name, etc. Unless, of course, I'm making things too complicated again, and it really is better to authenticate Participants rather than Actors... How about a little search... : PythonScript: getParticipantFor( self, participantSpecialistList ) while Participants in participantSpecialistList: theParticipant = Participants.getParticipantForActor( self.actor_id ) if theParticipant is not None: break return theParticipant It's up to the 'Participants' Specialists to implement getParticipantForActor based on the actor_id. (if actor_id is the same as reseller_id then it's just getItem!) Now... to make this slick, add an attribute handler for your actor that does this automagically when you ask for 'participant'. I think something like: WITH self.getParticipantFor( [Resellers, Customers] ) COMPUTE myParticipant = RESULT or NOT_FOUND should do it. In code you just say: resellerName = self.myParticipant.name or somthing like that. Of course.. I've not tried this. But it *seems* like it should work. ;-) I imagine it would... and it looks pretty good. The question is, and that brings us back to the object connections table, whether this is really the way you would want to do it. Itai -steve "Itai" == Itai Tavor [EMAIL PROTECTED] writes: Itai There might be many ways to implement each connection, but I Itai think that there will always be one or two ways that would Itai be simplest and most robust... so this would not only save Itai you the trouble of figuring it out alone every time, but Itai would also prevent you from getting stuck down the road. Itai The problem is that we have at best guesses, and at worst Itai empty table cells in the guide. I'm still struggling with Itai many of these... The worst one seems to be XOR type Itai connections, where a Specialist implementing a role is not Itai involved. Example: Itai Actor: Person. Itai Participants: Customer, Reseller Itai Object connections: (Customer) 1---[XOR A] 1 (Actor) Itai [XOR A] 1---1 (Reseller) Itai acl_users Login Manager authenticates users using Actor Itai objects (by connecting the the Actors Specialist). The Itai application needs to identify the Participant. Itai If you add participant_id to Actor, you still don't know Itai which Participant Specialist to load the Participant Itai from. You don't want to add participant_type to Actor (at Itai least, I don't think you do - it seems real ugly). So, what Itai do you do? Do you place the Customers and Resellers Itai Specialists inside a Participants Specialist? We'll have to Itai call it MegaSpecialist :-). Bad idea - other parts of the Itai application have to access Resellers specifically, so Itai Resellers should not be hid
Re: [Zope-dev] urllib not available in Python Scripts?
Evan Simpson wrote: From: "Itai Tavor" [EMAIL PROTECTED] import urllib urllib.__allow_access_to_unprotected_subobjects__ = 1 Ok, this is simple enough, and it works. But... it opens access to everything in urllib. For now, the best way is to use a dictionary of names, like this: import urllib urllib.__allow_access_to_unprotected_subobjects__ = { 'quote': 1, 'unquote': 1, } Cheers, Evan @ digicool 4-am Thanks! Nice and simple. The moral of this story is, you got to know what to ask :-) -- Itai Tavor"Je sautille, donc je suis." C3Works[EMAIL PROTECTED] - Kermit the Frog "If you haven't got your health, you haven't got anything" ___ 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] ZPatterns, ZClasses, Specialists: Assigningresponsibilities
Itai Tavor wrote: I have the following ZClasses, with matching Specialists: Product, Graphic, Order, OrderLineItem. When a customer adds a product to their order, they have to provide a graphic file which will be printed on the product (imagine buying a lunch box with your cat's photo on it). The Graphics Specialist can provide a addGraphicSnippet form. But who's responsible for asking for this graphic when adding the product to the order? Is it still the Product object? But a Product turns into a Product-with-Graphic only when it's a part of an order, so is it correct for the Product to even know about Graphics? the alternative is to move the addToOrder methods to either Order or OrderLineItems, but this doesn't make any more sense because these would then have to know a lot more about a Product than is good for them. Any ideas? Sounds to me like you have a new type of Product. You have your basic products (of which there are many kinds), and you have ProductWithGraphic products. A ProductWithGraphic is a "calculated product": it is composed of a basic product and a graphic. Its cost, delivery time, packing charge, and so forth, are calculated based on the combination of the basic product and the graphic. To the rest of the application, a ProductWithGraphic is just another kind of product. Thanks, this is an interesting suggestion... but I'm not sure how it would work. It gets very complicated when I try to think of implementing it. The application accesses products using a Products Specialist, with a Rack for each type of product. The contents of these Racks make up the Product catalog of the store. The Products Specialist implements the role of 'things that can be added to an order'. On the other hand, ProductWithGraphic is not part of the store's catalog. A new instance of it is created every time a shopper adds a product to their cart. So it does not fill the role 'thing that can be added to an order'. rather, its role is of something that has been ordered and is being fabricated. So treating ProductWithGraphic as another kind of Product doesn't seem to make sense... I do realize I need a new kind of product - CustomizableProduct. But, looking at the role of a ProductWithGraphic, it looks a lot more like an OrderLineItem than a Product. It's part of an order. It's state changes are part of the order handling process. So wouldn't it make sense to have a lineItemWithGraphic object in the OrderLineItems Specialist? That seems much simpler to me... except that the responsibilities question in it is still open. Back to square 1. This is how I see it: - Products Specialist productRack customizableProductRack - OrderLineItem Specialist lineItemRack lineItemWithGraphicRack - product.addMeToOrder(): order.addLineItem(product_id=id, add='lineItem') - custimazable_product.addMeToOrder(): order.addLineItem(product_id=id, add='lineItemWithGraphic') I imagine, then, that the UI for uploading the graphic would be included in product.addMeToOrderForm, using a UI snippet from the OrderLineItemsWithGraphic Specialist. Then I could pass REQUEST on to order.addLineItem and to OrderLineItemsWithGraphic.add, which would then upload the file? Woof... so long. I'd appreciate any comments on this - especially on the question on whether it's better to have a specialized type of OrderLineItem, or to link the standard OrderLineItem to a Product object in case of a standard product, or, in the case of a customizable product, to a new object which stores the graphic and tracks the fabrication of the customized item. TIA Itai -- Itai Tavor"Je sautille, donc je suis." C3Works[EMAIL PROTECTED] - Kermit the Frog "If you haven't got your health, you haven't got anything" ___ 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] A couple of possible Python Scripts bugs
Evan Simpson wrote: From: Itai Tavor [EMAIL PROTECTED] First, when trying to add a Python Script, I sometimes get: Error Type: AttributeError Error Value: tx Thanks! Fixed in CVS. return container.domains returns AttributeError. This does not occur if I try to read a property on the first propertysheet in the ZClass. Also, getProperty('domains') works in the Python Script. And this Python Script: Sorry, I can't replicate this on Zope 2.3 alpha 1. I'm the one who should be sorry. I forgot to mention I was using 2.2.4. And I know Python Scripts are not certified to work with 2.2.4, so this is pretty much irrelevant. I'm glad the first item turned out to be a real bug! -- Itai Tavor"Je sautille, donc je suis." C3Works[EMAIL PROTECTED] - Kermit the Frog "If you haven't got your health, you haven't got anything" ___ 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 )
[Zope-dev] ZPatterns, ZClasses, Specialists: Assigning responsibilities
I'm having problems deciding where certain methods should be implemented. In some cases it's easy - for example, objects manage themselves, Specialists manage collections, so editInstanceForm belongs in the ZClass, while listOpenOrders belongs in the Specialist. But here are some cases where it's not as clear: 1. I want to edit an object from the editing form of another object. So I give my object an editInstanceSnippet method. It's very similar to editInstanceForm, except that it's not a full html document. Should it go in the ZClass? But it's a method used for application integration - so maybe it belongs in the Specialist? 2. In a typical shopping cart application, a Product object will be responsible for adding itself to an order, right? So the Product will have an addMeToOrderForm, which will call addMeToOrder, which in turn will call order.addOrderLineItem method. I think. But here's a complication: I have the following ZClasses, with matching Specialists: Product, Graphic, Order, OrderLineItem. When a customer adds a product to their order, they have to provide a graphic file which will be printed on the product (imagine buying a lunch box with your cat's photo on it). The Graphics Specialist can provide a addGraphicSnippet form. But who's responsible for asking for this graphic when adding the product to the order? Is it still the Product object? But a Product turns into a Product-with-Graphic only when it's a part of an order, so is it correct for the Product to even know about Graphics? the alternative is to move the addToOrder methods to either Order or OrderLineItems, but this doesn't make any more sense because these would then have to know a lot more about a Product than is good for them. Any ideas? TIA Itai -- Itai Tavor"Je sautille, donc je suis." C3Works[EMAIL PROTECTED] - Kermit the Frog "If you haven't got your health, you haven't got anything" ___ 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 )
[Zope-dev] urllib not available in Python Scripts?
Hi, sorry for the recent barrage of posts... In Python Methods I could do urllib.quote(...). This doesn't work in Python Scripts. Is quote considered a security risk? Itai -- Itai Tavor"Je sautille, donc je suis." C3Works[EMAIL PROTECTED] - Kermit the Frog "If you haven't got your health, you haven't got anything" ___ 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 )
[Zope-dev] Adding and setting properties from a virtual Specialist
Hi, I have a Specialist ('OrderingEntities') which creates virtual objects, mapped to existing objects (using ZClass 'Employee') in another Specialist ('Employees'). I want OrderingEntities to add and modify a property 'current_order_id' on the Employee objects. I can get the virtual object to access properties from the real object, but I can't figure out how to implement the property add/change. To make things simpler, I added the property current_order_id to the Employee class, so I can test just modifying this property, leaving creating it for later. OrderingEntities has an employeeRack, set to use the Employee class and to load by accessing attribute current_order_id. The Rack has this SkinScript: WITH Employees.getItem(self.id) COMPUTE original_object=RESULT or NOT_FOUND WITH self.original_object COMPUTE current_order_id WHEN OBJECT ADDED,CHANGED STORE current_order_id USING self.original_object.manage_changeProperties(current_order_id=self.current_order_id) Doing dtml-var "OrderingEntities.getItem(some_id).current_order_id)" shows me the value of current_order_id of the Employee object some_id. But I can't figure out how to change the property so it get changed in the Employee object. dtml-call "OrderingEntities.getItem(some_id).manage_changeProperties(current_order_id='123')" does nothing, it doesn't even trigger the WHEN OBJECT CHANGED line (not that I really expected it to work... this object is virtual, how can I call changeProperties on it?) Other than figuring out how to get the change to work, I two more problems: -Eventually the OrderingEntities Specialist will have several Racks mapping to several other Specialists, so it will end up returning different classes. Should I instead create a new ZClass with just the current_order_id property and use this class in all the virtual Racks? - How do I add a property to the original object from the virtual object (assuming I did not add it manually to the Employee class)? Do I call self.original_object.manage_addProperty(...) from the SkinScript? TIA -- Itai Tavor"Je sautille, donc je suis." C3Works[EMAIL PROTECTED] - Kermit the Frog "If you haven't got your health, you haven't got anything" ___ 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] Adding and setting properties from a virtualSpecialist
Steve Spicklemire wrote: Hi Itai, "Itai" == Itai Tavor [EMAIL PROTECTED] writes: Itai "OrderingEntities.getItem(some_id).current_order_id)" shows Itai me the value of current_order_id of the Employee object Itai some_id. But I can't figure out how to change the property Itai so it get changed in the Employee object. dtml-call Itai "OrderingEntities.getItem(some_id).manage_changeProperties(current_order_id='123')" Itai does nothing, it doesn't even trigger the WHEN OBJECT Itai CHANGED line (not that I really expected it to work... this Itai object is virtual, how can I call changeProperties on it?) How about 'OrderingEntities.getItem(some_id).propertysheets.TheRightPropertysheet.manage_changeProperties() Gr now I'm really annoyed. Why didn't I try that? So obvious. Thanks. Itai Other than figuring out how to get the change to work, I two Itai more problems: Itai -Eventually the OrderingEntities Specialist will have Itai several Racks mapping to several other Specialists, so it Itai will end up returning different classes. Should I instead Itai create a new ZClass with just the current_order_id property Itai and use this class in all the virtual Racks? This is what I do in most cases... each rack has different SkinScript to map the attributes of different classes onto the common attribute set of the single Storage class used by all the racks. Sounds like a good plan, think I'll adopt it. Itai - How do I add a property to the original object from the Itai virtual object (assuming I did not add it manually to the Itai Employee class)? Do I call Itai self.original_object.manage_addProperty(...) from the Itai SkinScript? I think this should work but it will only add the propertysheet to the instance.. not the class. If the property is completely missing from the original class then it seems to me either there is really no real need to save it there... or the class was incomplete somehow to begin with... and it should be added at the ZClass level.. Say I got several Participants, and some of those need to be able to place orders. I create the Specialist OrderingEntities to implement the role of 'someone who places orders'. From what I understand about using Specialists to extend a class behavior, this Specialist should add the properties it needs to track orders with to the Participant classes - I should not have to go in to every Participant class and add the property to it, because those classes don't know and don't care that they might be used in this role. Am I wrong in this? Otherwise, the only other way to track properties for this role would be to physically store a new object on the OrderingEntities Rack for every Participant class accessed, but what's the point in that, if I can simply add the property to the original class? Making small steps up the ZPatterns mountain (and too many of them backwards), Itai -- Itai Tavor"Je sautille, donc je suis." C3Works[EMAIL PROTECTED] - Kermit the Frog "If you haven't got your health, you haven't got anything" ___ 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 )
[Zope-dev] Re: ZPatterns, ObjectDomain, UML and all that.....
Steve Spicklemire wrote: "RC" == RC Compaan [EMAIL PROTECTED] writes: RC Hi Steve RC I'm also a babe in the woods when it comes to object RC modelling, but here's my pennie's worth. Since code RC generation was not really required in the models I recently RC did for Zope Apps and the terrible exchange rate on the South RC African Rand I decided to use to very light weight Playground RC modelling tool. I agree with Steve Alexander that Coad RC notation serves ZPatterns *better* and this is exactly what RC Playground uses. Ahh.. alas Playground is Win only (if I'm thinking correctly that it's the software that came in Coad's book), and I loaned tbe book and CD to someone else ... g... ;-) It is the software that comes with the book, and it is Win only. I started using it but switched to ConceptDraw because I got tired of turning my chair around to face the Windows machine every time I wanted to look at my object model. Like Roche said, you don't need code generation, so all you need is to be able to place classes and connect them. Playground is nice in that it actually knows about classes and lets you view class lists, create connections from the list and so on. ConceptDraw is just a drawing program so you won't have class lists, and the libraries aren't complete, but on the other hand, it works well on a Mac and, unlike Playground, it lets you do Coad, UML, Use Cases, activity diagrams, sequence diagrams, component diagrams, collaboration diagrams... Itai -- Itai Tavor"Je sautille, donc je suis." C3Works[EMAIL PROTECTED] - Kermit the Frog "If you haven't got your health, you haven't got anything" ___ 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 )
[Zope-dev] RE: ZPatterns, ObjectDomain, UML and all that.....
Roché wrote: Steve Spicklemire wrote: If I explicitly store a Bar object as an Attribute of a DataSkin then what happens if the original Bar is removed from its Specialist's Rack? Does the Bar I store still refer to the original Rack as its DataManager? So.. does a Rack sometimes have 'clients' that are not really in the Rack at all? Or perhaps I misunderstood the discussion, and the Address wasn't really a DataSkin at all? Also.. assuming that all works, do I have to do anything special, or carefully to be sure that the persistence machinery doesn't incur lots of expensive attribute fetching if I don't explicitly refer to those attributes, but have the DataSkin as a directly set attribute of another DataSkin? Before I started building Apps with ZPatterns I built a object/relational access layer in Delphi for my applications which enables me to create pure objects in my problem domain and delegate all data management to the the access layer. I *think* this is one of the things ZPatterns wants to do as well. Take the Customer with Address property example: I create Customer and Address Dataskins. For Customer I have an external method setAddress which sets the Address property of my Customer object and this is how I would create a new Customer: newCustomer = customerRack.newItem( CustomerCounter ) newAddress = addressRack.newItem( AddressCounter ) newCustomer.setAddress( newAddress ) I prefer the simplicity this brings when I have to access the properties of a Customer (without having to call a getter each time I need an address): myCustomer.Address.Street This also maps quite simply to SQL storage. So although instances of Address are properties of Customer they live on their own Rack and instances of Customer simply refers to their Address through assignment. With Container/Content type objects I do roughly the same - I have setContainer methods for the Content objects. Me thinks that what we all need is a guide to implementing object connections for different object relationships and patterns. Perhaps something like this (view with monospaced font): Object relationship| (Pattern) | Implementation 1 1 | Add prop to A: b_id A - B | In A call Bs (Specialist of B): my_b = Bs.getItem(b_id) n 1 | Add prop to B: a_id A - B | Add method to Bs (Specialist of B): getBsForA(a_id) | In A call Bs: my_b_list = Bs.getBsForA(a_id) n n | ? A - B | n [XOR A] 1| Add Specialist Xs implementing role of A and B A -| Add prop to C: x_id n [XOR A] 1 C | In A, B call Xs: my_x = Xs.getItem(x_id) B --| (Participant-Transaction)| (A and B - Participants, C - Transaction) [XOR A] 1 n | Add prop to B, C: a_id B| In B, C call As (Specialist of A): my_a = As.getItem(a_id) A [XOR A] 1 n | C| (can't do reverse connection?) Does anyone think this would be useful? Can we get the experts to expand/correct/verify this? Obviously more relationship types need to be added, and also some extra information is needed (such as who's responsible to set the id attributes and how, when and how reverse connections are done, etc.). Itai -- Itai Tavor"Je sautille, donc je suis." C3Works[EMAIL PROTECTED] - Kermit the Frog "If you haven't got your health, you haven't got anything" ___ 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] ZPatterns, ObjectDomain, UML and all that.....
Steve Spicklemire wrote: I've been working out some issues with EMarket, and as a way to 'clear the cruft'.. I decided to bite the bullet and do some more careful object modeling. Other than scribbling on paper, and making up some diagrams that look a little like those from Coad's book on Patterns and Strategies, I've never used any object modeling tools before in my life. S... I downloaded the eval version of ObjectDomain, and I can go for about 5 minutes on a Mac before it crashes, and usually 10 or 15 on Windows before it stops responding to mouse/keyboard input. Save early, save often.. ;-. Sure it's frustrating but it seems more workable that ArgoUML which I've had even less luck with (What are other folks using? Rose?) anyway after much more time that I would have thought possible I've come up with: I'm in about the same position as you right now - trying to learn formal object modeling and ZPatterns, so I'm not qualified to say anything about your model or questions... I just want to mention two things that I found: - I didn't find any of the modeling tools you mentioned, or others I've tried, very useful on a Mac (or at all), and I ended up using ConceptDraw, which is a general purpose drawing tool with UML and Coad libraries. - Steve Alexander wrote in a reply to your post: I think Coad's notation is better and clearer, as it allows you to communicate information about objects and their classes all in one place. Coad's notation is more about showing interactions of objects, whereas UML makes that awkward, and is mostly used for expressing static information about relationships between classes. Very true, IMVHO. I still find there's a big gap between a Coad model and a ZPatterns implementation, but it's much better than with UML. HTH -- Itai Tavor"Je sautille, donc je suis." C3Works[EMAIL PROTECTED] - Kermit the Frog "If you haven't got your health, you haven't got anything" ___ 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 )
[Zope-dev] Implementing [XOR A] 1 object connections in ZPatterns
Hi, Continuing the saga of my struggles with ZPatterns, I'm trying to work out the best way to implement an object that can be related to one of several other objects. For example, I have a Product class. A Product can come in different colors, so I also have a Color class. Products can have two photos of the product - small and large. Colors can also have a photo, showing the product in that particular color. So, a Photo object can be a large product photo, a small product photo, or a color photo. I can think of two ways to implement this: 1. Add small_photo_id, large_photo_id properties to Product, and photo_id property to Color. Then I do something like: Product.editInstanceForm: dtml-if large_photo_id dtml-var "Photos.getItem(large_photo_id).viewInstance(...)" dtml-else form action="selectLargePhoto" method="post" dtml-var "Photos.selectPhotoSnippet(...)" /form /dtml-if methodProduct.selectLargePhoto/method: photo_id = self.Photos.selectPhoto(REQUEST) self.propertysheets.Basic.manage_changeProperties(large_photo_id=photo_id) 2. Add owner_id, photo_key properties to Photo. Then use: Product.editInstanceForm: dtml-var "Photos.selectPhotoForOwner(Photos, REQUEST, owner_id=id, photo_key='large')" Photos.selectPhotoForOwner: dtml-let photo="defaultRack.getItemForKey(owner_id, photo_key)" dtml-if photo dtml-var "photo.viewInstance(...)" dtml-else ... code for selecting/creating photo ... /dtml-let The 2nd way seems to go better with OO principles - all handling of photos is delegated to the Photos Specialist and the Product doesn't care if the photo exists or not, or where it comes from. But it also increases complexity in Photos, because I need to implement an efficient way to retrieve photos (with a Catalog, or SQL searches), and because it introduces the photo_key. Storing photo_id in Product eliminates these complexities, but it moves some of the responsibility for managing photos into Product. Can anyone add anything on making the choice? Or maybe a 3rd way I haven't thought of? Thanks, Itai -- Itai Tavor"Je sautille, donc je suis." C3Works[EMAIL PROTECTED] - Kermit the Frog "If you haven't got your health, you haven't got anything" ___ 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] ZPetterns implementation qustions
Phillip J. Eby wrote: At 06:19 PM 11/29/00 +1100, Itai Tavor wrote: Hi, I'm trying to figure out the right way to implement a set of classes and roles in ZPatterns. I asked some questions about this a while ago, and then went away and did some learning, but I'm stuck again and I'm afraid I need to ask more questions. I have two types of actors - Person (with properties name, phone, email, password) and Organization (with properties name, phone, fax, business_number). I also have two participants - Customer and Reseller. Each participant can be either a Person or an Organization. The participants can fill several roles, like OrderingEntities, BillableEntities, etc. Starting from the bottom, I create a Specialist for each role, each one with two virtual Racks - customerRack and ResellerRack, so I can refer to an OrderingEntity without caring if it's a Reseller or Customer. My problem is in implementing the Participant Specialists and storing Participant and Actor classes. Do I create Specialists for the Actors? It seems to me that since there is either one Person or one Organization per Customer, then the actor object should be created in the Customers Specialist. So Customers will have 3 Racks - defaultRack (using Customer object), personRack (using Person object) and organizationRack (using Organization object). Does this make sense? I think what you want is to have an Actors specialist containing a personRack and organizationRack. That is, treat "Actor" as a role relative to either Customer or Reseller. The reason I say, "I think", is because I'm really not clear on why you're doing certain things here to start with. See below. If this is a good way to do it, how do I handle creating and accessing the Person and Organization objects? Do I call personRack.newItem(newCustomerId) in the script that creates the customer? Or do I somehow do it in a SkinScript in defaultRack? And how do I get to the Person data? With an attribute provider? Or in Here's a red flag: why are you creating a person when you create a customer? If a person is something that you only make when you have a customer, then the actor-participant-transaction pattern isn't really valid, IMHO. For Actor-Participant-Transaction to make sense, you have to have Actors that exist seperate from the Participants. While it makes sense to be able to create an Actor at the same time, your model needs to also include a way to select an *existing* Actor as the Participant, otherwise you are not gaining anything from the A-P-T pattern and you might as well just have the Participant. I think I have problems understanding the whole A-P-T pattern. Maybe someone can help clear it up for me... An Actor is a Person or an Organization. A Participant can be (in my application) a Customer, Customer Contact, Reseller, ResellerContact, or Employee. Participants have different roles - for example, all Participants can place orders on behalf of customers, and they take on the OrderingEntity role. Orders are always paid for by Customers in their role as BillableEntities. Now, OrderingEntities and BillableEntities are roles that actualize the object connections between the Participants and the Transaction objects (in the above examples, the Transaction object would be Order), right? They are not new Participants. So in this application, while Participants can fill multiple roles, each Actor can only be a single Participant. A Person participating as a CustomerContact is (in the real world) employed by the Customer, so in the application she won't participate as anything else. So the A-P pattern seems to serve the purpose of reusing common properties and methods, rather than allowing for n-1 relationship between Actors and Participants. This seems to me to suggest that the application should have a Person class but that the Person will get created when a new Participant is created, and that a 'select existing Actor as Participant' interface, as Phillip suggests above, is not necessary. Am I right, or do I persist in misunderstanding A-P-T? A related problem I've been struggling with is how to allow a Reseller to buy product for itself/herself. Normally orders are placed for Customers only. Would it make more sense to create a role for entities that receive orders (implemented as a Specialist with virtual Racks for Customers and Resellers), or to complicate the A-P pattern by allowing a single Actor to be both a Reseller and a Customer? The new role path seems to make more sense to me, but I've been known to be wrong before :). Here's a pattern for mapping A-P-T interactions onto ZPatterns, however... If you are doing A-P-T, make sure you use a Specialist for access to the Actors. For example, in some applications Ty and I write, "acl_users" is designated as the Specialist for actors if all actors in the system have to be able to use the application. The user interface and implementation
[Zope-dev] ZPetterns implementation qustions
Hi, I'm trying to figure out the right way to implement a set of classes and roles in ZPatterns. I asked some questions about this a while ago, and then went away and did some learning, but I'm stuck again and I'm afraid I need to ask more questions. I have two types of actors - Person (with properties name, phone, email, password) and Organization (with properties name, phone, fax, business_number). I also have two participants - Customer and Reseller. Each participant can be either a Person or an Organization. The participants can fill several roles, like OrderingEntities, BillableEntities, etc. Starting from the bottom, I create a Specialist for each role, each one with two virtual Racks - customerRack and ResellerRack, so I can refer to an OrderingEntity without caring if it's a Reseller or Customer. My problem is in implementing the Participant Specialists and storing Participant and Actor classes. Do I create Specialists for the Actors? It seems to me that since there is either one Person or one Organization per Customer, then the actor object should be created in the Customers Specialist. So Customers will have 3 Racks - defaultRack (using Customer object), personRack (using Person object) and organizationRack (using Organization object). Does this make sense? If this is a good way to do it, how do I handle creating and accessing the Person and Organization objects? Do I call personRack.newItem(newCustomerId) in the script that creates the customer? Or do I somehow do it in a SkinScript in defaultRack? And how do I get to the Person data? With an attribute provider? Or in the SkinScript: WITH personRack.getItem(self.id) COMPUTE name=name, phone=phone, email=email, password=password, personObject=RESULT) Also, if Actors are stored in the Specialists that implement the roles they participate as, there is no place to store methods that are common to an Actor regardless of role - for example, a method that checks if a password is secure enough and called when adding a Person object. So I either duplicate these methods in every Participant Specialist, or create more Specialists - which seems like a waste either way. Another problem is how to edit these objects - if I have a form which includes fields for a Customer properties and for the properties of the Person object linked to that Customer, can I change the Person object from the Customer SkinScript? I don't think I can do this: WHEN OBJECT CHANGED STORE name, password USING personObject.propertysheets.manage_changeProperties(name=self.name, password=self.password) Right? Because name and password are not properties on the Customer DataSkin. So I have to call person.manage_changeProperties(...) in the method that changes Customer... it seems to me that I always end up doing object connections work in methods and the SkinScript can't help with anything :( Hope this is not too convoluted...I'd really appreciate any help anyone can offer. The existing ZPatterns examples all deal with fairly straightforward situations, but it's the more complex class relationships where the bears and tigers are hiding :) Itai -- Itai Tavor"Je sautille, donc je suis." C3Works[EMAIL PROTECTED] - Kermit the Frog "If you haven't got your health, you haven't got anything" ___ 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] Questions about implementing object models withZPatterns
Phillip J. Eby wrote: At 05:19 PM 11/1/00 +1100, Itai Tavor wrote: Ok... I think I get the "Specialist per role, not per class" part. But I still can't make the jump from a class diagram to a ZClass/Specialist setup. A class diagram contains all the roles - they're the lines between the classes. :) That's a great statement :) It really helps me decipher my object model. Look at it this way... if an object has a particular association role that it needs filled, and there is more than one kind of object that can fill that role, then presumably those objects must all implement a certain interface, right? You need to create a Specialist for that interface. In other words, there is usually one Specialist per collaboration interface -- which is NOT a one-to-one mapping with classes, since some classes may implement multiple interfaces, and some classes may all implement the same interface. How do you decide where to create collaboration Specialists? You wouldn't have one for every line in the object model, right? Do you use one only where there is more than one kind of object that can fill a role? How do you determine if a collaboration interface requires a collaboration Specialist, or can be done with a direct connection between the two class Specialists? For example, take an OrderLineItem object and a ShipmentLineItem object (one describes a quantity of a certain product added to an order, and the other that quantity of product being shipped). In the interface between OrderLineItem and ShipmentLineItem, an OrderLine can be seen as filling the role "thing that is shipped". OrderLineItem also fills the role "thing that is purchased" when it is added to an order. Would you create Specialists for each of these roles? Or, in the case of BillableEntities below, would you still use this Specialist if there were only Customers in the system (so, only one participant filling the "thing that places orders" role)? Are collaboration Specialists only used to interface participant-type objects? I can solve some of it by subclassing ZClasses. So, if I need Customers and Resellers, I'll make a Specialist for each, and a Customer and Reseller ZClasses, both subclassed from Person which stores common properties for a person. This part is ok. What *role* do Customer and Reseller objects play in your system? It sounds to me like perhaps they play the role of "thing that places orders" or "thing that orders are shipped to". Depending on your application's functions, you could need as many as FOUR specialists: Customers Resellers BillableEntities ShippingDestinations Where the latter two specialists would contain a pair of Racks that mapped back to the Customers and Resellers specialists, respectively. The collaboration Specialist won't actually *do* anything, would they? They would only abstract the retrieval of participant objects, so that any object which requires a "ship_to" property will not have to know or care what kind of participant is referred to. Am I getting this right? (Of course, I could add PD methods to ShippingDestinations if I wanted to, like printShippingLabel, but in a basic application this Specialist doesn't seem to need to do anything at all). Also, these collaboration Specialists seem to serve to hide the fact that there are two types of participants. So, for example, a Payment object would just know "things that get billed". So how would I ask the Payments Specialist for "all payments made to resellers"? But it gets more complex than that. Take this example: Every OrderLineItem object can have one or more Payment objects associated with it. There are 3 possible payment types - Check, Charge and BankDeposit, so I make a ZClass for each one, all subclassed from a general Payment ZClass. I create one Payments Specialist with 3 Racks. Where do I store methods that are specific to one payment type? In the Rack? I can't store them in the Specialist - it would be a mess, and I can't store them in the ZClass, because the ZClass doesn't know about the rest of the application. Huh? What do you mean by "methods that are specific to one payment type" in this context? What do payments do that requires knowledge of the rest of the application? If it's a problem-domain method, it belongs in the ZClass. Ok, I get this now. This question was based on my lack of understanding of how a ZPatterns application is structured. A Payment object needs to access other parts of the application - for example, to get a UI snippet from BillableEntities. I thought that ZClasses are supposed to be self-contained, without links to the rest of the app, while methods that link parts of the app together belong in the Specialists. I can see I was totally wrong in this. Please note, however, that at this stage of design you shouldn't be looking at how the references are g
[Zope-dev] Questions about implementing object models with ZPatterns
Hi, How do I implement gen-spec classes using ZPatterns and ZClasses? For example, I want to implement Person and Customer. Writing it in Python, it would be easy to subclass Person to get Customer, and Customer would inherit Person's properties and methods. If I instead create a specialist and ZClass for each class, do I use a SkinScript to remap Person's properties into Customer? And what about the methods - Customer can't inherit Person's methods, so I have to write methods in Customer which call the same methods in Person. This seems terribly complicated... am I missing something? Another question: In Coad's examples, if a class has an 'n' order relationship to another class - say Order and OrderItems, Order would contain a list of OrderItems. Each OrderItem would contain the id of the Order it belongs to. It seems to me that it would be easier for Order to call OrderItems.getItemsForOrder(self.id), then I don't have to maintain a list in Orders, and if I add an OrderItem the Order will immediately know about it without me having to call it and tell it the OrderItem was added. Is there anything wrong with this approach? TIA, Itai -- Itai Tavor"Je sautille, donc je suis." C3Works[EMAIL PROTECTED] - Kermit the Frog "If you haven't got your health, you haven't got anything" ___ 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] Questions about implementing object models withZPatterns
Phillip J. Eby wrote: At 12:35 PM 11/1/00 +1100, Itai Tavor wrote: Hi, How do I implement gen-spec classes using ZPatterns and ZClasses? For example, I want to implement Person and Customer. Writing it in Python, it would be easy to subclass Person to get Customer, and Customer would inherit Person's properties and methods. If I instead create a specialist and ZClass for each class, do I use a SkinScript to remap Person's properties into Customer? And what about the methods - Customer can't inherit Person's methods, so I have to write methods in Customer which call the same methods in Person. This seems terribly complicated... am I missing something? If you want subclasses, just subclass ZClasses. As for the remapping, etc., it depends on what you want to do. Keep in mind that Specialists are created per *role* or *interface*, not per class. You can have a "People" specialist that has a personRack and a customerRack in it, for example. Specialists are application- and usage-driven; you don't always end up creating specialists for every class in your object model. Ok... I think I get the "Specialist per role, not per class" part. But I still can't make the jump from a class diagram to a ZClass/Specialist setup. I can solve some of it by subclassing ZClasses. So, if I need Customers and Resellers, I'll make a Specialist for each, and a Customer and Reseller ZClasses, both subclassed from Person which stores common properties for a person. This part is ok. But it gets more complex than that. Take this example: Every OrderLineItem object can have one or more Payment objects associated with it. There are 3 possible payment types - Check, Charge and BankDeposit, so I make a ZClass for each one, all subclassed from a general Payment ZClass. I create one Payments Specialist with 3 Racks. Where do I store methods that are specific to one payment type? In the Rack? I can't store them in the Specialist - it would be a mess, and I can't store them in the ZClass, because the ZClass doesn't know about the rest of the application. Actually, writing this down makes me realize that it could work... would Payments.getItem(some_payment_id).someMethod() call someMethod in the Rack if one exists, and the one in the Specialist if not? I guess that would make it very easy... subclassing moves into the Specialist. Another problem I'm having is how to store id's for different objects in the the same field. In the Payments example above this is not a problem, because all payments are supplied by the Payments specialist. But what about another example - Customers and Resellers are two totally different roles, so they each get a Specialist. the Payment object has from_id and to_id fields, and each of those can hold the id of a customer or reseller, or some special code to indicate the store. I could add from_type and to_type fields, or I could prefix the id with a code letter, but neither seem like a good solution. Is there a recommended approach for solving this problem? (By the way, note that if you have a personRack and customerRack in the same specialist, they can share data plug-ins (such as SkinScript methods) placed directly in the specialist. The ranking order of the parent plug-ins in the child racks is determined by where you place a "Link to Parent Data Plug-Ins" in the racks' data plug-in lists.) Another question: In Coad's examples, if a class has an 'n' order relationship to another class - say Order and OrderItems, Order would contain a list of OrderItems. Each OrderItem would contain the id of the Order it belongs to. It seems to me that it would be easier for Order to call OrderItems.getItemsForOrder(self.id), then I don't have to maintain a list in Orders, and if I add an OrderItem the Order will immediately know about it without me having to call it and tell it the OrderItem was added. Is there anything wrong with this approach? Nothing at all. It's the recommended approach, actually. This is how you make frameworks work... by delegating to specialists responsible for a role in the application. That is, instead of the Orders system having to know anything about how order items are actually implemented, it can delegate that function to an OrderItems specialist that could have such things as DiscountItems, ReturnItems, and all sorts of other objects that implement an OrderItem interface. Similarly, rather than an Order providing its own interface for entering an order item, the UI code can be (should be) placed in the OrderItems specialist, and called by the Order object's add/edit forms. Encapsulation at its very best. :) That's the ZPatterns way; the tools were specifically created to make it easy to do things the "right" way from a seperation-of-powers standpoint. Thanks! I feel a little better now :) -- Itai Tavor"Je sautille, donc je suis." C3Works[EMAIL PROTECTED] - Ker
[Zope-dev] Problem with LoginManager, UserSource and object re-mapping
Hi, I have the following setup: - LoginManager with 3 UserSources, one of them named CustomerUserSource. - A Customers specialist, using a Customer ZClass for storage. Customer has a 'login' propertysheet with property 'password', and a getCustomerByName method returning a customer object. - CustomerUserSource 'load by accessing attribute' is set to 'id'. - A SkinScript in CustomerUserSource: WITH Customers.getCustomerByName(Customers, self.id) COMPUTE password=password, original_object=RESULT The following PythonMethod: obj=self.CustomerUserSource.getItem('jane') return obj.password returns the correct password for customer 'jane', but this one: obj=self.getItem('jane') return obj.password returns this: NameError password Troubleshooting Suggestions This resource may be trying to reference a nonexistent object or variable password. The URL may be incorrect. The parameters passed to this resource may be incorrect. If the error persists please contact the site maintainer. Thank you for your patience. Traceback (innermost last): File /opt/Zope-2.2.2-linux2-x86/lib/python/ZPublisher/Publish.py, line 222, in publish_module File /opt/Zope-2.2.2-linux2-x86/lib/python/ZPublisher/Publish.py, line 187, in publish File /opt/Zope-2.2.2-linux2-x86/lib/python/Zope/__init__.py, line 221, in zpublisher_exception_hook (Object: ProviderContainer) File /opt/Zope-2.2.2-linux2-x86/lib/python/ZPublisher/Publish.py, line 171, in publish File /opt/Zope-2.2.2-linux2-x86/lib/python/ZPublisher/mapply.py, line 160, in mapply (Object: test3) File /opt/Zope-2.2.2-linux2-x86/lib/python/ZPublisher/Publish.py, line 112, in call_object (Object: test3) File /opt/Zope/lib/python/Products/PythonMethod/PythonMethod.py, line 168, in __call__ (Object: test3) (Info: ((LoginManager instance at 875a590, ), {}, None)) File string, line 8, in test3 (Object: ProviderContainer) File /opt/Zope/lib/python/Products/ZPatterns/DataSkins.py, line 181, in __get_attr__ (Object: BetterLocalRolesMixin) File /opt/Zope/lib/python/Products/ZPatterns/AttributeProviders.py, line 346, in _AttributeFor (Object: GAPMixin) File /opt/Zope/lib/python/Products/ZPatterns/AttributeProviders.py, line 335, in _AttributeFor (Object: GAPMixin) File /opt/Zope/lib/python/Products/ZPatterns/Expressions.py, line 122, in eval File /opt/Zope-2.2.2-linux2-x86/lib/python/DocumentTemplate/DT_Util.py, line 337, in eval (Object: password) (Info: password) File string, line 0, in ? NameError: (see above) I don't understand why a direct getItem() call to CustomerUserSource would trigger the WITH...COMPUTE line, while just doing getItem() on the LoginManager doesn't? As I understand it, getItem() calls each UserSource, so why would there be a difference in behavior? TIA, Itai -- Itai Tavor"Je sautille, donc je suis." C3Works[EMAIL PROTECTED] - Kermit the Frog "If you haven't got your health, you haven't got anything" ___ 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] A couple of ZPatterns questions
At 06:15 PM 10/12/00 +1100, Itai Tavor wrote: Hi, .. 2. I want to store a list of products, and give each one an arbitrary number of photos. I can use a Product ZClass, subclassed from ObjectManager and store Image objects inside it. But what will happen to these objects if I use this ZClass in a Rack? And how would I handle storing the objects in SQL tables - I will need to somehow turn each Image object into a table entry, and the same Generic Attribute Provider will have to work with 2 SQL tables. Is there a nice way of doing this? Or should I store the photos in a separate ZClass and use it in another Rack in the Products Specialist? I would not suggest trying to go the ObjectManager route. ZPatterns does not have a good way at present to map child objects into other databases. Instead, a more custom approach would be appropriate, where you have say an "images" attribute that is loaded/saved through SQL. This has the downside, however, of being either resource intensive or computationally intensive. However, it'd probably be best of all to have a Photos specialist, with a getPhotosForProduct() method, addPhotoToProduct(), and so on. Why would I want another Specialist for photos? Photos are just another attribute of a Product. They just happen to be stored separately, a distinction which I think should happen at the Rack level. I created my Products Specialist with 3 racks: 'defaultRack' for Product properties, 'photoRack' for photos, and 'priceRack' for product price options (every product can have multiple price options, so I don't store a price in the product properties). Then I can have methods in each Rack to deal with the specific object stored in it, and methods in the Specialist to handle the overall view. I can also have a SkinScript in the defaultRack to return a virtual Product object which includes a list of photo objects. Is there anything wrong with this? Actually, I can't put an Image object on a DataSkin, right? So however I store it, it's going to have to be a my own custom Image object subclassed from DataSkin... Not necessarily, it depends on your overall structure. If you want to use standard Zope Image objects you may indeed want to subclass from DataSkin. I do want to use the standard Zope Image object - it's got a lot of useful functions that I don't want to lose and I don't want to do the work of writing my own Image class and duplicating all those functions. But I don't know how to get the Image product to store in a DataSkin - or if it's possible at all. If I create a ZClass subclassing Image and DataSkin, would the image data automatically get stored in the DataSkin? Or do I have to override all methods dealing with storage in the object? Also, the Image __init__ methd requires a file - Image objects can't be created empty, but the DataSkin always creates new objects with no data, so I guess some overriding will be required to allow the object to function empty... Itai -- Itai Tavor"Je sautille, donc je suis." C3Works[EMAIL PROTECTED] - Kermit the Frog "If you haven't got your health, you haven't got anything" ___ 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 )
[Zope-dev] Re: Zope-Dev digest, Vol 1 #752 - 13 msgs
James Johnson wrote: 2. I want to store a list of products, and give each one an arbitrary number of photos. I can use a Product ZClass, subclassed from ObjectManager and store Image objects inside it. Would using the new ZPatterns based EMarket-0.2.0a2 help as a base system. I would also look at the updated information on SkinScript located here. http://www.zope.org//Members/pje/Wikis/ZPatterns/SkinScriptSyntax I hope this helps. It's extremely helpful. I missed that SkinScript Wiki page, and I've been following the discussions about the ZPatterns-based EMarket but didn't realize it's been released. Thanks! -- Itai Tavor"Je sautille, donc je suis." C3Works[EMAIL PROTECTED] - Kermit the Frog "If you haven't got your health, you haven't got anything" ___ 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 )
[Zope-dev] Re: Trying to catch up - what are the best Zope tools today?
Itai asked: "I started reading about ZPatterns but I still can't get my head around it... I'm wondering if I should try to learn it fast enough for this project, or stick to what I already know. What in people's experience is the typical learning curve for ZPatterns? How much am I going to have to figure out to be able to build support for SQL storage? FYI ZPatterns has been a rapidly moving target, but it's looking pretty solid now, and a few folks have managed to wade in and make sense of it already. There's even some documentation at : http://www.zope.org/Members/pje/Wikis/ZPatterns/HomePage Most of the discussions you'll see on this list between Steve Spicklemire and Phil Eby / Ty Sarna are directly related to the next rev. of EMarket, which will be based on ZPatterns. If you think the flexibility that comes from a cleanly implemented Object Pattern will be worth the learning curve, ZPatterns is just about there now. The "how" of storing data in an RDBMS, accessed with ZSQLMethods is no different with ZPatterns. The real difference is "who" does the storage and retrieval. This is the concept of the "Specialist" object, which "knows" all about the specifics of the data and storage implementation. In any case, get to know ZClasses and PythonMethods, which may not have been ready for prime time, or even released, last time you looked. Those will be useful no matter which direction you choose. Later, Jerry S. Thanks. I did work with ZClasses and PythonMethods - I wasn't gone that long. I couldn't see how ZPatterns are actually implemented, regardless of what tools are used - but I'm getting it slowly, mostly by collecting a lot of tips from posts in the list over the past few months. ZPatterns looks great and definitely worth the learning curve - I'm off to buy Coad's book so I can do it right. -- Itai Tavor"Je sautille, donc je suis." C3Works[EMAIL PROTECTED] - Kermit the Frog "If you haven't got your health, you haven't got anything" ___ 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 )
[Zope-dev] ToDoManager ZPatterns example not working
Hi, I installed the ToDoManager/ToDoProduct example (http://www.zope.org/Members/sspickle/DumbZPatternsExample ) but it won't work. System is RedHat 6.1, Zope 2.2.2, ZPatterns-0-4-2a3. I get the following traceback when I try to view /ToDoManager/index_html. Is it a bug somewhere or a problem with my installation? Error Type: AttributeError Error Value: _setRack Traceback (innermost last): File /opt/Zope-2.2.2-linux2-x86/lib/python/ZPublisher/Publish.py, line 222, in publish_module File /opt/Zope-2.2.2-linux2-x86/lib/python/ZPublisher/Publish.py, line 187, in publish File /opt/Zope-2.2.2-linux2-x86/lib/python/Zope/__init__.py, line 221, in zpublisher_exception_hook (Object: ProviderContainer) File /opt/Zope-2.2.2-linux2-x86/lib/python/ZPublisher/Publish.py, line 171, in publish File /opt/Zope-2.2.2-linux2-x86/lib/python/ZPublisher/mapply.py, line 160, in mapply (Object: index_html) File /opt/Zope-2.2.2-linux2-x86/lib/python/ZPublisher/Publish.py, line 112, in call_object (Object: index_html) File /opt/Zope-2.2.2-linux2-x86/lib/python/OFS/DTMLDocument.py, line 177, in __call__ (Object: index_html) File /opt/Zope-2.2.2-linux2-x86/lib/python/DocumentTemplate/DT_String.py, line 528, in __call__ (Object: index_html) File /opt/Zope-2.2.2-linux2-x86/lib/python/DocumentTemplate/DT_In.py, line 691, in renderwob (Object: defaultRack.getPersistentItemIDs()) File /opt/Zope-2.2.2-linux2-x86/lib/python/DocumentTemplate/DT_Let.py, line 147, in render (Object: currID="_['sequence-item']") File /opt/Zope-2.2.2-linux2-x86/lib/python/DocumentTemplate/DT_With.py, line 133, in render (Object: getItem(currID)) File /opt/Zope-2.2.2-linux2-x86/lib/python/DocumentTemplate/DT_Util.py, line 337, in eval (Object: getItem(currID)) (Info: currID) File string, line 0, in ? File /opt/Zope/lib/python/Products/ZPatterns/Specialists.py, line 34, in getItem (Object: ProviderContainer) File /opt/Zope/lib/python/Products/ZPatterns/Rack.py, line 60, in getItem (Object: ProviderContainer) File /opt/Zope/lib/python/Products/ZPatterns/Rack.py, line 114, in retrieveItem (Object: ProviderContainer) File /opt/Zope-2.2.2-linux2-x86/lib/python/OFS/Uninstalled.py, line 110, in __getattr__ (Object: broken) AttributeError: (see above) -- Itai Tavor"Je sautille, donc je suis." C3Works[EMAIL PROTECTED] - Kermit the Frog "If you haven't got your health, you haven't got anything" ___ 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 )
[Zope-dev] Trying to catch up - what are the best Zope tools today?
Hi, I've been out of the Zope world for a few months... now I'm back and I need to quickly write a small-scale e-commerce application. It's got enough peculiarities to make it impossible to do with eTailer or EMarket, so I'm trying to figure out the best tools and approach to use for writing it, but so much has changed in Zope since I last worked with it. There's ZPatterns, LoginManager instead of GenericUserFolder, new session management products... the new tools seem much better than the old, but most are in development and carry dire warnings, and at least some of the old tools don't work in Zope 2.2. Can anyone provide a quick rundown of the best choices for building a production site at this time? I'm going to need sessions, user registration and login, and the usual array of e-commerce pieces (products, carts, orders, payments...), with all data stored in SQL. I started reading about ZPatterns but I still can't get my head around it... I'm wondering if I should try to learn it fast enough for this project, or stick to what I already know. What in people's experience is the typical learning curve for ZPatterns? How much am I going to have to figure out to be able to build support for SQL storage? I couldn't find any examples for SQL use in ZPatterns - did I miss anything? Thanks in advance for any comments. -- Itai Tavor"Je sautille, donc je suis." C3Works[EMAIL PROTECTED] - Kermit the Frog "If you haven't got your health, you haven't got anything" ___ 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 )