﻿ticket	summary	type	release	owner	status	created	modified	_description	_reporter
5232	MyPagePlugin not functioning as default handler (solution included, but raises another error)	defect	0.11	dgc	new	2009-05-14T14:12:17+02:00	2010-12-04T23:08:32+01:00	"When setting the MyPagePlugin as default handler in Trac

''{{{trac.ini}}}''
{{{
 [trac]
 default_handler = MyPagePlugin
}}}

... the page begins to load and nothing happens. I only get following error in the console (using trac as daemon without apache or sth. similar):
{{{
 ----------------------------------------
 Exception happened during processing of request from ('127.0.0.1', 2924)
 Traceback (most recent call last):
   File ""C:\Python25\lib\SocketServer.py"", line 464, in process_request_thread
     self.finish_request(request, client_address)
   File ""C:\Python25\lib\SocketServer.py"", line 254, in finish_request
     self.RequestHandlerClass(request, client_address, self)
   File ""C:\Python25\lib\SocketServer.py"", line 522, in __init__
     self.handle()
   File ""C:\Python25\lib\BaseHTTPServer.py"", line 316, in handle
     self.handle_one_request()
   File ""C:\Python25\lib\site-packages\trac-0.11.4rc1-py2.5-win32.egg\trac\web\wsgi.py"", line 175, in handle_one_request
     gateway.run(self.server.application)
   File ""C:\Python25\lib\site-packages\trac-0.11.4rc1-py2.5-win32.egg\trac\web\wsgi.py"", line 98, in run
     self._write('')
   File ""C:\Python25\lib\site-packages\trac-0.11.4rc1-py2.5-win32.egg\trac\web\wsgi.py"", line 192, in _write
     assert self.headers_set, 'Response not started'
 AssertionError: Response not started
 ----------------------------------------
}}}

I didn't have any clue about python before today, but I could fix this problem by determining the default handler within the function/method ''{{{process_request(self, req)}}}'' of the {{{MyPagePlugin.py}}} file like following ({{{+}}} means added; {{{#}}} means changed):

{{{
 36	def process_request(self, req):
 37		url = self.mypage_url(req)
 ++		if self.config.get('trac', 'default_handler') == 'MyPagePlugin':
 ++			replacement_urls = ['/me', '/']
 ++		else:
 ++			replacement_urls = ['/']
 38		self.log.debug('process_request: %s' % url)
 ##		if req.path_info in replacement_urls:
 40			req.send_response(307)
 41			req.send_header('Location', url)
 42			req.end_headers()
 43			return
}}}

But now I have another problem...

Our Trac is configured to redirect the user to the login page if the permission is insufficient. In words: all anonymous access is forbidden, only authenticated users can do anything. PermRedirectPlugin is used for this.

Because of the fix I made the following page is coming up when there is no authentication cookie and the site is called:

>'''''Oops…'''''
>>'''Trac detected an internal error:'''[[BR]]
>>{{{TypeError: issubclass() arg 1 must be a class}}}
>
>There was an internal error in Trac. It is recommended that you inform your local >Trac administrator and give him all the information he needs to reproduce the issue.
>
>The action that triggered the error was:
>
>{{{GET: /}}}

----

Because I'm bloody new to Python, at this point I am at my wits' end.

The {{{tracd}}} server daemon is running on ''Windows XP Professional SP2'' if that helps."	anonymous
5178	Examples please!	defect	0.11	dgc	new	2009-05-03T23:22:26+02:00	2011-02-17T11:09:07+01:00	"This sounds great. I have my ini configured as suggested. However, I'm having some problems:

 1. the mypage option only appears when I'm logged in as an admin, not user
 1. when I click on the mypage link, I get: ""Not Found.  The requested URL /wiki/u/admin was not found on this server.""

Please provide more detail on what I could put on a mypage and what it would look like.  Perhaps you could add some screenshots.

I'm looking forward to start using this plugin.

Thanks, Ariel "	Ariel Balter
4887	[patch] MYPAGE_VIEW not registered properly, so doesn't show up in permission list	defect	0.11	dgc	assigned	2009-04-05T23:42:20+02:00	2010-12-25T20:56:07+01:00	"After putting the !TracMyPage.py file in the plugins directory and restarting apache, trac does not seem to know about the ""MYPAGE_VIEW"" permission that the plugin needs in order to show up.

Workaround if you are fine with all users seeing the nav item is below; it just removes any reliance on permissions.

This is under trac v0.11.3.

{{{
#!diff
--- /tmp/TracMyPage.py.orig     2009-03-07 06:06:08.000000000 -0500
+++ TracMyPage.py       2009-03-07 06:07:19.168416638 -0500
 -4,7 +4,6 @@
 from trac.web import IRequestHandler
 from trac.web.api import IRequestFilter
 from trac.web.chrome import INavigationContributor
-from trac.perm import IPermissionRequestor, IPermissionPolicy
 
 
 class MyPagePlugin(Component):
 -15,8 +14,7 @@
                return 'mypage'
 
        def get_navigation_items(self, req):
-               if req.perm.has_permission('MYPAGE_VIEW'):
-                       yield ('mainnav', 'mypage', html.A('My Page', href=req.href.me()))
+               yield ('mainnav', 'mypage', html.A('My Page', href=req.href.me()))
 
 
        # IRequestHandler methods
}}}"	dclark
5688	Redirect loop when defining error parameter as a slash separated path	defect	0.11	dgc	new	2009-08-20T10:09:14+02:00	2009-08-28T06:32:01+02:00	"The plug-in works fine for me if I define
{{{
error = WarnPrivatePageAccess
}}}
However, if I define
{{{
error = User/WarnPrivatePageAccess
}}}
there is a redirect on an attempt to access a protected page, however we never land on the error page because there is a redirect loop.

{{{
This webpage has a redirect loop.

The webpage at https://trac.exampl.com/wiki/User/WarnPrivatePageAccess
has resulted in too many redirects. Clearing your cookies for this site
may fix the problem. If not, it is possibly a server configuration issue
and not a problem with your computer.
}}}

The error was detected with Google Chrome 2.0.172.39 on Windows Vista x64.  I have not tried other browsers and OS's."	anonymous
6696	Links to sub pages	enhancement	0.11	dgc	new	2010-02-19T23:00:17+01:00	2012-10-27T11:42:02+02:00	"It would be nice if it was possible to catch any pages being created from the users initial ""MyPage"" and add 'u/$username/ to the link to form a nice hierarchy.

   "	anonymous
8273	Add i18n support	enhancement	0.11	dgc	new	2010-12-05T00:40:09+01:00	2010-12-05T00:40:09+01:00	"Since this plugin is contributing to Trac's main navigation, it would be nice to add optional i18n support, to make it upwards-compatible to Trac>=0.12.

Expect automatic switching between English/German/Japanese/.. label just depending on user's browser settings per client, if Trac>0.11 and Babel>=0.9.5 are detected. And by joining us at the [wiki:TracPluginTranslation Trac plugin l10n project] you would get you plugin know especially among growing number of users interested in localized Trac environments.

I've done this many times before. Just tell me, if you'd consider adding this, and I'll release patches for review and commit by you or me, as you like it. I offer be available for possible later issues and requests, i.e. when you add more translatable strings, but don't care about non-English environments or learning i18n stuff [t:wiki:CookBook/PluginL10N on your own]."	Steffen Hoffmann
