I just wrote a quick macro to display the LDAP attributes available from the 
Request object (see below).

Running this shows that, at least on my setup, I get both `AUTHENTICATE_MAIL` 
and `AUTHORIZE_MAIL` set with my email, I am not sure where the latter comes 
from.

Also, [1] states that `formatter.req` is "(to be deprecated)" but does not say 
how else to get at the data?  This is my biggest gripe with python code is that 
it can be difficult to work out how to get to the data I want.

[1] 
http://trac.edgewall.org/wiki/TracDev/PluginDevelopment/ExtensionPoints/trac.wiki.api.IWikiMacroProvider
 

Cheers,

~ Mark C

{{{
# -*- coding: utf-8 -*-
#
# With help from 
https://code.google.com/p/modwsgi/wiki/DebuggingTechniques#Displaying_Request_Environment
"""Trac Macro to list a session's WSGI environment."""

from trac.core import *
from trac.wiki.formatter import format_to_html
from trac.wiki.macros import WikiMacroBase

class WsgiEnvMacro(WikiMacroBase):
    """Produces a table of Key: Value pairs from the WSGI request environment
    variables.

    Usage:
    {{{
    [[WsgiEnv]]
    }}}
    """
    def expand_macro(self, formatter, name, content):
        dt = "||'''Attribute'''||'''Value'''||\n"
        # the current Request is available as formatter.req
        wenv = formatter.req.environ
        keys = wenv.keys()
        keys.sort()
        for k in keys:
            dt += "|| `%s`  || %s  ||\n" % (str(k), str(wenv[k]))

        content = format_to_html(self.env, formatter.context, dt)
        content = '<div class="component-list">%s</div>' % content
        return content
}}}

-- 
You received this message because you are subscribed to the Google Groups "Trac 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/trac-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to