Attachment 'xslt.py.diff'

Download

   1 Index: xslt.py
   2 ===================================================================
   3 RCS file: /moin/Lib/site-packages/MoinMoin/parser/xslt.py,v
   4 retrieving revision 1.1
   5 diff -u -r1.1 xslt.py
   6 --- xslt.py	1 Feb 2005 07:54:26 -0000	1.1
   7 +++ xslt.py	2 Mar 2005 13:02:30 -0000
   8 @@ -2,7 +2,7 @@
   9  """
  10      MoinMoin - XML Parser
  11  
  12 -    This code works with 4Suite 1.0a1 or higher only!
  13 +    This code works with 4Suite 1.0a1 (up to & including 4Suite 1.0a4)
  14  
  15      @copyright: 2001, 2003 by Jürgen Hermann <jh@web.de>
  16      @license: GNU GPL, see COPYING for details.
  17 @@ -21,7 +21,7 @@
  18      Dependencies = Dependencies # copy dependencies
  19  
  20      def __init__(self, raw, request, **kw):
  21 -        self.raw = raw
  22 +        self.raw = raw.encode(config.charset) # we need a string, not unicode obj
  23          self.request = request
  24          self.form = request.form
  25          self._ = request.getText
  26 @@ -66,16 +66,33 @@
  27              try:
  28                  base_uri = u'wiki://Self/'
  29  
  30 -                # patch 4Suite 1.0a1
  31 -                if ft_version == "1.0a":
  32 -                    class MoinResolver(Uri.SchemeRegistryResolver):
  33 +                # patch broken 4Suite 1.0a1 (announces as "1.0a")
  34 +                # 1.0a3 ("1.0a3") is broken, too
  35 +                # thus, I assume 1.0a2 is also broken and announces either as "1.0a" or "1.0a2", hopefully
  36 +                if ft_version not in ["1.0a", "1.0a2", "1.0a3", "1.0a4",]: # you can add more broken versions here
  37 +                    MoinResolver = Uri.SchemeRegistryResolver
  38 +                else:
  39 +                    if ft_version == "1.0a4":  # 1.0a4 changes location of SchemeRegistryResolver
  40 +                        from Ft.Lib import Resolvers
  41 +                        SchemeRegistryResolverPATH = Resolvers.SchemeRegistryResolver
  42 +                    else:
  43 +                        SchemeRegistryResolverPATH = Uri.SchemeRegistryResolver
  44 +
  45 +                    class MoinResolver(SchemeRegistryResolverPATH):
  46                          def normalize(self, uri, base):
  47                              from Ft.Lib import Uri
  48  
  49 -                            scheme = Uri._getScheme(uri)
  50 +                            
  51 +                            if ft_version == "1.0a4":
  52 +                                GetSchemeFunc = Uri.GetScheme
  53 +                            else:
  54 +                                GetSchemeFunc = Uri._getScheme
  55 +                            
  56 +                            scheme = GetSchemeFunc(uri)
  57 +                            
  58                              if not scheme:
  59                                  if base:
  60 -                                    scheme = Uri._getScheme(base)
  61 +                                    scheme = GetSchemeFunc(base)
  62                                  if not scheme:
  63                                      return Uri.BaseUriResolver.normalize(self, uri, base)
  64                                  else:
  65 @@ -83,16 +100,15 @@
  66                                      if not uri:
  67                                          return base
  68                              return uri
  69 -                else:
  70 -                    MoinResolver = Uri.SchemeRegistryResolver
  71  
  72                  wiki_resolver = MoinResolver()
  73  
  74 -                def _resolve_page(uri, base=None, Uri=Uri, base_uri=base_uri, resolver=wiki_resolver):
  75 +                def _resolve_page(uri, base=None, Uri=Uri, base_uri=base_uri, resolver=wiki_resolver, request=self.request):
  76                      """ Check whether uri is a valid pagename.
  77                      """
  78                      if uri.startswith(base_uri):
  79 -                        page = Page.Page(uri[len(base_uri):].encode(config.charset))
  80 +                        pagename = uri[len(base_uri):]
  81 +                        page = Page.Page(request, pagename)
  82                          if page.exists():
  83                              return StringIO.StringIO(page.get_raw_body())
  84                          else:
  85 @@ -106,10 +122,8 @@
  86  
  87  
  88                  out_file = StringIO.StringIO()
  89 -                input_factory = InputSource.InputSourceFactory(
  90 -                    resolver=wiki_resolver
  91 -                )
  92 -                page_uri = u"%s%s" % (base_uri, unicode(formatter.page.page_name, config.charset))
  93 +                input_factory = InputSource.InputSourceFactory(resolver=wiki_resolver)
  94 +                page_uri = u"%s%s" % (base_uri, formatter.page.page_name)
  95  
  96                  processor.run(
  97                      input_factory.fromString(self.raw, uri=page_uri),

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-02 13:03:50, 4.5 KB) [[attachment:xslt.py.diff]]
 All files | Selected Files: delete move to page copy to page

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