Log in |
Consolidating Multiple Property Sheets in ZClasses (plus CatalogAwareness)I wish there were a builtin way to integrate builtin property sheets, both inherited and peer, because that would greatly simplify maintenance of ZClass management stuff. But there isn't, and here's the setup when you're making custom sheets": (I'm not claiming this is the best design, but here goes...)
In the add/edit form, the action for the Submit button should be the add or edit method, depending on where it is. The names of the form elements (HTML inputs) should be the names of the properties in your property sheets you want to add/change. When you submit this form, the method it is submitted to gets a REQUEST object with keys named for the form elements, each associated with the value in the element when the form was submitted. You can see these in the URL line when you submit with GET. So it comes to the add method, which creates a new object in the dtml-with, then works in its namespace. While in the new object's namespace you can:
Typically you then redirect to whatever page should come after clicking submit. The ZClass constructor does this for you. You will do the same thing in your edit method, except you will not make a new object, and you're already in the appropriate namespace. You can do this in a DTML method patterened after the ZClass constructor, but this is where PythonScripts are good. One might look something like: # Keep in mind I'm making this up off the top of my head. I'll verify it against my code later... context.propertysheets.PROPERTYSHEETNAME1.manage_changeProperties(REQUEST) context.propertysheets.PROPERTYSHEETNAME2.manage_changeProperties(REQUEST) return context.REQUEST.RESPONSE.redirect(location) Easy huh? So then you just go into the ZClass management interface and add your edit method to a tab, test it out, and you're done. Issues:
|