#3958 closed defect (fixed)
thispage = hdf.getValue('wiki.page_name', '')
Reported by: | Owned by: | Christian Boos | |
---|---|---|---|
Priority: | highest | Milestone: | 0.11 |
Component: | wiki system | Version: | devel |
Severity: | normal | Keywords: | |
Cc: | ilias@… | Branch: | |
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description
The AutoNav plugin is broken with latest svn head. This is because hdf.getValue('wiki.page_name', ) returns an empty string.
Grepping the trac source code, I found references to it in the wiki-macros/TracGuideToc.py file as well.
What should the plugin be calling now to get this information?
Attachments (2)
Change History (17)
comment:1 by , 18 years ago
Component: | general → wiki |
---|---|
Milestone: | → 0.11 |
Owner: | changed from | to
comment:3 by , 18 years ago
Well, I don't know about the AutoNav plugin: if it's the "old style" macro, I guess you can't fix it. If it's an IWikiMacroProvider
plugin, then the workaround would be to use req.path_info
, and strip the /wiki/
prefix if it's there to get the page name (if it's not there, then you have WikiStart
, assuming you're wanting to use that macro only in Wiki pages).
(and btw. I suggest that we drop support for the pre-0.9 style of macros in Trac 0.11)
comment:4 by , 18 years ago
Priority: | normal → highest |
---|
This is really important for 0.11. And yeah, we should drop old-style macros… they're pretty much useless when the HDF isn't available anymore anyway.
comment:5 by , 18 years ago
It would be great if something like the AutoNav plugin was included in Trac. I really need that functionality. I'm using AutoNav3 plugin from your site:
http://trac.edgewall.org/wiki/MacroBazaar
It would be really cool if you just made a mock hdf object available so that all of the old code would just magically work instead of breaking everyone's wiki's when they upgrade.
by , 18 years ago
Attachment: | TracGuideTocPlugin.tar.bz2 added |
---|
TracGuideToc (new-style plugin, remove old macro first)
follow-up: 8 comment:7 by , 18 years ago
Could you rather use .tar.gz or .zip attachments next time? Thanks!
comment:8 by , 18 years ago
Replying to cboos:
Could you rather use .tar.gz or .zip attachments next time? Thanks!
Huh? What's wrong with .tar.bz2? It's a pretty standard format and gives better compression than GZip.
comment:9 by , 18 years ago
Tried installing the AutoNav macro from the above .bz2 and it doesn't seem to work…
2006-10-24 15:21:10,556 Trac[formatter] DEBUG: Executing Wiki macro AutoNav by provider <trac.wiki.macros.UserMacroProvider object at 0xb6a3cdac> 2006-10-24 15:21:10,556 Trac[macros] ERROR: Wiki macro AutoNav failed ('module' object has no attribute 'execute') Traceback (most recent call last):
File "/usr/lib/python2.4/site-packages/trac/wiki/macros.py", line 456, in render_macro
return module.execute(req and req.hdf, content, self.env)
AttributeError: 'module' object has no attribute 'execute' 2006-10-24 15:21:10,557 Trac[formatter] ERROR: Macro AutoNav(None) failed Traceback (most recent call last):
File "/usr/lib/python2.4/site-packages/trac/wiki/formatter.py", line 443, in _macro_formatter
return macro.process(self.req, args, True)
File "/usr/lib/python2.4/site-packages/trac/wiki/formatter.py", line 115, in process
text = self.processor(req, text)
File "/usr/lib/python2.4/site-packages/trac/wiki/formatter.py", line 103, in _macro_processor
return self.macro_provider.render_macro(req, self.name, text)
File "/usr/lib/python2.4/site-packages/trac/wiki/macros.py", line 456, in render_macro
return module.execute(req and req.hdf, content, self.env)
AttributeError: 'module' object has no attribute 'execute'
follow-up: 11 comment:10 by , 18 years ago
Status: | new → assigned |
---|
The macros attached by stromnov@… are plugins, so you shouldn't copy them to your wiki-macros, where only "old-style" (i.e. pre-0.9) macros are expected. Instead, you should either install them as plugins (see TracPlugins) or simply put the main file in the plugins folder (aka. single file plugins).
And about the .tar.bz2: I'm mainly working on Windows, where that format is not very common and not well supported (e.g. those files can't be opened by the latest Winzip).
I've started to adapt the contributed TracTocGuide.py a bit further, but I'm not sure yet where to put it… in trac/wiki/macros.py, in contrib?
Suggestions welcomed.
comment:11 by , 18 years ago
Replying to cboos:
I'm not sure yet where to put it… in trac/wiki/macros.py, in contrib?
While it is used in preinstalled Trac pages, it is preferably to keep it in trac/wiki/macros.py
comment:12 by , 18 years ago
Well, perhaps, but at the same time I have the feeling that this macro would be best kept in a file of its own. That's also what I said for the Image macro, some times ago. I wonder if the idea of a trac/wiki/macros folder would be better accepted now ;)
comment:13 by , 18 years ago
WikiContext implements this.
We should also update the documentation:
- for 0.10 stating that the old-style macros is being phased out and focusing on the documentation for IWikiMacroProvider and WikiMacroBase.
- for 0.11, documenting the interface change in the
render_macro
method, which will take aContext
instead of aRequest
.
comment:14 by , 18 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Fixed in r4451. The documentation in this Wiki has been updated as well.
I'll update the AutoNav macro shortly and put it in the MacroBazaar as an example.
The next wiki refactoring will introduce a "context" information (stacked context, even).
The interface is not yet defined, but it should be something like:
formatter.context
(type, detail)
. We could also think about having the "name" of the text (is it the "page" or the "comment"?) and possibly the module used.There's already a lot of documented situations where knowing the current context makes sense. There are a few more exotic situations where it's even necessary to know if we are "embedded" in some wider context.