anyone skilled in the ways of changing page properties?
::: on a standard page served by zope, user enters pagename into a field and presses submit ------------ <form method=GET action=createwikipage> <input type="text" name="pagename"> <input type="submit" name="submit" value="Submit"> </form> ------------ ::: createwikipage is a dtml method to which pagename is passed onto ::: a ZWiki page is now successfully created with the pagename specified by the user as the id ------------ <dtml-call "manage_addZWikiPage(id=pagename, title='')"> ------------ ::: thanks to Geoff Gardiner's managed mode additions, the ZWiki page has an extra boolean property called managed_mode, which i would like to set to true (1) : this is where, my troubles begin, and i have tried with the help of those helpful souls in #zope on irc.openprojects.net, many many combinations ------------ <dtml-with "_[pagename]"> <dtml-call "manage_editProperties({'managed_mode':1, 'type':'int'})"> </dtml-with> ------------ the above proceeds with no problems, but doesnt change the managed_mode to 1 ------------ <dtml-with "_[pagename]"> <dtml-call "REQUEST.set('managed_mode', 1)"> <dtml-call "manage_editProperties(REQUEST)"> </dtml-with> ------------ which again "works" but without any change like the first one, and after digging through the mailing list archive, i tried: ------------ <dtml-call "_[pagename].propertysheets.Basic.manage_changeProperties(manage_mode=1)"> ------------ which unfortunately leads to an attribute error with Error Value: 'string' object has no attribute 'propertysheets' i have tried god knows how many different combinations along similar lines, but they either give me zope errors or even worse, "work" but without having changed the value of the property. i would appreciate it if anyone could point me to what i am doing wrong here. i believe the main problem lies in "passing" the pagename to the dtml method for it to change the properties of. other than that, i have no idea what i am doing wrong, and i am close to tearing out my hair in frustration ::: now, if ever, i get that solved, i would also like to set the user who submitted the pagename as the page_owner of the new page. again, page_owner is a new ZWiki property due to Geoff's work =) and for this, i presume, whatever dtml works with the above change for managed mode, with the slight change of : ------------ manage_changeProperties(page_owner=AUTHENTICATED_USER) or manage_changeProperties('page_owner', 'AUTHENTICATED_USER.getUserName()', 'string') ------------ ::: now, i would like to create a new property on the ZWiki page, called page_creation_time, and set the the creation time/date as the value ------------ manage_addProperty('page_creation_time',ZopeTime(),'date') ------------ ::: and finally, the user is redirected to the editform of the page (and i am proud to say that this is working ;) ------------ <dtml-call "RESPONSE.redirect(_['URL1'] + '/' + REQUEST['pagename'] + '/editform?cols=60&rows=20')"> ------------ if anyone can help me with the setting of the managed_mode, i would be delighted and they would earn a big spot on this site of mine <g> and, if anyone can also provide code that works to set the page_owner and page_creation_time, then i will do anything to make you happy. thanks in advance for any help -- best regards, tav [slackware, running zope 2.2, served through Apache ProxyPass + Site Access, with ZWiki 0.6.1 with Geoff Gardiner's mm3 and the CVS version of PTK from two days ago]
Hi tav, Try changing all your _[pagename] to _.getitem(pagename,0), especially when you're getting errors about strings not having attributes. _[pagename] will call the object's __call__ method, if it has one and return the result, rather then the actual object. Which can be more than a little irritating ;-) getitem gives you more control: getitem(object,0) will always return the object. getitem(object,1) will __call__ it if it can. cheers, Chris
Chris Withers wrote:
Try changing all your _[pagename] to _.getitem(pagename,0), especially when you're getting errors about strings not having attributes.
Chris, you are a star! I made the whole of the site in two days, but wasnt able to work out this particular problem for over another two days!. learnt a lot of dtml in an attempt to do so, but still hadnt solved it :/ once again, thanks Chris for the lifesaver. Also, special thanks to AdamK, who followed me up on IRC, and helped resolve it. now, only one more thing needs resolving... <g> ... when i do the following: manage_changeProperties(page_owner=AUTHENTICATED_USER) i get the error ------------- Error Type: ValueError Error Value: Invalid property value: wrapped object ------------- course, if i put ' ' around AUTHENTICATED_USER, it works but it then uses that literally, which is not what is needed. any ideas as to how i can insert the username into the property field? much appreciated, and once again, thanks in advance. -- best regards, tav
tav, try manage_changeProperties(page_owner=AUTHENTICATED_USER.getUserName()) ----- Original Message ----- From: "tav" <tav@espnow.com> Cc: <zope@zope.org> Sent: Friday, July 28, 2000 12:14 PM Subject: Re: [Zope] anyone skilled in the ways of changing page properties?
Chris Withers wrote:
Try changing all your _[pagename] to _.getitem(pagename,0), especially when you're getting errors about strings not having attributes.
Chris, you are a star!
I made the whole of the site in two days, but wasnt able to work out this particular problem for over another two days!. learnt a lot of dtml in an attempt to do so, but still hadnt solved it :/
once again, thanks Chris for the lifesaver. Also, special thanks to AdamK, who followed me up on IRC, and helped resolve it.
now, only one more thing needs resolving... <g> ... when i do the following:
manage_changeProperties(page_owner=AUTHENTICATED_USER)
i get the error
------------- Error Type: ValueError Error Value: Invalid property value: wrapped object -------------
course, if i put ' ' around AUTHENTICATED_USER, it works but it then uses that literally, which is not what is needed. any ideas as to how i can insert the username into the property field?
much appreciated, and once again, thanks in advance.
-- best regards, tav
_______________________________________________ Zope maillist - Zope@zope.org 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 )
tav,
try
manage_changeProperties(page_owner=AUTHENTICATED_USER.getUserName())
Phil, cheers, that works =) though, the strangest thing is that i had tried that and had gotten attribute errors, which i thought was arising due to the lack of ' ' around it... hmz, strange, but it works now... so. thanks i hope that i do justice to the help that you have all given me; i just need to do a bit more work, and then i can launch the site for everyone to see -- best regards, tav
participants (3)
-
Chris Withers -
Phil Harris -
tav