FileAttachedEvent behaves differently when using <<Include()>>

I'm using the ParserMarket/matplotlib parser to generate images dynamically (only when the matplotlib code has changed). After the image(s) are generated, send_event(FileAttachedEvent()) is called to index the generated images. The indexing works fine when the page (say it is called MplPage) with the matplotlib code is rendered directly. I check the indexing by doing a FullSearch(), which brings back the attachments on MplPage.

If I repeat the above by including MplPage with the <<Include()>> macro within another page, the images are no longer indexed.

Steps to reproduce

  1. Create sample page SamplePage with following content

    <<Include(/subpage)>>
  2. Create /subpage where the parser is called
    {{{#!xap
    Hello world!
    }}}
  3. Goto /subpage (check if attachment test-indexing.txt has been created)
  4. Search for text-indexing.txt, should return /subpage with attachment
  5. Goto /subpage and delete test-indexing.txt (without reloading page)
  6. Goto SamplePage (includes /subpage and recreates test-indexing.txt)

  7. Search for text-indexing.txt, /subpage with attachment no longer found

Example text_x_xap.py

   1 # -*- coding: iso-8859-15 -*-
   2 """
   3     @copyright: 2008 F. Zieher
   4     @license: GNU GPL, see COPYING for details.
   5 
   6 """
   7 
   8 import os
   9 from MoinMoin.events import FileAttachedEvent, send_event
  10 from MoinMoin.action import AttachFile
  11 
  12 Dependencies = ["namespace"]
  13 
  14 # -------------------------------------------------------------------------------
  15 
  16 class Parser:
  17     """
  18         Test xapian indexing
  19     """
  20     
  21     extensions = []
  22     Dependencies = Dependencies
  23 
  24     def __init__(self, raw, request, **kw):
  25         self.raw = raw
  26         self.request = request
  27 
  28     def format(self, formatter):
  29         """ Send the text. """
  30 
  31         self.request.flush() # to identify error text
  32         self.formatter = formatter
  33         self.pagename  = formatter.page.page_name
  34         self.attach_dir=AttachFile.getAttachDir(self.request,self.pagename,create=1)
  35 
  36         fname = 'test-indexing.txt'
  37         fpath = os.path.join(self.attach_dir,fname)
  38         f = open(fpath,'w')
  39         f.write(self.raw)
  40         f.close()
  41         send_event(FileAttachedEvent(self.request, self.pagename, fname, os.path.getsize(fpath)))
  42         self.request.write('<pre>'+self.raw+'</pre>')

Component selection

Details

MoinMoin Version

1.8.2

OS and Version

WinXP or Linux (SLES10)

Python Version

2.4

Server Setup

twisted

Server Details

Language you are using the wiki in (set in the browser/UserPreferences)

Workaround

Discussion

Plan


CategoryMoinMoinBug

MoinMoin: MoinMoinBugs/1.8XapianDynamicAttachmentNotIndexedDuringInclude (last edited 2009-12-28 00:17:30 by FranzZieher)