I am trying to apply the theme "explorer" Ver.2.4 in moinmoin Ver.1.9. As soon as I click on "save" I get an error in explorer.py:

AttributeError: 'AllContext' object has no attribute 'cookie' on Line 158 self.cookie = request.cookie

I figured out by searching in the source code, that it could be "cookies" instead of "cookie" - that worked OK.

Next I got an error:

AttributeError: 'AllContext' object has no attribute 'http_host' in Line 166 self.site_mode = getattr(cfg, '%s_site_mode' % module_name, not request.http_host.startswith('localhost'))

Here I did not found any comparable examples in the moin source code. What can I do to fix the problem?

2009-12-16 Regards, RudolfReuter


Bug fix for moin version 1.9 (9 patches, mostly because of cookie reprogramming, werkzeug) In principle it works, but it may still contain bugs, so please beware!

Experts should have a look at the code please, and correct where necessary.

The file explorer.py (version 2.4) has to be patched at 9 locations. The information was extracted mostly from MoinMoin/web/session.py and MoinMoin/support/werkzeug/wrappers.py

The static part of "explorer" has to go now to MoinMoin/web/static/htdocs/explorer.

I show first the old line with a leading about line number and a #, next line is the patch for moin v.1.9

   1 #1
   2 158 #self.cookie = request.cookie  # Moin 1.7/1.88
   3     self.cookie = request.cookies  # 2009-12-18 Moin 1.9
   4 
   5 #2
   6 166 #self.site_mode = getattr(cfg, '%s_site_mode' % module_name, not request.http_host.startswith('localhost'))
   7     self.site_mode = getattr(cfg, '%s_site_mode' % module_name, not request.host.startswith('localhost'))
   8 
   9 #3/4/5
  10 214 #self.sidebar_width = self.cookie['%s_sidebar_width' % module_name].value
  11     self.sidebar_width = self.request.cookies.get('%s_sidebar_width' % module_name) # 2009-12-18 Moin 1.9
  12     #main_height = self.cookie['%s_main_height' % module_name].value
  13     main_height = self.request.cookies.get('%s_main_height' % module_name) # 2009-12-18 Moin 1.9
  14     #page_content_height = self.cookie['%s_page_content_height' % module_name].value
  15     page_content_height = self.request.cookies.get('%s_page_content_height' % module_name) # 2009-12-18 Moin
  16 
  17 #6
  18 835 #elog = self.request.editlog
  19     elog = editlog.EditLog(self.request)  # 2009-12-18 Moin 1.9
  20 
  21 #7
  22 1163  #self.cookie = request.cookie
  23       self.cookie = request.cookies # 2009-12-18 Moin 1.9
  24 
  25 #8
  26 1174  #self.expand_subtree = self.cookie['expand_subtree'].value
  27       self.expand_subtree = self.request.cookies.get('expand_subtree') # 2009-12-18 Moin 1.9
  28       #self.cookie[self.expand_subtree] = 1
  29       self.request.set_cookie('expand_subtree', value=1)  # 2009-12-18 Moin 1.9
  30 
  31 #9
  32 1261 #self.cookie[id] = 'X'
  33      self.request.set_cookie(id, value='X')  # 2009-12-18 Moin 1.9

2009-12-18 Regards, RudolfReuter

(!) Please use diff -u old new to create a patch. -- ThomasWaldmann 2009-12-18 22:45:46

Thanks for the patch. I elaborated it somehow, to prevent breaking compatibility with old versions. The attached patch (explorer-moin1v9.patch) works for me, and it should deal with version incompatibilities in all obvious places (i.e. in places with checks for a specific Moin version). I'm sure, though, that it needs a thorough review, as I'm just an occasional hacker. -- UeliSchläpfer 2024-11-25 00:15:12

_Big_ _thanks_ for the patch! I will review the source and the changes but i have work myself into the problem. 2024-11-25 00:15:12

MoinMoin: ThemeMarket/Explorer/Bugs/Moin-1.9_Error (last edited 2011-06-25 19:03:19 by dslb-188-098-036-002)