Edgewall Software

Ticket #3958 (closed defect: fixed)

Opened 21 months ago

Last modified 19 months ago

thispage = hdf.getValue('wiki.page_name', '')

Reported by: jon@… Owned by: cboos
Priority: highest Milestone: 0.11
Component: wiki system Version: devel
Severity: normal Keywords:
Cc: ilias@…

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

AutoNavPlugin.tar.bz2 (1.5 kB) - added by stromnov@… 21 months ago.
AutoNav? (new-style plugin)
TracGuideTocPlugin.tar.bz2 (1.3 kB) - added by stromnov@… 21 months ago.
TracGuideToc (new-style plugin, remove old macro first)

Change History

  Changed 21 months ago by cboos

  • owner changed from jonas to cboos
  • component changed from general to wiki
  • milestone set to 0.11

What should the plugin be calling now to get this information?

The next wiki refactoring will introduce a "context" information (stacked context, even).

The interface is not yet defined, but it should be something like:

  • obtain it from: formatter.context
  • this will be a stack of "context" descriptors
  • each "context" will at least identify the main resource to which the text being formatted belong (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.

  Changed 21 months ago by anonymous

Will you also tell me what I can call right now to fix the plugin?

  Changed 21 months ago by cboos

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)

  Changed 21 months ago by cmlenz

  • priority changed from normal to 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.

  Changed 21 months ago by anonymous

It would be great if something like the AutoNav? plugin was included in Trac. I really need that functionality. I'm using AutoNav?3 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.

Changed 21 months ago by stromnov@…

AutoNav? (new-style plugin)

Changed 21 months ago by stromnov@…

TracGuideToc (new-style plugin, remove old macro first)

  Changed 21 months ago by stromnov@…

Reimplemented TracGuideToc and AutoNav:

follow-up: ↓ 8   Changed 21 months ago by cboos

Could you rather use .tar.gz or .zip attachments next time? Thanks!

in reply to: ↑ 7   Changed 21 months ago by mgood

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.

  Changed 21 months ago by jon@…

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   Changed 21 months ago by cboos

  • status changed from new to 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.

in reply to: ↑ 10   Changed 21 months ago by Andrew Stromnov <stromnov@…>

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

  Changed 21 months ago by cboos

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 ;)

  Changed 20 months ago by cboos

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 a Context instead of a Request.

  Changed 19 months ago by cboos

  • status changed from assigned to closed
  • resolution set to fixed

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.

  Changed 19 months ago by eblot

I guess there would be at least a cross-reference to add with th:wiki:MacroMigrationTutorial about macro formats in order to make things easier for macro developers.

Maybe this page should be deprecated on TH to avoid confusion?

  Changed 19 months ago by ilias@…

  • cc ilias@… added

Add/Change #3958 (thispage = hdf.getValue('wiki.page_name', ''))

Author



Change Properties
<Author field>
Action
as closed
Next status will be 'reopened'
 
Note: See TracTickets for help on using tickets.