[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Nuxeo-localizer] RE: Question re: using manage_editLocalProperty
From: |
Michael Stuempel |
Subject: |
[Nuxeo-localizer] RE: Question re: using manage_editLocalProperty |
Date: |
Tue, 6 Aug 2002 19:36:50 +0900 |
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...
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.
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
4. I get the following error:
Zope has encountered an error while publishing this resource.
Error Type: AttributeError
Error Value: manage_editLocalProperty
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.
Thanks again!
--Michael
---
Michael Stuempel, MCSE
address@hidden
-----Original Message-----
Date: Mon, 05 Aug 2002 10:14:29 +0200
From: =?UTF-8?B?SnVhbiBEYXZpZCBJYsOhw7FleiBQYWxvbWFy?= <address@hidden>
To: address@hidden
Subject: Re: [Nuxeo-localizer] Question re: using
manage_editLocalProperty
Reply-To: address@hidden
Hi Michael,
The code you've sent has a DTML method for the form which is also the
action, right?
Well, this is not a good idea, usually you do the form in DTML and the
action of the form in Python, which modifies the objects and does a
redirect back to the form. Try this approach.
Regarding the Localizer API to be used..
* For LocalPropertyManager
From unrestricted code you can use a lower level API, for
example:
ob._setLocalPropValue('title', 'en', 'hello world')
The parameters are the id of the local property, the language
being updated and the version for that language. Other related
methods are '_setLocalProperty' and '_delLocalProperty'.
From restricted code you've to use:
ob.manage_editLocalProperty('title', {'en': 'hello world'})
* For the message catalog
The method to be used is 'manage_editMessage', like this:
manage_editMessage('hello world', 'es', 'hola mundo')
The parameters are the message to be translated, the language
of the translation and the translation itself. Other related
methods are 'manage_delMessage'.
Looking for the solution to your problem I've seen that the API needs to
be improved.
Another thing, are you working from restricted or unrestricted code?,
that is, are you developing your application through the web or are you
building a Python product? You'll get a more accurate answer if I've
this information.
- [Nuxeo-localizer] RE: Question re: using manage_editLocalProperty,
Michael Stuempel <=