nuxeo-localizer
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Nuxeo-localizer] RE: Question re: using manage_editLocalProperty


From: Juan David Ibáñez Palomar
Subject: Re: [Nuxeo-localizer] RE: Question re: using manage_editLocalProperty
Date: Tue, 06 Aug 2002 16:53:50 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.0) Gecko/20020610 Debian/1.0.0-1

Michael Stuempel wrote:

Hi,

Thanks for the reply.
The advice makes sense and I'm turning the action of the form into a
Python script. This doesn't look very difficult, however I am having
trouble getting it done. I've made a python script that gets called as
the form action. The variables all appear to be passed correctly and I'm
ready to move onto the Localizer API.

Based on what I've read on Restricted vs Unrestricted
(http://www.zope.org//Wikis/DevSite/Projects/PythonMethods/UserGuide) it
looks like I'll be using restricted code, but I don't know enough to be
sure. Also, I get an error when I use the Unrestricted format in the
python script...


That's right, you're working with restricted code.


My problem now? seems to be passing the object to the python script.
This is what I've done:

1. I am using <dtml-with  restrictedTraverse(passedURL, _.None)> in the
form to get the namespace of the page I want to edit. The <dtm-with ...>
works and I get the correct information from that object (ie. Title,
Data, Language) in the form that gets built. I also use <dtml-call
"REQUEST.setVirtualRoot(editPagePath,hard=0)"> to set REQUEST
information. I don't know if this is a good or bad thing, since I can
get the information I need without it.


Don't use setVirtualRoot, it's for manipulating the url traversal.
To set REQUEST information type:

REQUEST.set('key', 'value')

However, I don't understand why do you need this.

To get the context, from the Python script, just use the 'context'
variable. I'm not sure to understand the 'restrictedTraverse' stuff.


2. The python script has the following code, where curID and curLang and
data are all passed. I tried passing REQUEST as well, but although I
didn't get an error passing it, it wasn't the REQUEST I was looking for
in the Python Method.

Parameters: curID, curLang, data, REQUEST

Python Method:
#Save the data
REQUEST.manage_editLocalProperty(curID, {curLang: data})

# Return passed data to check
print "Request: %s" % REQUEST,
print "id: %s" % curID,
print "Lang: %s" % curLang,
print "data: %s" % data
return printed


You don't need to pass the REQUEST, as you always can get it
through acquisition:

request = container.REQUEST



4. I get the following error:

       Zope has encountered an error while publishing this resource.

       Error Type: AttributeError
       Error Value: manage_editLocalProperty



Yep, 'manage_editLocalProperty' is a method of the 'LocalPropertyManager'
class, for example 'LocalContent' objects have it. It's not of the request
object.



5. If I comment out the REQUEST.manage... it runs and I can see that
what I want to be passed is passed correctly, however REQUEST is
different...local to the container.


I think the problem is that I don't know how to pass the object
properly. The data is correct, but the error seems to indicate that
REQUEST.manage_editLocalProperty() doesn't exist.

I'd appreciate any help.



I'm somewhat confused about what you're doing, at a first glance
it looks like you're following an approach much more complex than
needed.

Also, my suggestion is to develop a Python product, working through
the web is ok for simple things, but you're going to constantly face
problems you wouldn't have from the file system.


Anyway, let's me try to guess, only a bit. You want to change
'LocalContent' objects with your own forms, and you're developing
through the web, right?

Well, put a DTML method and a Python script somewhere in the
acquisition path, typically the root of your web site. The DTML
method is the edit form, the Python script is the action of the
form. If you've the following folder structure:

/root/a/b/content (LocalContent object)
/root/lc_edit_form (DTML Method)
/root/lc_edit (Python Script)

To edit the content object you have to go to the url:

/root/a/b/content/edit_form

Then the content object is the first in the acquisition path, then
you'll get its attributes through acquisition. The form would look
like:

<form action="lc_edit" method="post">
..
</form>

And the Python script would look like:

request = container.REQUEST
response = request.RESPONSE

context.manage_editLocalProperty(...)

response.redirect(request['HTTP_REFERER'])


However, it's still better to develop a Python product. But maybe
this is a quickest solution.

Hope this helps.



cheers,
david




reply via email to

[Prev in Thread] Current Thread [Next in Thread]