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

Ian Blenke icblenke@2c2.com
Sat, 16 Oct 1999 22:24:57 -0400


On Sat, 16 Oct 1999, Stuart 'Zen' Bishop wrote:

> 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 :-)

Thanks again for the help, Stuart! Unfortunately, the pain hasn't ended
quite yet :)

Another workaround alternative to fully qualifying the Product namespace
seems
to be wrapping all code in the ZCass methods that reference such properties,
ie:

     <SELECT NAME="myselectionname">
	<dtml-with "manage_addProduct['MyTestProduct']">
	 <dtml-in MyOptionList>
        <OPTION VALUE="<dtml-var sequence-item>"><dtml-var
sequence-item></OPTION>
 	 </dtml-in>
      </dtml-with>
     </SELECT>

This works well, and isn't an entirely objectionable approach.

Now that I have a working _addForm, the next trick is to get the form fields

populated in the created object. The correct place to do this seems to be in
_add - where the createInObjectManager is called:

	<dtml-with "MyTestZClass.createInObjectManager(REQUEST['id'],
REQUEST)">
       <dtml-comment>
       <!--#call "propertysheets.Basic.manage_editProperties(REQUEST)"-->
       </dtml-comment>
	</dtml-with>

Unfortunately, if you remove the comments, I get a "Error Type:
AttributeError",
"Error Value: Basic". Attempting to do anything like the following
beforehand
doesn't seem to help:

	<dtml-call "REQUEST.set('myselectionname', _['myselectionname'])">
	or
	<dtml-call "REQUEST.set('myselectionname',
_.getitem('myselectionname'))">

Off to the ZDG reference, and the following magic appears:

	<dtml-with "MyTestZClass.createInObjectManager(REQUEST['id'],
REQUEST)">
	 <dtml-call "manage_changeProperties({
         'myselectionname'   : REQUEST['myselectionname']
        })">
	</dtml-with>

This doesn't give me an error, but it also doesn't seem to do anything.

There's something here I'm not getting, and it's driving me batty.

Any help is quite graciously appreciated :)

- Ian C. Blenke <ian@blenke.com> <icblenke@2c2.com>
"There's always more than one way to shoot yourself in the foot..."