Edgewall Software
Modify

Opened 11 years ago

Closed 11 years ago

Last modified 8 years ago

#3958 closed defect (fixed)

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

Reported by: jon@… Owned by: Christian Boos
Priority: highest Milestone: 0.11
Component: wiki system Version: devel
Severity: normal Keywords:
Cc: ilias@…
Release Notes:
API 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)

AutoNavPlugin.tar.bz2 (1.5 KB ) - added by stromnov@… 11 years ago.
AutoNav (new-style plugin)
TracGuideTocPlugin.tar.bz2 (1.3 KB ) - added by stromnov@… 11 years ago.
TracGuideToc (new-style plugin, remove old macro first)

Download all attachments as: .zip

Change History (17)

comment:1 Changed 11 years ago by Christian Boos

Component: generalwiki
Milestone: 0.11
Owner: changed from Jonas Borgström to Christian Boos

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.

comment:2 Changed 11 years ago by anonymous

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

comment:3 Changed 11 years ago by Christian Boos

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 Changed 11 years ago by Christopher Lenz

Priority: normalhighest

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 Changed 11 years 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 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.

Changed 11 years ago by stromnov@…

Attachment: AutoNavPlugin.tar.bz2 added

AutoNav (new-style plugin)

Changed 11 years ago by stromnov@…

Attachment: TracGuideTocPlugin.tar.bz2 added

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

comment:6 Changed 11 years ago by stromnov@…

Reimplemented TracGuideToc and AutoNav:

comment:7 Changed 11 years ago by Christian Boos

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

comment:8 in reply to:  7 Changed 11 years ago by Matthew Good

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 Changed 11 years 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'

comment:10 Changed 11 years ago by Christian Boos

Status: newassigned

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 in reply to:  10 Changed 11 years 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

comment:12 Changed 11 years ago by Christian Boos

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 Changed 11 years ago by Christian Boos

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.

comment:14 Changed 11 years ago by Christian Boos

Resolution: fixed
Status: assignedclosed

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.

comment:16 Changed 11 years ago by ilias@…

Cc: ilias@… added

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Christian Boos.
The resolution will be deleted.
to The owner will be changed from Christian Boos to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .

 
Note: See TracTickets for help on using tickets.