I have one web server that I am using with zope running on the same box. I want to know how I could transfer session info from one url at www.domain.com to my secure site at secure.domain.com. As far as I can tell, I don't have access to the same session data. This is for a shoppping cart app that would have a user back and forth but I want to maintain the contents of the cart no matter where they may be. Thanks, -- Ben Bush Center 7, Systems Administrator 801-655-2640
Hello... anybody know how to convert the row returned from an Z SQL into a dictionary? Jerry
anybody know how to convert the row returned from an Z SQL into a dictionary?
You could write a Python function (or in Zope terms, a Python Script ) like this that converts an object to a dictionary def class2dict(o): """Return a dictionary from object that has public variable -> key pairs """ dict = {} #all the attributes in a class are already in __dict__ for elem in o.__dict__.keys(): if elem.find("_" + o.__class__.__name__) == 0: continue #We discard private variables, which are automatically #named _ClassName__variablename, when we define it in #the class as __variablename else: dict[elem] = o.__dict__[elem] return dict Note: this is tested in Python world; but I haven't used it in Zope ZSQL. - Babu -- http://vsbabu.org/
Thanks for your help, but.... I tried this routine (mythod) both as a python script and as an External python script. as a python script I get errors stating that "__" variables are private... as external method I get the following errors: Error Type: AttributeError Error Value: __dict__ Jerry On Sat, 2003-08-09 at 17:49, Satheesh Babu wrote:
anybody know how to convert the row returned from an Z SQL into a dictionary?
You could write a Python function (or in Zope terms, a Python Script ) like this that converts an object to a dictionary
def class2dict(o): """Return a dictionary from object that has public variable -> key pairs """ dict = {} #all the attributes in a class are already in __dict__ for elem in o.__dict__.keys(): if elem.find("_" + o.__class__.__name__) == 0: continue #We discard private variables, which are automatically #named _ClassName__variablename, when we define it in #the class as __variablename else: dict[elem] = o.__dict__[elem] return dict
Note: this is tested in Python world; but I haven't used it in Zope ZSQL.
- Babu -- http://vsbabu.org/
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
This one is pretty straightforward. You can turn a ZSQL result set into a list of dictionaries simply by calling the dictionaries() method on the result set. For example: results = ZSQLMethod.getSomethingFromDB() dicts = results.dictionaries() Hope that helps, Kevin Jerry Westrick wrote:
Hello...
anybody know how to convert the row returned from an Z SQL into a dictionary?
Jerry
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Ah... that is exactly what I wanted but...... with the following code: # Get User Info for row in context.Get_UserInfo(user=request.AUTHENTICATED_USER): values['user'] = row.dictionary() print values['user'] return printed I get an error: Error Type: AttributeError Error Value: dictionary Ditto for dictionaries() On Sun, 2003-08-10 at 00:34, Kevin Carlson wrote:
This one is pretty straightforward. You can turn a ZSQL result set into a list of dictionaries simply by calling the dictionaries() method on the result set.
For example:
results = ZSQLMethod.getSomethingFromDB() dicts = results.dictionaries()
Hope that helps,
Kevin
Jerry Westrick wrote:
Hello...
anybody know how to convert the row returned from an Z SQL into a dictionary?
Jerry
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Thanky you everybody.... I finally got it... I'll explain it here (maybe someone is as silly as I am and this'll help) Point 1: Z SQL Method returns a result set. Point 2: a result set, has a ".dictionaries()" method Point 3: The result set, contains a list of (instances of r) Point 4: an instance of r does NOT have a .dictionaries() nor anything similar! so insead of for row in (context.Get_Template(...)): values[row['username']] = row.dictionary() I need to use: result = context.Get_Template(...) for row in (result.dictionaries()) values[row['username']] = row Took a while but I finally got it! Jerry P.S. Thanks again for all your patience and help... On Sat, 2003-08-09 at 01:30, Jerry Westrick wrote:
Hello...
anybody know how to convert the row returned from an Z SQL into a dictionary?
Jerry
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Hi all, I am developing a utility for admin type of user. The problem i am facing is ,the admin type of user is not able to access the properties of other acl_users where as he is in a position to access his own properties and change them. The Properties are stored in the portal_memberdata like user email etc. Here is the code which is causing problem <div tal:define="purl here/portal_url; mtool here/portal_membership; member mtool/getAuthenticatedMember; "> The function getAuthenticatedMember returns the member object by which i am able to access the currently logged in user properties like his email etc. Now what i want is that when a admin user has logged in, he should be in a position to access the other acl_member's member object and acceess his properties like email stored in portal_member data. The method something like this : <div tal:define="purl here/portal_url; mtool here/portal_membership; member mtool/getAuthenticatedMember('memberid'); "> Kindly answer as early as Possible. Its Urgent. Thanks in advance. rgds karuneesh
It would have been better to ask this CMF related question in the CMF mailing list (<mailto:zope-cmf@zope.org>). Karuneesh Bagga wrote at 2003-8-11 14:09 +0530:
... The function getAuthenticatedMember returns the member object by which i am able to access the currently logged in user properties like his email etc.
You can use the "MembershipTool" method "getMemberById" to obtain a "MemberData" object for a member identified by it id (aka "username"). This method is protected by the "ManagePortal" permission. Thus, you may need a proxie role. Then you can use the "MemberData" method "setProperties" to modify the properties for this member. Dieter
The new version of the Zope book covers this see: http://zope.org/Documentation/Books/ZopeBook/current/RelationalDatabases.stx It's near the bottom of the page. Andrew -- Logical Progression Ltd, 20 Forth Street, Edinburgh EH1 3LH, UK Tel: +44 (0)131 550 3733 Web: http://www.logicalprogression.net/
From: Jerry Westrick <Jerry@Westrick.Com> Reply-To: Jerry@Westrick.com Date: 09 Aug 2003 01:30:43 +0200 To: zope@zope.org Subject: [Zope] Z SQL row to dictionary
Hello...
anybody know how to convert the row returned from an Z SQL into a dictionary?
Jerry
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
participants (7)
-
Andrew Veitch -
Ben Bush -
Dieter Maurer -
Jerry Westrick -
Karuneesh Bagga -
Kevin Carlson -
Satheesh Babu