RE: [Zope] ZClass propertysheet: Selection/Multi selection/Token - how?
On Sat, October 16, 1999, Kam Cheung wrote:
The problem: Some of the input fields are selection dropdown lists and multiple-selection lists that represent fixed options. These options will have spaces in them (killing a :token implementation). These options will need to appended to in the future.
The simpliest method -- Create a custom EditForm and Edit DTML method inside your ZClass. Then click your the "View" tab in your ZClass, assign a view to the EditForm (make it the first view, and preferably, remove the standard properties view as well).
If you do that, when your users click on the ZClass's instance, they will be presented with your EditForm.
So, instead of using a "list" property or Tiny Table object to hold the fields within the edit page, I *must* statically populate all of the <SELECT><OPTION></OPTION>...</SELECT> lists on a main edit page? The idea here is to make the ZClass edit panel a bit more dynamic - in that I can merely add to a list whenever a new list option needs to be edited. My problem so far is based around the problem that: methods defined *outside* of the ZClass (_add, _addForm, _classFactory, etc) seem to aquire the namespace of the Product that they are located in *at creation time only*. The propertysheet within the ZClass can see methods defined within the ZClass (through aquisition), but not the outside methods. So, another solution was given: try a :lines property on the Product to hold the options. Well, this works great for _add and _addForm - but the properties do not show up in the namespace of an 'instanciated object of that Product'. So, when the user goes to edit a created object, there is nothing to use to automagically fill in the dropdown boxes. Thinking about it for a bit, one would think that the following in _add would work: (WARNING, This doesn't work... perhaps someone can tell me why) In MyTestProduct, populate MyFirstOptionList and MySecondOptionList in the Product properties. In MyTestZClass_add: <dtml-with "MyTestZClass.createInObjectManager(REQUEST['id'], REQUEST)"> <dtml-call "REQUEST.set('MyFirstOptionList', _['MyFirstOptionList'])"> <dtml-call "REQUEST.set('MySecondOptionList', _['MySecondOptionList'])"> <dtml-call "propertysheets.Basic.manage_editProperties(REQUEST)"> </dtml-with> Using something like this, it would theoretically copy the properties from the Product namespace into the created Object's namespace. What am I doing wrong? How else can I carry around a list of options to be used both during the creation of a ZObject instance and during its operation? - Ian C. Blenke <ian@blenke.com> <icblenke@2c2.com>
On Sat, 16 Oct 1999, Ian Blenke wrote:
So, another solution was given: try a :lines property on the Product to hold the options. Well, this works great for _add and _addForm - but the properties do not show up in the namespace of an 'instanciated object of that Product'. So, when the user goes to edit a created object, there is nothing to use to automagically fill in the dropdown boxes.
I meant inside the ZClass definition :-) In the _addForm, you should be able to reference it as MyClass.propertysheets.myprops.linesitem (or possibly the ugly Control_Panel.Products.MyProduct.MyClass.propertysheets.myprops.linesitem) And when instantiated, its just a normal property :-) ___ // Zen (alias Stuart Bishop) Work: zen@cs.rmit.edu.au // E N Senior Systems Alchemist Play: zen@shangri-la.dropbear.id.au //__ Computer Science, RMIT WWW: http://www.cs.rmit.edu.au/~zen
At 02:59 17-10-99 , Ian Blenke wrote:
(WARNING, This doesn't work... perhaps someone can tell me why)
In MyTestProduct, populate MyFirstOptionList and MySecondOptionList in the Product properties.
In MyTestZClass_add:
<dtml-with "MyTestZClass.createInObjectManager(REQUEST['id'], REQUEST)"> <dtml-call "REQUEST.set('MyFirstOptionList', _['MyFirstOptionList'])"> <dtml-call "REQUEST.set('MySecondOptionList', _['MySecondOptionList'])"> <dtml-call "propertysheets.Basic.manage_editProperties(REQUEST)"> </dtml-with>
Because of the with tag, you are inside the namespace of your newly created ZClass instance. _['MyFirstOptionList'] (or just plain MyFirstOptionList) will retrieve the MyFirstOptionList of that instance, which is empty. You can copy the value using a let tag: <dtml-let def1=MyFirstOptionList def2=MySecondOptionList <dtml-with "MyTestZClass.createInObjectManager(REQUEST['id'], REQUEST)"> <dtml-call "REQUEST.set('MyFirstOptionList', def1)"> <dtml-call "REQUEST.set('MySecondOptionList', def2)"> <dtml-call "propertysheets.Basic.manage_editProperties(REQUEST)"> </dtml-with> <dtml-let> -- Martijn Pieters, Web Developer | Antraciet http://www.antraciet.nl | T: +31 35 7502100 F: +31 35 7502111 | mj@antraciet.nl http://www.antraciet.nl/~mj | PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149 ---------------------------------------------
participants (3)
-
Ian Blenke -
Martijn Pieters -
Stuart 'Zen' Bishop