Re: [Zope] LoginManager with SQL and Skinscript: adding properties to propertysheet propertysheet

2001-01-08 Thread Dan L. Pierson

Aaron Payne [EMAIL PROTECTED] writes:

 I am following Dan Pierson's How-To SQL LoginManager with SQL and
 Skinscript. I am not able to add properties.

You may have noticed my silence on property sheets...  At first, I
didn't expect to use them, because I expected only members to edit
their "properties" and I'm certainly not going to expose the standard
Zope management interface to them.  After going through the latest PTK
sources some more, it looks like I may try using them after all.  In
either case, the important things to remember are:

- The actual property data isn't stored in the ZClass or its property
sheets, and the Skinscript code makes the ZClass "property" attributes
have values with or without property sheets, and

- The ZClass instances are ephemeral -- nothing is expected to store
them for any length of time (though they may be cached).

 I created LoginManager:LoginUser subclassed zclass def for a user with
 a propertysheet Basic.
 
 It had properties password and email.  The LM methods I tested failed
 so I deleted the properties.  Now I want to add them again. When I try
 I get:
 
 
 for password
 Invalid property id, password. It is in use.
 for email:
 Invalid property id, email. It is in use.
 
 I also deleted the entire propertysheet and tried to add the props but
 the same error occured.
 
 
 I can add new props but not ones that were deleted earlier. Is there a
 way around this problem?

I think you'll have to delete the whole ZClass and start over :-(.
This shouldn't be too much of a pain because you shouldn't have any
instances to worry about.  If you've written custom methods, you'll
want to copy them someplace before deleting the class.

Hope this helps,

Dan Pierson





___
Zope maillist  -  [EMAIL PROTECTED]
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 )




[Zope] LoginManager with SQL and Skinscript: adding properties topropertysheet propertysheet

2001-01-07 Thread Aaron Payne

Hi all,

I am following Dan Pierson's How-To SQL LoginManager with SQL and 
Skinscript. I am not able to add properties.

I created LoginManager:LoginUser subclassed zclass def for a user with a 
propertysheet Basic.
It had properties password and email.  The LM methods I tested failed so I 
deleted the properties.  Now I want to add them again. When I try I get:

for password
Invalid property id, password. It is in use.
for email:
Invalid property id, email. It is in use.

I also deleted the entire propertysheet and tried to add the props but the 
same error occured.

I can add new props but not ones that were deleted earlier. Is there a way 
around this problem?

Zope 2.2.1
System Platform: freebsd4

-Aaron


___
Zope maillist  -  [EMAIL PROTECTED]
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 )




[Zope] LoginManager - With SQL

2000-10-16 Thread ed colmar

Thanks for the tips everyone!

I keep going between UserDb and LoginManager to try to get this to work.
UserDb gives me weird errors, and isn't really current, so I'm focusing on
LM.

I feel like I'm getting closer to a solution, but I'm still having
difficuties...

I followed jPenny's how to regarding accessing SQL method variables from
within python, and wrapped the retrieveItem result in a User Class.  It
seems like it is at least running my code now, but no authentication...

Am I close?  Can Anyone working with LoginManager offer any insight into
this?

Thanks!

-e-

Here's the code I have in UserSources.py

class User(BasicUser):
"""  A wrapper for the basic user class """
icon='misc_/UserDb/User_icon'

def __init__(self, name, password, roles, domains):
self.name   =name
self.__ =password
self.roles  =filter(None, map(strip, split(roles, ',')))
self.domains=filter(None, map(strip, split(domains, ',')))

def getUserName(self):
return self.name

def _getPassword(self):
return self.__

def getRoles(self):
return self.roles

def getDomains(self):
return self.domains



class PGCryptUserSource(BasicUserSource):
"""  A sql based encrypted user source """
meta_type="PG Crypt User Source"
__plugin_kind__="User Source"

def retrieveItem(self, name):
try: res=self.getuserbyusername(username=name)
except: return None

fields2index={}
fieldnames=res._schema.items()

for i in range(len(fieldnames)):
fields2index[fieldnames[i][0]]=fieldnames[i][1]

username=res[0][fields2index['username']]
password=res[0][fields2index['password']]
roles=res[0][fields2index['roles']]
domains=res[0][fields2index['domains']]

return User(username, password, roles, domains)


def rolesForUser(self, user):
name = user.getUserName()
res = self.getuserbyusername(username=name)
fields2index={}
fieldnames=res._schema.items()
for i in range(len(fieldnames)):
fields2index[fieldnames[i][0]]=fieldnames[i][1]
roles=res[0][fields2index['roles']]
return roles

def domainsForUser(self, user):
name = user.getUserName()
res = self.getuserbyusername(username=name)
fields2index={}
fieldnames=res._schema.items()
for i in range(len(fieldnames)):
fields2index[fieldnames[i][0]]=fieldnames[i][1]
domains=res[0][fields2index['domains']]
return domains

def authenticateUser(self, user, password, request):
name = user.getUserName()
res = self.getuserbyusername(username=name)
fields2index={}
fieldnames=res._schema.items()
for i in range(len(fieldnames)):
fields2index[fieldnames[i][0]]=fieldnames[i][1]
passwd=res[0][fields2index['password']]
if crypt.crypt(password,'ab')==passwd:
return 1
else:
return 0




Here's one of the tracebacks that I get:

Error Type: TypeError
Error Value: argument 1: expected read-only character buffer, None found

Traceback (innermost last): File
/usr/local/zope/lib/python/ZPublisher/Publish.py, line 222, in
publish_module
File /usr/local/zope/lib/python/ZPublisher/Publish.py, line 187, in publish
File /usr/local/zope/lib/python/Zope/__init__.py, line 221, in
zpublisher_exception_hook (Object: Traversable)
File /usr/local/zope/lib/python/ZPublisher/Publish.py, line 162, in publish
File /usr/local/zope/lib/python/ZPublisher/BaseRequest.py, line 440, in
traverse
File /usr/local/zope/lib/python/Products/LoginManager/LoginManager.py, line
108, in validate (Object: ProviderContainer)
File /usr/local/zope/lib/python/Products/LoginManager/LoginMethods.py, line
235, in findLogin (Object: PlugInBase)
File /usr/local/zope/lib/python/Products/LoginManager/LoginManager.py, line
65, in getItem (Object: ProviderContainer)
File /usr/local/zope/lib/python/Products/ZPatterns/Rack.py, line 60, in
getItem (Object: ProviderContainer)
File /usr/local/zope/lib/python/Products/LoginManager/UserSources.py, line
522, in retrieveItem (Object: ProviderContainer)
File /usr/local/zope/lib/python/Products/LoginManager/UserSources.py, line
485, in __init__ TypeError: (see above)


___
Zope maillist  -  [EMAIL PROTECTED]
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 )




Re: [Zope] LoginManager - with SQL?

2000-10-13 Thread ed colmar


Has anyone been able to use LoginManager with a SQL db?  with or without
encryption?

I'm still baffled by this how-to:
http://www.zope.org/Members/jok/SQL_based_LoginManager

In this example, there are dtml-methods that do the work of the UserSource,
but there is no retrieveItem?

I would really love to get this working instead of having to revert back to
older depreciated products.

Thanks for any help!

-e-

From: "Aleksander Salwa" [EMAIL PROTECTED]

 I remember I had some troubles trying to put methods rolesForUser,
 domainsForUser, authenticateUser in UserSource class. They can be moved to
 user class. I did so.
 But your case is harder then mine, cause you don't have objects
 representing users in ZODB. Maybe there are problems with retrieveItem
 method ?
 Maybe you should build wrapper class around your database
 data - something like "pluggable brains" ?
 I have no more ideas :(



___
Zope maillist  -  [EMAIL PROTECTED]
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 )




Re: [Zope] LoginManager - with SQL?

2000-10-13 Thread Holger Lehmann

Well we use the UserDbFolder Product after havin the same/similar problems 
with the LoginManager :-)

- Holger

Am Fri, 13 Oct 2000 schrieben Sie:
 Has anyone been able to use LoginManager with a SQL db?  with or without
 encryption?

 I'm still baffled by this how-to:
 http://www.zope.org/Members/jok/SQL_based_LoginManager

 In this example, there are dtml-methods that do the work of the UserSource,
 but there is no retrieveItem?

 I would really love to get this working instead of having to revert back to
 older depreciated products.

 Thanks for any help!

 -e-

 From: "Aleksander Salwa" [EMAIL PROTECTED]

  I remember I had some troubles trying to put methods rolesForUser,
  domainsForUser, authenticateUser in UserSource class. They can be moved
  to user class. I did so.
  But your case is harder then mine, cause you don't have objects
  representing users in ZODB. Maybe there are problems with retrieveItem
  method ?
  Maybe you should build wrapper class around your database
  data - something like "pluggable brains" ?
  I have no more ideas :(

 ___
 Zope maillist  -  [EMAIL PROTECTED]
 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 )

-- 
---
catWorkX GmbH Hamburg
Dipl.-Ing. Holger Lehmann
Stresemannstr. 364
22761 Hamburg
Tel: +49 40 890 646-0
Fax: +49 40 890 646-66
mailto:[EMAIL PROTECTED]
http://www.catworkx.de
http://www.catbridge.de

___
Zope maillist  -  [EMAIL PROTECTED]
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 )