Attachment 'template.patch'

Download

   1 * looking for arch@arch.thinkmo.de--2003-archives/moin--main--1.3--patch-665 to compare with
   2 * comparing to arch@arch.thinkmo.de--2003-archives/moin--main--1.3--patch-665
   3 M  MoinMoin/PageEditor.py
   4 
   5 * modified files
   6 
   7 --- orig/MoinMoin/PageEditor.py
   8 +++ mod/MoinMoin/PageEditor.py
   9 @@ -285,22 +285,35 @@
  10          
  11          self.request.write(self.request.formatter.startContent("content"))
  12          
  13 -        # get the text body for the editor field
  14 -        if form.has_key('template'):
  15 -            # "template" parameter contains the name of the template page
  16 -            template_page = wikiutil.unquoteWikiname(form['template'][0])
  17 +        # Get the text body for the editor field.
  18 +
  19 +        # TODO: what about deleted pages? show the text of the last
  20 +        # revision or use the template?
  21 +
  22 +        raw_body = ''
  23 +        if self.exists():
  24 +            # If the page exists, we get the text from the page.
  25 +
  26 +            # TODO: maybe warn if template argument was ignored becuase
  27 +            # the page exists?
  28 +            
  29 +            raw_body = self.get_raw_body()
  30 +        elif form.has_key('template'):
  31 +            # If the page does not exists, we try to get the content
  32 +            # from the template parameter.
  33 +            template_page = form['template'][0]
  34              if self.request.user.may.read(template_page):
  35                  raw_body = Page(self.request, template_page).get_raw_body()
  36                  if raw_body:
  37 -                    self.request.write(_("[Content of new page loaded from %s]") % (template_page,), '<br>')
  38 +                    self.request.write(_("[Content of new page loaded from %s]") %
  39 +                                       (template_page,), '<br>')
  40                  else:
  41 -                    self.request.write(_("[Template %s not found]") % (template_page,), '<br>')
  42 +                    self.request.write(_("[Template %s not found]") %
  43 +                                       (template_page,), '<br>')
  44              else:
  45 -                raw_body = ''
  46 -                self.request.write(_("[You may not read %s]") % (template_page,), '<br>')
  47 -        else:
  48 -            raw_body = self.get_raw_body()
  49 -
  50 +                self.request.write(_("[You may not read %s]") %
  51 +                                   (template_page,), '<br>')
  52 +        
  53          # send text above text area
  54          template_param = ''
  55          if form.has_key('template'):

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2005-03-13 21:21:02, 2.4 KB) [[attachment:template.patch]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.