Re: [Zope] Access object inside a folder
Sin Hang Kin a écrit : did u try that: dtml-in "PARENTS[0].objectValues(['DTML Document'])" sort=id do what u want /dtml-in Hope this help Bye Pio. Hi, I have put objects inside a folder tabledef and would like to refer them : dtml-in "_.getitem('tabledef').objectItems(['DTML Document'])" sort=id mapping dtml-var "_['sequence-item']" html_quote /dtml-in However, this does not work, But putting the objects in the current folder works without problems: dtml-in "objectItems(['DTML Document'])" sort=id dtml-var "_['sequence-item']" html_quote /dtml-in I also try: dtml-with tabledef dtml-in "objectItems(['DTML Document'])" sort=id dtml-var "_['sequence-item']" /dtml-in/dtml-with and some other combinations, all without success. How can I access the objects (DTML DOCUMENTS) inside a folder? 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 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. Can somebody help me with these? Rgs, Kent Sin - kentsin.weblogs.com kentsin.imeme.net ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev ) ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Access object inside a folder
Sin Hang Kin writes: dtml-in "_.getitem('tabledef').objectItems(['DTML Document'])" sort=id mapping dtml-var "_['sequence-item']" html_quote /dtml-in Error Type: AttributeError Error Value: __getitem__ This is as it should be: "objectItems" does not return a list of mapping objects. These objects do not have a mapping's "__getitem__" method. Therefore, you get the AttributeError. 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\DocumentTemplate\DT_With.py, line 132, in render (Object: tabledef) AttributeError: (see above) That is very strange! The error message (including traceback) tells that Zope tried to access "tabledef.__call__". This was impossible, because "tabledef" has no "__call__" attribute. The strange thing: your DTML snipped does not contain any place, where Zope must access "tabledef.__call__". Both in the "dtml-with" as well as in "_['sequence-item']", Zope will see, whether the objects are callable and if so, it will call them. It seems that "callable" returns true, but in fact one of the objects is indeed not "callable". 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__ That is the same as in the first example. 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. I am still not sure, what you are for. But at least, I understand your partial problem: accessing the content of a folder. I think I can help you with this. When you look at the ObjectReference at URL:http://zdp.zope.org (the Zope Documentation Portal), you will find that "objectItems" returns a list of pairs "(id,subobject)". "dtml-in" handles such list specially (- dtml-in reference): it calls the first component "sequence-key" and the second "sequence-item". The following DTML code works for me (Zope 2.1.6): dtml-in "tabledef.objectItems(['DTML Method'])" sort=sequence-key h1dtml-var sequence-key-- the subobject's id--/h1 dtml-var sequence-item -- the subobject itself, rendered-- /dtml-in Dieter ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] Access object inside a folder
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']))