Johan -
I have done a similiar hotfix by using None - which I think is a
better alternative than ''.
If you want to see all of the source, download the following Product,
http://www.zope.org/Members/natsukashi/Products/CMFPropertyCore, and
look inside the file CMFPropertyCore/LinkPropertyManager.py
1) I created my own converter functions and simply call the real
function if the value is not none. Here is an excerpt from a file
called LinkPropertyManager.py:
from OFS.PropertyManager import PropertyManager
from ZPublisher import Converters
class LinkPropertyManager(PropertyManager):
def field2float(v):
if not v:
return None
else:
return Converters.field2float(v)
def field2int(v):
if not v:
return None
else:
return Converters.field2int(v)
def field2long(v):
if not v:
return None
else:
return Converters.field2long(v)
def field2date(v):
if not v:
return None
else:
return Converters.field2date(v)
def field2link(v):
if hasattr(v,'read'): v=v.read()
else: v=str(v)
return v
type_converters = Converters.type_converters
type_converters.update({'float' : field2float
, 'int' : field2int
, 'long' : field2long
, 'date' : field2date
, 'link' : field2link
})
PropertyManager.type_converters = LinkPropertyManager.type_converters
2) Since you are patching the type converter, you might as well patch
the manage_propertiesForm. This can be done by hotfixing the
OFS.PropertyManager.PropertyManager.manage_propertiesForm value with
your own dtml file.
Here is a diff between the CMFPropertyCore/dtml/properties.dtml file
and zope's properties.dtml file.
bash$ diff -c properties.dtml
/opt/arseed/tfs-lib/zope/zope-2.4.1/lib/python/OFS/dtml/properties.dtml
*** properties.dtml Thu Aug 9 10:41:41 2001
---
/opt/arseed/tfs-lib/zope/zope-2.4.1/lib/python/OFS/dtml/properties.dtml
Wed Oct 3 07:49:38 2001
***
*** 58,74
dtml-if type == 'int'
input type=text name=dtml-var id:dtml-var
type size=35 value=dtml-if hasProperty(id)dtml-var
!'%s' % (getProperty(id) or '') html_quote/dtml-if
dtml-elif type == 'long'
input type=text name=dtml-var id:dtml-var type size=35
value=dtml-if hasProperty(id)dtml-var
!('%s' % (getProperty(id) or ''))[:-1] html_quote/dtml-if
dtml-elif type in ('float', 'date')
input type=text name=dtml-var id:dtml-var type size=35
!value=dtml-var getProperty(id) html_quote null=
dtml-elif type=='string'
input type=text name=dtml-var id:string size=35
!value=dtml-var getProperty(id) html_quote null=
dtml-elif type=='boolean'
input type=checkbox name=dtml-var id:boolean size=35
dtml-if getProperty(id)CHECKED/dtml-if
--- 58,74
dtml-if type == 'int'
input type=text name=dtml-var id:dtml-var
type size=35 value=dtml-if hasProperty(id)dtml-var
!'%s' % getProperty(id) html_quote/dtml-if
dtml-elif type == 'long'
input type=text name=dtml-var id:dtml-var type size=35
value=dtml-if hasProperty(id)dtml-var
!('%s' % getProperty(id))[:-1] html_quote/dtml-if
dtml-elif type in ('float', 'date')
input type=text name=dtml-var id:dtml-var type size=35
!value=dtml-var getProperty(id) html_quote
dtml-elif type=='string'
input type=text name=dtml-var id:string size=35
!value=dtml-var getProperty(id) html_quote
dtml-elif type=='boolean'
input type=checkbox name=dtml-var id:boolean size=35
dtml-if getProperty(id)CHECKED/dtml-if
***
*** 77,83
value=dtml-in getProperty(id)dtml-var sequence-item
html_quote /dtml-in
dtml-elif type=='text'
textarea name=dtml-var id:text rows=6 cols=35dtml-var
!getProperty(id) html_quote null=/textarea
dtml-elif type=='lines'
textarea name=dtml-var id:lines rows=6 cols=35dtml-in
getProperty(id)dtml-var sequence-item html_quotedtml-if
--- 77,83
value=dtml-in getProperty(id)dtml-var sequence-item
html_quote /dtml-in
dtml-elif type=='text'
textarea name=dtml-var id:text rows=6 cols=35dtml-var
!getProperty(id) html_quote/textarea
dtml-elif type=='lines'
textarea name=dtml-var id:lines rows=6 cols=35dtml-in
getProperty(id)dtml-var sequence-item html_quotedtml-if
***
*** 91,97
dtml-in getProperty(select_variable)
option
dtml-if
_['sequence-item']==getProperty(id)SELECTED/dtml-if
! dtml-var sequence-item html_quote null= /option
/dtml-in
/select
/div
--- 91,97
dtml-in getProperty(select_variable)
option
dtml-if
_['sequence-item']==getProperty(id)SELECTED/dtml-if
! dtml-var sequence-item