[Zope] ZClass propertysheet: Selection/Multi selection/Token - how?

Ian Blenke icblenke@2c2.com
Sat, 16 Oct 1999 20:59:26 -0400


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>