Commit 216279ad authored by Jim Fulton's avatar Jim Fulton

Improved property handling.

parent 09848456
__doc__="""Object Manager __doc__="""Object Manager
$Id: ObjectManager.py,v 1.4 1997/08/08 16:54:12 jim Exp $""" $Id: ObjectManager.py,v 1.5 1997/08/08 23:03:51 jim Exp $"""
__version__='$Revision: 1.4 $'[11:-2] __version__='$Revision: 1.5 $'[11:-2]
from SingleThreadedTransaction import Persistent from SingleThreadedTransaction import Persistent
...@@ -11,8 +11,9 @@ from Globals import ManageHTMLFile,PublicHTMLFile ...@@ -11,8 +11,9 @@ from Globals import ManageHTMLFile,PublicHTMLFile
from Globals import MessageDialog from Globals import MessageDialog
from App.Management import Management from App.Management import Management
from Acquisition import Acquirer from Acquisition import Acquirer
from string import find,joinfields from string import find,join,lower
from urllib import quote from urllib import quote
from DocumentTemplate import html_quote
class ObjectManager(Acquirer,Management,Persistent): class ObjectManager(Acquirer,Management,Persistent):
"""Generic object manager """Generic object manager
...@@ -163,7 +164,7 @@ class ObjectManager(Acquirer,Management,Persistent): ...@@ -163,7 +164,7 @@ class ObjectManager(Acquirer,Management,Persistent):
for p in self._properties: for p in self._properties:
n=p['id'] n=p['id']
try: setattr(self,n,REQUEST[n]) try: setattr(self,n,REQUEST[n])
except: pass except: setattr(self,n,'')
return self.manage_propertiesForm(self,REQUEST) return self.manage_propertiesForm(self,REQUEST)
def manage_delProperties(self,ids,REQUEST): def manage_delProperties(self,ids,REQUEST):
...@@ -187,28 +188,56 @@ class ObjectManager(Acquirer,Management,Persistent): ...@@ -187,28 +188,56 @@ class ObjectManager(Acquirer,Management,Persistent):
def _defaultInput(self,n,t,v): def _defaultInput(self,n,t,v):
return '<INPUT NAME="%s:%s" SIZE="50" VALUE="%s"></TD>' % (n,t,v) return '<INPUT NAME="%s:%s" SIZE="50" VALUE="%s"></TD>' % (n,t,v)
def _stringInput(self,n,t,v):
return ('<INPUT NAME="%s:%s" SIZE="50" VALUE="%s"></TD>'
% (n,t,html_quote(v)))
def _booleanInput(self,n,t,v):
if v: v="CHECKET"
else: v=''
return ('<INPUT TYPE= "CHECKBOX" NAME="%s:%s" SIZE="50" %s></TD>'
% (n,t,v))
def _selectInput(self,n,t,v): def _selectInput(self,n,t,v):
s=['<SELECT NAME="%s:%s">' % (n,t)] s=['<SELECT NAME="%s:%s">' % (n,t)]
map(lambda i: s.append('<OPTION>%s' % i), v) map(lambda i: s.append('<OPTION>%s' % i), v)
s.append('</SELECT>') s.append('</SELECT>')
return joinfields(s,'\n') return join(s,'\n')
def _linesInput(self,n,t,v): def _linesInput(self,n,t,v):
try: v=html_quote(join(v,'\n'))
except: v=''
return ( return (
'<TEXTAREA NAME="%s:lines" ROWS="10" COLS="50">%s</TEXTAREA>' % (n,v)) '<TEXTAREA NAME="%s:lines" ROWS="10" COLS="50">%s</TEXTAREA>'
% (n,v))
def _textInput(self,n,t,v): def _textInput(self,n,t,v):
return '<TEXTAREA NAME="%s" ROWS="10" COLS="50">%s</TEXTAREA>' % (n,v) return ('<TEXTAREA NAME="%s" ROWS="10" COLS="50">%s</TEXTAREA>'
% (n,html_quote(v)))
_inputMap={'float': _defaultInput,
'int': _defaultInput, _inputMap={
'long': _defaultInput, 'float': _defaultInput,
'string':_defaultInput, 'int': _defaultInput,
'lines': _linesInput, 'long': _defaultInput,
'text': _textInput, 'string': _stringInput,
} 'lines': _linesInput,
'text': _textInput,
propertyTypes=_inputMap.keys() 'date': _defaultInput,
'regex': _stringInput,
'Regex': _stringInput,
'regexs': _stringInput,
'Regexs': _stringInput,
'tokens': _stringInput,
'boolean': _booleanInput,
}
propertyTypes=map(lambda key: (lower(key), key), _inputMap.keys())
propertyTypes.sort()
propertyTypes=map(lambda key:
{'id': key[1],
'selected': key[1]=='string' and 'SELECTED' or ''},
propertyTypes)
def propertyInputs(self): def propertyInputs(self):
imap=self._inputMap imap=self._inputMap
...@@ -223,6 +252,9 @@ class ObjectManager(Acquirer,Management,Persistent): ...@@ -223,6 +252,9 @@ class ObjectManager(Acquirer,Management,Persistent):
############################################################################## ##############################################################################
# #
# $Log: ObjectManager.py,v $ # $Log: ObjectManager.py,v $
# Revision 1.5 1997/08/08 23:03:51 jim
# Improved property handling.
#
# Revision 1.4 1997/08/08 16:54:12 jim # Revision 1.4 1997/08/08 16:54:12 jim
# Changed to allow overriding of acquired attributes. # Changed to allow overriding of acquired attributes.
# #
......
...@@ -16,7 +16,7 @@ edit the value and click the "Change Properties" button. ...@@ -16,7 +16,7 @@ edit the value and click the "Change Properties" button.
<!--#in propertyInputs mapping--> <!--#in propertyInputs mapping-->
<TR> <TR>
<TD ALIGN="LEFT" VALIGN="TOP"><B><!--#var id fmt=spacify--></B></TD> <TD ALIGN="LEFT" VALIGN="TOP"><B><!--#var id fmt=spacify--></B></TD>
<TD ALIGN="LEFT" VALIGN="TOP"><!--#var input fmt=html_quote--></TD> <TD ALIGN="LEFT" VALIGN="TOP"><!--#var input--></TD>
</TR> </TR>
<!--#/in propertyInputs--> <!--#/in propertyInputs-->
<!--#/if propertyInputs--> <!--#/if propertyInputs-->
...@@ -48,8 +48,8 @@ value fields below and then clicking on the "Add Property" button. ...@@ -48,8 +48,8 @@ value fields below and then clicking on the "Add Property" button.
<TD ALIGN="LEFT" VALIGN="TOP">Type:</TD> <TD ALIGN="LEFT" VALIGN="TOP">Type:</TD>
<TD ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT" VALIGN="TOP">
<SELECT NAME="type"> <SELECT NAME="type">
<!--#in propertyTypes--> <!--#in propertyTypes mapping-->
<OPTION><!--#var __str__--> <OPTION <!--#var selected-->><!--#var id-->
<!--#/in propertyTypes--> <!--#/in propertyTypes-->
</SELECT> </SELECT>
</TD> </TD>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment