version 1.1, 2008/01/02 19:01:35
|
version 1.2, 2008/01/04 15:34:43
|
Line 13 from Products.PageTemplates.PageTemplate
|
Line 13 from Products.PageTemplates.PageTemplate
|
# do xml |
# do xml |
import xmlrpclibBasicAuth |
import xmlrpclibBasicAuth |
|
|
|
def unicodify(s): |
|
"""decode str (utf-8 or latin-1 representation) into unicode object""" |
|
if not s: |
|
return u"" |
|
if isinstance(s, str): |
|
try: |
|
return s.decode('utf-8') |
|
except: |
|
return s.decode('latin-1') |
|
else: |
|
return s |
|
|
|
def utf8ify(s): |
|
"""encode unicode object or string into byte string in utf-8 representation. |
|
assumes string objects to be utf-8""" |
|
if not s: |
|
return "" |
|
if isinstance(s, str): |
|
return s |
|
else: |
|
return s.encode('utf-8') |
|
|
|
|
class BaseSyncer(SimpleItem.Item, Persistent, Acquisition.Implicit, Role.RoleManager): |
class BaseSyncer(SimpleItem.Item, Persistent, Acquisition.Implicit, Role.RoleManager): |
"""This class contains Basic methods, even These methods will be common if we implements Module Syncer""" |
"""This class contains Basic methods, even These methods will be common if we implements Module Syncer""" |
Line 185 class BaseSyncer(SimpleItem.Item, Persis
|
Line 207 class BaseSyncer(SimpleItem.Item, Persis
|
# do any other encoding here |
# do any other encoding here |
# eg twofish, zlib etc |
# eg twofish, zlib etc |
# this will do me for now |
# this will do me for now |
return base64.encodestring(s) |
return base64.encodestring(utf8ify(s)) |
|
|
def _decode(self, s): |
def _decode(self, s): |
# do any other encoding here |
# do any other encoding here |