Hi, I am a new user of zope, and I have some questions: a) how do I call hash on some text object. What I want to do is generate a text variable from an input form, then hash this and get a (hopefully) unique 32-bit integer number. I want to generate unique keys, as the text is unique, and the hash integer will much faster to pass around. I tried <dtml-call hash(text)> but it produces nothing. Do I have to do this in a python method? b) is there a variable that holds the current user's name? like <dtml-var username> but it doesn't work. PS. I tried searching the lists and on yahoo and on the tutorials and on the zopebook, but I didn't find much information on hash and dtml-call. So please I would appreciate some help on this.
I don't know about the hash method - but dtml-call is not supposed to return anything you should try <dtml-var hash(text)> and as for part b of your question, check out the AUTHENTICATED_USER variable (try <dtml-var name="AUTHENTICATED_USER">) hth Laurie -----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Konstantinos Margaritis Sent: Thursday, June 07, 2001 11:43 AM To: zope@zope.org Subject: [Zope] hash and username variables Hi, I am a new user of zope, and I have some questions: a) how do I call hash on some text object. What I want to do is generate a text variable from an input form, then hash this and get a (hopefully) unique 32-bit integer number. I want to generate unique keys, as the text is unique, and the hash integer will much faster to pass around. I tried <dtml-call hash(text)> but it produces nothing. Do I have to do this in a python method? b) is there a variable that holds the current user's name? like <dtml-var username> but it doesn't work. PS. I tried searching the lists and on yahoo and on the tutorials and on the zopebook, but I didn't find much information on hash and dtml-call. So please I would appreciate some help on this. _______________________________________________ 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 )
"E. Seifert" wrote:
Hi,
Laurie Nason resonded to Konstantinos Margaritis:
and as for part b of your question, check out the AUTHENTICATED_USER variable (try <dtml-var name="AUTHENTICATED_USER">)
Isn't it "AUTHENTICATED_USER.getUserName()"?
No, it's <dtml-var "_.SecurityGetUser().getUserName()"> ...or however it's spelled now ;-) cheers, Chris
Hi, After a lot of experiments I finally found out how to do this. I am describing the process here in case someone is interested. It really is very simple, but for some reason I could not use the builtin hash() function/methond of zope. Thanks for all the help. a) First create a Python script method (I named it make_key) with 1 argument the object which to hash (I called it text): # make_key(text) # return the positive hash of the input argument return abs(hash(text)) Then in any methond you want to call the hash method, include the following: <dtml-var "make_key(insert_text_argument_here)"> That's it. It really saved me trying to create a database with unique objects (such as big texts) that I could not really use the indexing on them. I know I could use the ZCatalog class, but that will be in a next version :-) I still am in the process of learning zope. May I say that it is the greatest application server I ever saw? Congratulations! Regards Konstantinos Margaritis
participants (4)
-
Chris Withers -
E. Seifert -
Konstantinos Margaritis -
Laurie Nason