[Zope] Re: Using ZopeEDIT with Notepad?

Martijn Pieters mj@digicool.com
Tue, 21 Mar 2000 11:41:03 +0100


On Tue, Mar 21, 2000 at 11:12:14AM +0100, Wolfgang Strobl wrote:
> On 20 Mar 00, 14:35  JB wrote:
> 
> > The '%s' gets replaced by a temporary file name, it definitly needs to
> > be there. I know nothing about notepad.exe, but it sounds like notepad
> > can't accept filename arguments on the command line. 
> 
> It can, since ca. 1984. :-)
> 
> >I can't verify
> > this however. I know people are using ZopeEDIT in Win?? so it must be
> > something with notepad.
> > 
> > cheers
> > jb
> > 
> > Paul Browning wrote:
> > > 
> > > OK, so it's not my favourite editor but I thought I'd
> > > try Notepad with ZopeEDIT for the hell of it.
> > > 
> > > Can anyone tell me what I should set EDITOR_CMD to?
> > > 
> > > 'C:\WINNT\system32\notepad.exe' and 'C:\WINNT\system32\notepad.exe
> > > %s' don't do the job. (What's the %s for anyway?)
> 
> Try %1, instead.  %1, %2 etc stand for a commands first, second 
> ... positional parameter in the MSDOS/Windows/Windows NT 
> universe.

*Sigh* Did anyone read my reply to the original message?? A backslash has
special meaning in python! And positional parameters have nothing to do with
python either!

In python (as in many programming languages based on C) \n means newline. Just
fire up a python interpreter:

  >> repr('C:\WINNT\system32\notepad.exe %s')
  'C:\\WINNT\\system32\012otepad.exe %s'

\012 is the octal representation for newline. Note that, as \W and \s are
meaningless, they are interpreted as if you used a double backslash.

The solution immediatly becomes clear:

  >> repr('C:\\WINNT\\system32\\notepad.exe %s')
  'C:\\WINNT\\system32\\notepad.exe %s'
  >> repr(r'C:\WINNT\system32\notepad.exe %s')
  'C:\\WINNT\\system32\\notepad.exe %s'

ZopeEDIT uses the string to build up a command to feed to the system. It uses
the default python % operator to replace the %s (which is a C-sprintf-like
string formatting code) with the filename of the temporary file it creates.

Please, next time, use the python debugger or something to see what goes
wrong. Paul has long since gotten ZopeEDIT to work, BTW.

-- 
Martijn Pieters
| Software Engineer    mailto:mj@digicool.com
| Digital Creations  http://www.digicool.com/
| Creators of Zope       http://www.zope.org/
|   The Open Source Web Application Server
---------------------------------------------