[CMF-checkins] CVS: CMF/CMFSetup - workflow.py:1.18
Tres Seaver
tseaver at zope.com
Thu Jun 24 14:25:11 EDT 2004
Update of /cvs-repository/CMF/CMFSetup
In directory cvs.zope.org:/tmp/cvs-serv2595
Modified Files:
workflow.py
Log Message:
- Preserve non-string values for variable defaults.
=== CMF/CMFSetup/workflow.py 1.17 => 1.18 ===
--- CMF/CMFSetup/workflow.py:1.17 Thu Jun 24 13:59:05 2004
+++ CMF/CMFSetup/workflow.py Thu Jun 24 14:24:41 2004
@@ -407,12 +407,15 @@
guard = v.getInfoGuard()
+ default_type = _guessVariableType( v.default_value )
+
info = { 'id' : k
, 'description' : v.description
, 'for_catalog' : bool( v.for_catalog )
, 'for_status' : bool( v.for_status )
, 'update_always' : bool( v.update_always )
, 'default_value' : v.default_value
+ , 'default_type' : default_type
, 'default_expr' : v.getDefaultExprText()
, 'guard_permissions' : guard.permissions
, 'guard_roles' : guard.roles
@@ -993,13 +996,17 @@
assert len( nodes ) <= 1, nodes
if len( nodes ) < 1:
- return { 'value' : '', 'expression' : '' }
+ return { 'value' : '', 'expression' : '', 'type' : 'n/a' }
node = nodes[ 0 ]
value_nodes = node.getElementsByTagName( 'value' )
assert( len( value_nodes ) <= 1 )
+ value_type = 'n/a'
+ if value_nodes:
+ value_type = value_nodes[ 0 ].getAttribute( 'type' ) or 'n/a'
+
value_text = value_nodes and _coalesceTextNodeChildren( value_nodes[ 0 ]
, encoding
) or ''
@@ -1012,6 +1019,7 @@
) or ''
return { 'value' : value_text
+ , 'type' : value_type
, 'expression' : expr_text
}
@@ -1033,6 +1041,9 @@
from DateTime.DateTime import DateTime
+ if value is None:
+ return 'none'
+
if isinstance( value, DateTime ):
return 'datetime'
@@ -1054,6 +1065,9 @@
from DateTime.DateTime import DateTime
+ if type_id == 'none':
+ return None
+
if type_id == 'datetime':
return DateTime( value )
@@ -1137,9 +1151,13 @@
, 'guard_expr' : guard[ 'expression' ]
}
+ default = v_info[ 'default' ]
+ default_value = _convertVariableValue( default[ 'value' ]
+ , default[ 'type' ] )
+
v.setProperties( description = v_info[ 'description' ]
- , default_value = v_info[ 'default' ][ 'value' ]
- , default_expr = v_info[ 'default' ][ 'expression' ]
+ , default_value = default_value
+ , default_expr = default[ 'expression' ]
, for_catalog = v_info[ 'for_catalog' ]
, for_status = v_info[ 'for_status' ]
, update_always = v_info[ 'update_always' ]
More information about the CMF-checkins
mailing list