class hashView(BrowserView):
def init(self,context,request):
self.context=context
self.request=request #return "hi"
self.avariable="hello, i worked" #defcall(self):
# return "Hash without arguments work and no self"
def getHash(self,param):
return param+"test param"
def getHash2(self):
return "getHash 2 worked"
I would like to call the getHash and getHash2 method from a script in the zmi
If I try this
retval = context.unrestrictedTraverse('@@hashview/getHash2')
I get Insufficient Priviledges
I am able to obtain the values of getHash2 from a page template with the following
method with no parameters works
But, If i try to obtain the values of getHash, which takes a parameter using the following, nothing is returned.
Thank you for responding. I want to call it from a script, because the script will do some calculations and pass parameters to getHash. Also, If I choose to call getHash from the pagetemplate, How would I pass parameters to it?
I had this function as an External Method that I can call from various zmi scripts. External Methods are now deprecated and everything I read seem to indicate that you have to use a Browserview instead.
So, I have the code setup in a browserview. I can call it from a page template, but I do not know how to pass parameters to it from a page template. I also do not know how to call it from a zmi script.
For which are you getting insufficient privileges on restrictedTraverse(), or on call of a method of your view? In either case, you might need to make adjustments to your ZCML (either to permission or to allowed_attributes).
My script is supposed to take a few parameters and return a dictionary that contains a hashvalue and a timestamp. I cannot write the script in the zmi itself because it is importing hmac and time.
I am getting insufficient priviledge on the method call.
Because once the dictionary is returned. The zmi script that is calling the browserview has to act on the returned data before passing it to the pagetemplate.
I already have everything in place and working where the code is an external method. I don't want to rebuild everything. I just want to convert the external method to a BrowserView and call the various methods in it. We have many clients running Plone, an external method has to be copied to each everytime there is a change.