Re: [Zope] Problems with Coding differences to do same stuff... boundary="------------EAFFAD5A57052936695E91D7"
Trying to do a simple thing as creating a document and then adding a property with an DTML method, found that the following code does not work, it comes up with a password request (all security settings are at defaults):
<dtml-call "company.noticias.manage_addDTMLDocument(titulo,subtitulo,texto)"> <dtml-with "company.noticias._[titulo]"> <dtml-call "propertysheets.manage_addProperty('link',resumen,'text')" > </dtml-with>
Try <dtml-with "_.getattr(company.noticias,_[titulo])"> In DTML, you are not allowed to access any attribute starting with "_". And in fact, "_" is not even an attribute of "company.noticias". Dieter
Hi, thanks for your comment !! I know about not beeing allowed to access attributes that start with "_". Actually what is intended here is for _[titulo] to be evaluated to the name of a folder, the one that has just been created by the manage_addDTMLDocument call (which worked fine)with the name specified by the user in a form field. <dtml-call "company.noticias.manage_addDTMLDocument(titulo,subtitulo,texto)"> <dtml-with "company.noticias._[titulo]"> <dtml-call "propertysheets.manage_addProperty('link',resumen,'text')" > </dtml-with> The variable "titulo" comes from a form that calls itself so, I expected company.noticias._[titulo] to be evaluated say as "company.noticias.january" assuming the user entered "january" on the form. Nevertheless, on my alternative coding, _[titulo] evaluated correctly, it's a pity such a large coding had to be made, even introducing an "un-necesary" loop-search and an "if" test, to accomplish what seemed trivial the way I exposed in the first place...unless I am missing something..... <dtml-call "company.noticias.manage_addDTMLDocument(titulo,subtitulo,texto)"> <dtml-with "company.noticias"> <dtml-in objectValues> <dtml-in propertyValues> <dtml-if "id() == _[titulo]"> <dtml-with id> <dtml-call "propertysheets.manage_addProperty('link',resumen,'text')"
</dtml-with> </dtml-if> Any comments.? Thanks and regards. Felipe Barousse Dieter Maurer wrote:
Trying to do a simple thing as creating a document and then adding a property with an DTML method, found that the following code does not work, it comes up with a password request (all security settings are at defaults):
<dtml-call "company.noticias.manage_addDTMLDocument(titulo,subtitulo,texto)"> <dtml-with "company.noticias._[titulo]"> <dtml-call "propertysheets.manage_addProperty('link',resumen,'text')" > </dtml-with>
Try <dtml-with "_.getattr(company.noticias,_[titulo])">
In DTML, you are not allowed to access any attribute starting with "_". And in fact, "_" is not even an attribute of "company.noticias".
Dieter
Felipe E Barousse Boue writes:
I know about not beeing allowed to access attributes that start with "_". I gave you a solution in my post, didn't I?
Again, try: <dtml-with "_.getattr(company.noticias,_[titulo])"> <dtml-call ....> </dtml-with>
Actually what is intended here is for _[titulo] to be evaluated to the name of a folder ... Of cause.
However, your expressions do not work like this. They have an evaluation order: "a.b[c]" is "(a.b)[c]" and not "a. (b[c])". To give you a better known analogy: if you have "5 * 1+1" then the result is "6" and not "10", even so "1+1" is "2" in a different context. In the special case of the "." operator, the right parameter must even be a name and can not be an expression. Thus, "a . (b[c])" is a syntax error. You have the "getattr" operator to obtain such "computed accesses": to obtain the effect of "a .(b[c])", you use "getattr(a,b[c])". That is what I proposed above (and in the last post). Dieter
participants (2)
-
Dieter Maurer -
Felipe E Barousse Boue