You are not logged in Log in Join
You are here: Home » Members » Toby Dickenson » Zope Unicode Support » Unicode support in PythonMethods

Log in
Name

Password

 

Unicode support in PythonMethods

The patch below to PythonMethods gives them the same level of Unicode support as my main Unicode patch does for DTML.

Caution: PythonMethods are not yet secure in Python 2.0, and this patch needs 2.0. Use it at your own risk.


Index: VSExec.py
===================================================================
RCS file: /cvs-repository/Products/DC/PythonMethod/zbytecodehacks/VSExec.py,v
retrieving revision 1.3
diff -c -r1.3 VSExec.py
*** VSExec.py	2000/08/31 22:08:56	1.3
--- VSExec.py	2000/10/19 10:28:30
***************
*** 228,234 ****
          add('\n')
  def _join_printed(printlist):
      return join(printlist, '')
! _join_printed = bind(_join_printed, join=join, map=map, str=str)
  
  general_special_globals['$print_handler'] = _print_handler
  general_special_globals['$join_printed'] = _join_printed
--- 228,247 ----
          add('\n')
  def _join_printed(printlist):
      return join(printlist, '')
! 
! try:
!     from DocumentTemplate.DT_Util import join_unicode
! except ImportError:
!     # Use pre-unicode methods
!     _join_printed = bind(_join_printed, join=join)
!     _print_handler = bind(_print_handler, str=str)
! else:
!     # Use Unicode methods if they are available
!     # These methods are implemented by the proposal at
!     # http://dev.zope.org/Wikis/DevSite/Proposals/UnicodeSupport
!     _join_printed = bind(_join_printed, join=join_unicode)
!     _print_handler = bind(_print_handler, str=ustr)
!    
  
  general_special_globals['$print_handler'] = _print_handler
  general_special_globals['$join_printed'] = _join_printed