[commits] r158 - selinux-site/trunk/buildout
jens at mail.se.linux.org
jens at mail.se.linux.org
Tis Dec 4 17:08:21 CET 2007
Author: jens
Date: 2007-12-04 17:08:20 +0100 (Tue, 04 Dec 2007)
New Revision: 158
Added:
selinux-site/trunk/buildout/ploneldap.patch
Log:
kkk
Added: selinux-site/trunk/buildout/ploneldap.patch
===================================================================
--- selinux-site/trunk/buildout/ploneldap.patch (rev 0)
+++ selinux-site/trunk/buildout/ploneldap.patch 2007-12-04 16:08:20 UTC (rev 158)
@@ -0,0 +1,59 @@
+--- parts/dist-products/PloneLDAP/property.py 2007-09-25 23:51:17.000000000 +0200
++++ property.py 2007-12-04 16:50:24.000000000 +0100
+@@ -2,6 +2,8 @@
+ from Products.PluggableAuthService.utils import classImplements
+ from Products.PluggableAuthService.UserPropertySheet import UserPropertySheet
+ from Products.PlonePAS.interfaces.propertysheets import IMutablePropertySheet
++from Products.CMFCore.interfaces import ISiteRoot
++from zope.component import getUtility
+
+
+ class LDAPPropertySheet(UserPropertySheet):
+@@ -14,14 +16,31 @@
+ for x in acl.getSchemaConfig().values() \
+ if x['public_name']]
+
++ schema=[(x[1], (x[0], x[2])) for x in self._ldapschema]
++
++ site_props = getUtility(ISiteRoot).portal_properties.site_properties
++ self._encoding = getattr(site_props, 'encoding', 'utf8')
++
+ properties=self._getCache(user)
+ if properties is None:
+ properties=self.fetchLdapProperties(user)
+ if properties:
++ schema_dict = dict(schema)
++
++ # user properties from LDAPUserFolder are unicode
++ # this propertysheet is used by plone/zope directly
++ # so the properties need the right encoding
++ encoded_properties = {}
++ for key, value in properties.items():
++ if schema_dict[key][1]=="lines":
++ encoded_value = [x.encode(self._encoding) for x in value]
++ else:
++ encoded_value = value.encode(self._encoding)
++ encoded_properties[key] = encoded_value
++ properties = encoded_properties
+ self._setCache(user, properties)
+
+- UserPropertySheet.__init__(self, id,
+- schema=[(x[1],x[2]) for x in self._ldapschema], **properties)
++ UserPropertySheet.__init__(self, id, schema=schema, **properties)
+
+
+ def fetchLdapProperties(self, user):
+@@ -64,11 +83,11 @@
+ for (key,value) in mapping.items():
+ if key in schema and self._properties[key]!=value:
+ if schema[key][1]=="lines":
+- value=[x.strip() for x in value]
++ value=[x.strip() for x in unicode(value, self._encoding)]
+ changes[schema[key][0]]=value
+ else:
+ value=value.strip()
+- changes[schema[key][0]]=[value]
++ changes[schema[key][0]]=[unicode(value, self._encoding)]
+ self._properties[key]=value
+
+ acl._delegate.modify(ldap_user.dn, attrs=changes)
More information about the commits
mailing list