[Zope] Access object inside a folder

Sin Hang Kin kentsin@poboxes.com
Wed, 28 Jun 2000 09:15:32 +0800


<dtml-in "_.getitem('tabledef').objectItems(['DTML Document'])" sort=id
mapping>
    <dtml-var "_['sequence-item']" html_quote>
</dtml-in>

Error Type: AttributeError
Error Value: __getitem__
Traceback (innermost last):
  File C:\Program Files\Zope2\lib\python\ZPublisher\Publish.py, line 222, in
publish_module
  File C:\Program Files\Zope2\lib\python\ZPublisher\Publish.py, line 187, in
publish
  File C:\Program Files\Zope2\lib\python\Zope\__init__.py, line 221, in
zpublisher_exception_hook
    (Object: ElementWithAttributes)
  File C:\Program Files\Zope2\lib\python\ZPublisher\Publish.py, line 171, in
publish
  File C:\Program Files\Zope2\lib\python\ZPublisher\mapply.py, line 160, in
mapply
    (Object: addNew)
  File C:\Program Files\Zope2\lib\python\ZPublisher\Publish.py, line 112, in
call_object
    (Object: addNew)
  File C:\Program Files\Zope2\lib\python\OFS\DTMLMethod.py, line 168, in
__call__
    (Object: addNew)
  File C:\Program Files\Zope2\lib\python\DocumentTemplate\DT_String.py, line
500, in __call__
    (Object: addNew)
  File C:\Program Files\Zope2\lib\python\DocumentTemplate\DT_In.py, line
691, in renderwob
    (Object: _.getitem('tabledef').objectItems(['DTML Document']))
  File C:\Program Files\Zope2\lib\python\DocumentTemplate\DT_Var.py, line
278, in render
    (Object: _['sequence-item'])
  File C:\Program Files\Zope2\lib\python\DocumentTemplate\DT_Util.py, line
333, in eval
    (Object: _['sequence-item'])
    (Info: _)
AttributeError: (see above)


> You note, that your examples have an essential difference:
> 1 uses "mapping", 2 does not.

<dtml-with tabledef>
<dtml-in "objectItems(['DTML Document'])" sort=id>
    <dtml-var "_['sequence-item']">
</dtml-in>
</dtml-with>

Error Type: AttributeError
Error Value: __call__
Traceback (innermost last):
  File C:\Program Files\Zope2\lib\python\ZPublisher\Publish.py, line 222, in
publish_module
  File C:\Program Files\Zope2\lib\python\ZPublisher\Publish.py, line 187, in
publish
  File C:\Program Files\Zope2\lib\python\Zope\__init__.py, line 221, in
zpublisher_exception_hook
    (Object: ElementWithAttributes)
  File C:\Program Files\Zope2\lib\python\ZPublisher\Publish.py, line 171, in
publish
  File C:\Program Files\Zope2\lib\python\ZPublisher\mapply.py, line 160, in
mapply
    (Object: addNew)
  File C:\Program Files\Zope2\lib\python\ZPublisher\Publish.py, line 112, in
call_object
    (Object: addNew)
  File C:\Program Files\Zope2\lib\python\OFS\DTMLMethod.py, line 168, in
__call__
    (Object: addNew)
  File C:\Program Files\Zope2\lib\python\DocumentTemplate\DT_String.py, line
500, in __call__
    (Object: addNew)
  File C:\Program Files\Zope2\lib\python\DocumentTemplate\DT_With.py, line
146, in render
    (Object: tabledef)
  File C:\Program Files\Zope2\lib\python\DocumentTemplate\DT_In.py, line
691, in renderwob
    (Object: objectItems(['DTML Document']))
  File C:\Program Files\Zope2\lib\python\DocumentTemplate\DT_Util.py, line
339, in eval
    (Object: _['sequence-item'])
    (Info: _)
  File <string>, line 0, in ?
  File C:\Program Files\Zope2\lib\python\DocumentTemplate\DT_Util.py, line
163, in careful_getitem
  File C:\Program Files\Zope2\lib\python\OFS\DTMLDocument.py, line 164, in
__call__
    (Object: f1)
  File C:\Program Files\Zope2\lib\python\DocumentTemplate\DT_String.py, line
500, in __call__
    (Object: f1)
  File C:\Program Files\Zope2\lib\python\OFS\DTMLMethod.py, line 164, in
__call__
    (Object: addNew)
  File C:\Program Files\Zope2\lib\python\DocumentTemplate\DT_String.py, line
500, in __call__
    (Object: addNew)
  File C:\Program Files\Zope2\lib\python\DocumentTemplate\DT_With.py, line
132, in render
    (Object: tabledef)
AttributeError: (see above)

If I add mapping:
<dtml-with tabledef>
<dtml-in "objectItems(['DTML Document'])" sort=id mapping>
    <dtml-var "_['sequence-item']">
</dtml-in>
</dtml-with>

Error Type: AttributeError
Error Value: __getitem__
Traceback (innermost last):
  File C:\Program Files\Zope2\lib\python\ZPublisher\Publish.py, line 222, in
publish_module
  File C:\Program Files\Zope2\lib\python\ZPublisher\Publish.py, line 187, in
publish
  File C:\Program Files\Zope2\lib\python\Zope\__init__.py, line 221, in
zpublisher_exception_hook
    (Object: ElementWithAttributes)
  File C:\Program Files\Zope2\lib\python\ZPublisher\Publish.py, line 171, in
publish
  File C:\Program Files\Zope2\lib\python\ZPublisher\mapply.py, line 160, in
mapply
    (Object: addNew)
  File C:\Program Files\Zope2\lib\python\ZPublisher\Publish.py, line 112, in
call_object
    (Object: addNew)
  File C:\Program Files\Zope2\lib\python\OFS\DTMLMethod.py, line 168, in
__call__
    (Object: addNew)
  File C:\Program Files\Zope2\lib\python\DocumentTemplate\DT_String.py, line
500, in __call__
    (Object: addNew)
  File C:\Program Files\Zope2\lib\python\DocumentTemplate\DT_With.py, line
146, in render
    (Object: tabledef)
  File C:\Program Files\Zope2\lib\python\DocumentTemplate\DT_In.py, line
691, in renderwob
    (Object: objectItems(['DTML Document']))
  File C:\Program Files\Zope2\lib\python\DocumentTemplate\DT_Util.py, line
333, in eval
    (Object: _['sequence-item'])
    (Info: _)
AttributeError: (see above)


I am using Zope 2.2b1

>  > Moreover, I would like to do the following:
>  >
>  > I have some properties of an object abc which have same name with the
object
>  > ids in the tabledef folder, I would also lookup the objects' properties
:
>  >
>  > <dtml-in propertyMap mapping>
>  >    <dtml-with tabledef.id>
> This will almost surely give a KeyError (tabledef.id).
> You must enclose it in "...".
>
>  >       <dtml-var help>
>  >      <dtml-var taborder>
>  >   </dtml-with>
>  > </dtml-in>
>
>  > Assume abc have a property address, then there should be a dtmldoc call
>  > address in tabledef, which have properties "help" and "tableorder". I
would
>  > like to retrieve them.
> I fear, I do not understand, what you want to do.

I have a folder call tabledef which use dtmldocument to keep some field
definition like its label, size, default value, help text etc. Which I would
like to generate the data entry form for it. The data will be stored as
object properties, so If I generate a edit form, then I should get the
property, lookup the field information in tabledef folder, and get the
label, size, information from there.

Rgs,

Kent Sin