[Zope-dev] Wrap or not wrap i Zope source
Peter Bengtsson
peter@grenna.net
Wed, 9 Aug 2000 12:29:27 +0100
What I want to do is simple.
Modify the source of Zope so that one can select either wrap=off or
wrap=virtual in the textarea box of the documentEdit.dtml
I bet you all recognize these HTML bits (documentEdit.dtml):
<INPUT NAME=SUBMIT TYPE="SUBMIT" VALUE="Taller">
<INPUT NAME=SUBMIT TYPE="SUBMIT" VALUE="Shorter">
<INPUT NAME=SUBMIT TYPE="SUBMIT" VALUE="Wider">
<INPUT NAME=SUBMIT TYPE="SUBMIT" VALUE="Narrower">
And I want to add:
<INPUT NAME=SUBMIT TYPE="SUBMIT" VALUE="Change Wrap"> <!-- an on/off
button -->
This submitbutton should trigger the simple following DTML
(documentEdit.dtml):
<dtml-if wrap_or_not>
WRAP="virtual"
<dtml-else>
WRAP="Off"
</dtml-if>
I have checked the python source, but I'm definitly not a wiz or very good
with OOP.
The documentEdit.dtml document "actions" the form to manage_edit() found in
DTMLDocument.py and DTMLMethod.py:
def manage_edit(self,data,title,SUBMIT='Change',dtpref_cols='50',
dtpref_rows='20',REQUEST=None):
"""
Replaces a Documents contents with Data, Title with Title.
The SUBMIT parameter is also used to change the size of the editing
area on the default Document edit screen. If the value is
"Smaller",
the rows and columns decrease by 5. If the value is "Bigger", the
rows and columns increase by 5. If any other or no value is
supplied,
the data gets checked for DTML errors and is saved.
"""
self._validateProxy(REQUEST)
if self._size_changes.has_key(SUBMIT):
return
self._er(data,title,SUBMIT,dtpref_cols,dtpref_rows,REQUEST)
self.title=str(title)
if type(data) is not type(''): data=data.read()
self.munge(data)
if REQUEST:
message="Content changed."
return
self.manage_main(self,REQUEST,manage_tabs_message=message)
The _er method is found in DTMLMethod.py
def _er(self,data,title,SUBMIT,dtpref_cols,dtpref_rows,REQUEST):
dr,dc = self._size_changes[SUBMIT]
rows=max(1,atoi(dtpref_rows)+dr)
cols=max(40,atoi(dtpref_cols)+dc)
e=(DateTime('GMT') + 365).rfc822()
resp=REQUEST['RESPONSE']
resp.setCookie('dtpref_rows',str(rows),path='/',expires=e)
resp.setCookie('dtpref_cols',str(cols),path='/',expires=e)
return self.manage_main(
self,REQUEST,title=title,__str__=self.quotedHTML(data),
dtpref_cols=cols,dtpref_rows=rows)
I GUESS that it is in this method I do my changes (together with parameters
in manage_edit() [DTMLDocument.py and DTMLMethod.py])
Maybe something like this:
if wrap_cookie is 'off':
resp.setCookie('wrap_cookie','virtual',path='/',expires=e)
newwrap_status='virtual'
else:
resp.setCookie('wrap_cookie','off',path='/',expires=e)
newwrap_status='off'
...and...
return self.manage_main(
self,REQUEST,title=title,__str__=self.quotedHTML(data),
dtpref_cols=cols,dtpref_rows=rows,wrap_or_not=newwrap_status)
I don't dare to do anything yet, because I feel a bit unfonfy about changing
source at this level.
Can you please give me some hints or advice or maybe you already have this
done.
Peter Bengtsson - bloody good programmer
[ do I dare to keep my funny signature after this email? ]