#1892 closed enhancement (fixed)
[PATCH] 0.11 Compatibility Patch
Reported by: | Owned by: | Ryan J Ollos | |
---|---|---|---|
Priority: | high | Component: | ProjectMenuPlugin |
Severity: | critical | Keywords: | |
Cc: | alvaro.iradier@…, Noah Kantrowitz, Ryan J Ollos | Trac Release: | 0.11 |
Description
Hi,
projectmenu plugin doesn't work in Trac 0.11. Calling add_script in get_navigation_items enters an infinite recursive call.
Attached is a patch to fix this, and make it work in Trac 0.11
Attachments (4)
Change History (29)
Changed 17 years ago by
Attachment: | web_ui.diff added |
---|
Changed 17 years ago by
Attachment: | web_ui.py.diff added |
---|
Updated patch (includes additional required modifcations)
comment:1 Changed 17 years ago by
Cc: | alvaro.iradier@… airadier@… added; anonymous removed |
---|
Which web_ui.py should this be applied to?
If we run a:
find . | grep web_ui.py
we receive several instances ...
./trac/search/web_ui.pyc ./trac/search/web_ui.py ./trac/prefs/web_ui.pyc ./trac/prefs/web_ui.py ./trac/admin/web_ui.pyc ./trac/admin/web_ui.py ./trac/timeline/web_ui.pyc ./trac/timeline/web_ui.py ./trac/ticket/web_ui.pyc ./trac/ticket/web_ui.py ./trac/wiki/web_ui.pyc ./trac/wiki/web_ui.py ./patches_and_diffs/projectmenuplugin/web_ui.py.diff
comment:2 Changed 17 years ago by
Sorry, it applies to the web_ui.py file in the ProjectMenu plugin, not in the trac core.
comment:3 Changed 17 years ago by
FYI: I ran:
patch -p0 < web_ui.py.diff
then received the following results:
patching file web_ui.py Hunk #1 succeeded at 1 with fuzz 2. Hunk #2 FAILED at 10. Hunk #3 succeeded at 27 (offset -1 lines). Hunk #4 succeeded at 35 (offset -1 lines). 1 out of 4 hunks FAILED -- saving rejects to file web_ui.py.rej
The reject file web_ui.py.rej looks as follows:
*************** *** 9,16 **** class ProjectMenuModule(Component): ! implements(INavigationContributor, ITemplateProvider) # INavigationProvider methods def get_navigation_items(self, req): projects = [] --- 10,25 ---- class ProjectMenuModule(Component): ! implements(INavigationContributor, ITemplateProvider, IRequestFilter) + # IRequestFilter methods + def pre_process_request(self, req, handler): + add_script(req, 'projectmenu/projectmenu.js') + return handler + + def post_process_request(self, req, template, content_type): + return(template, content_type) + # INavigationProvider methods def get_navigation_items(self, req): projects = []
Even with the rejected hunk I still tried to install it, and it works! Is this missing code important?...
comment:4 Changed 17 years ago by
OK I was wrong, it doesn't work ...
The menu itself shows up, but clicking on a project doesn't do anything
comment:5 Changed 17 years ago by
Cc: | Noah Kantrowitz added |
---|
Well! Clearly the IRequestFilter was required :-)
Although that hunk failed, I manually changed the line:
implements(INavigationContributor, ITemplateProvider)
to
implements(INavigationContributor, ITemplateProvider, IRequestFilter)
and immediately following I added the lines:
# IRequestFilter methods def pre_process_request(self, req, handler): add_script(req, 'projectmenu/projectmenu.js') return handler def post_process_request(self, req, template, content_type): return(template, content_type)
Then ran:
sudo easy_install -U .
And it works! Most excellent.
comment:6 Changed 17 years ago by
Alright so after more analysis unfortunately this doesn't work. Something about the patched code there causes a massive slowdown in trac.
Pages would sometimes take upwards of 20 seconds to load instead of the usual 2 seconds (at most). Running a dual core server caused 100% CPU load on both processors for EVERY page refresh (i.e. every time it called the ProjectMenuPlugin code since it shows on every page ... )
Any ideas coderanger/airadier?
comment:7 Changed 17 years ago by
In the call to open_environment
, add the argument use_cache=True
. Otherwise it loads every environment off disk each time and will be, as you said, insanely slow.
comment:8 Changed 17 years ago by
Great, I didn't know use_cache parameter was possible. I also noticed a slow down when the number of existing projects increased. Was this caused by my patch, or was it in the original plugin?
Changed 17 years ago by
Attachment: | web_ui.py.2.diff added |
---|
Updated web_ui.py.diff for 0.11 & environment caching
comment:9 Changed 17 years ago by
So I've just added an updated diff file: web_ui.py.2.diff
This contains the changes as per the previous diffs, as well as the addition to use the cache when calling the environments.
airradier, do you plan to incorporate this patch into the trunk to fully support 0.11?
comment:10 Changed 17 years ago by
I'm not the mantainer, I just made the patches for 0.11. I guess coderanger should merge them if he thinks they are right.
comment:11 follow-up: 12 Changed 16 years ago by
All of the *.diff files are empty ... where have the patches gone?
comment:12 Changed 16 years ago by
Replying to wbranderson@gmail.com:
All of the *.diff files are empty ... where have the patches gone?
Use the "Original Format" link at the bottom of the page. It's an old bug in Trac that can't render some diffs.
comment:13 follow-up: 14 Changed 16 years ago by
After applying the diff and restarting trac, I received the following error:
Traceback (most recent call last): File "c:\python24\lib\site-packages\Trac-0.11rc1-py2.4.egg\trac\web\api.py", line 339, in send_error 'text/html') File "c:\python24\lib\site-packages\Trac-0.11rc1-py2.4.egg\trac\web\chrome.py", line 684, in render_template data = self.populate_data(req, data) File "c:\python24\lib\site-packages\Trac-0.11rc1-py2.4.egg\trac\web\chrome.py", line 592, in populate_data d['chrome'].update(req.chrome) File "c:\python24\lib\site-packages\Trac-0.11rc1-py2.4.egg\trac\web\api.py", line 168, in __getattr__ value = self.callbacks[name](self) File "c:\python24\lib\site-packages\Trac-0.11rc1-py2.4.egg\trac\web\chrome.py", line 460, in prepare_request for category, name, text in contributor.get_navigation_items(req): File "build\bdist.win32\egg\projectmenu\web_ui.py", line 29, in get_navigation_items File "c:\python24\lib\site-packages\Trac-0.11rc1-py2.4.egg\trac\env.py", line 561, in open_environment env = env_cache.setdefault(env_path, open_environment(env_path)) File "c:\python24\lib\site-packages\Trac-0.11rc1-py2.4.egg\trac\env.py", line 565, in open_environment env = Environment(env_path) File "c:\python24\lib\site-packages\Trac-0.11rc1-py2.4.egg\trac\env.py", line 190, in __init__ self.verify() File "c:\python24\lib\site-packages\Trac-0.11rc1-py2.4.egg\trac\env.py", line 243, in verify fd = open(os.path.join(self.path, 'VERSION'), 'r') IOError: [Errno 2] No such file or directory: 'X:\\Path\\To\\Trac\\Installation\\trac.ini\\VERSION'
Any thoughts? I have Multiple environments installed at 'X:
Path
To
Trac
Installation
', but the folder itself is not an environment. Do I need to have a parent project? And if so, how to I set this up?
comment:14 follow-up: 15 Changed 16 years ago by
Your (wbranderson@…) error is caused by existing files in the directory where your multiple Trac project subdirs are located.
It can be easily fixed by the following patch:
for project in os.listdir(search_path): - if project != this_project: + if project != this_project and os.path.isdir(os.path.join(search_path, project)): proj_env = open_environment(os.path.join(search_path, project),use_cache=True)
comment:15 Changed 16 years ago by
Yea, I fixed the problem shortly after posting the ticket. All is well. Thanks for the help.
Replying to kmx:
Your (wbranderson@…) error is caused by existing files in the directory where your multiple Trac project subdirs are located.
It can be easily fixed by the following patch:
for project in os.listdir(search_path): - if project != this_project: + if project != this_project and os.path.isdir(os.path.join(search_path, project)): proj_env = open_environment(os.path.join(search_path, project),use_cache=True)
Changed 16 years ago by
comment:16 follow-up: 17 Changed 16 years ago by
Is there an intent to create a 0.11 compatible install anytime soon ?
comment:17 Changed 16 years ago by
Replying to anonymous:
Is there an intent to create a 0.11 compatible install anytime soon ?
... apparently not(?) ...too bad!
comment:18 Changed 15 years ago by
Cc: | Ryan J Ollos added |
---|
comment:19 Changed 15 years ago by
Summary: | 0.11 Compatibility Patch → [PATCH] 0.11 Compatibility Patch |
---|
comment:20 Changed 15 years ago by
Cc: | alvaro.iradier@… added; alvaro.iradier@… airadier@… removed |
---|
comment:21 Changed 13 years ago by
trac-0.12.2
- patch web_ui.py.2.diff
- patch comment:14 and modify like below
if project != this_project and os.path.isdir(os.path.join(search_path, project)) and project[0] != '.':"
- e.g. ".egg-cache"
comment:22 Changed 13 years ago by
After applying web_ui.py.2.diff to trac-0.12.2, I received the following warning:
Trac[chrome] WARNING: Error with navigation contributor ProjectMenuModule
comment:23 Changed 10 years ago by
Owner: | changed from Noah Kantrowitz to Ryan J Ollos |
---|---|
Status: | new → assigned |
Patch for web_ui.py, 0.11 Compatibility