Ticket #8832 (closed defect: fixed)

Opened 2 years ago

Last modified 7 months ago

AttributeError: 'Context' object has no attribute 'has_tags'

Reported by: lucid Assigned to: rjollos
Priority: normal Component: DiscussionPlugin
Severity: normal Keywords:
Cc: Trac Release: 0.12

Description

After updating (Trac 12.2, DiscussionPlugin r9877) I get the following error when using the RecentTopics? macro:

AttributeError: 'Context' object has no attribute 'has_tags'
2011-05-25 12:32:05,846 Trac[formatter] ERROR: Macro RecentTopics(10) failed: 
Traceback (most recent call last):
  File "build\bdist.win32\egg\trac\wiki\formatter.py", line 717, in _macro_formatter
    return macro.process(args, in_paragraph=True)
  File "build\bdist.win32\egg\trac\wiki\formatter.py", line 304, in process
    text = self.processor(text)
  File "build\bdist.win32\egg\trac\wiki\formatter.py", line 291, in _macro_processor
    text)
  File "build\bdist.win32\egg\tracdiscussion\wiki.py", line 81, in expand_macro
    return self._expand_recent_topics(formatter, name, content)
  File "build\bdist.win32\egg\tracdiscussion\wiki.py", line 233, in _expand_recent_topics
    forum_name = api.get_forum(context, entry['forum'])['name']
  File "build\bdist.win32\egg\tracdiscussion\api.py", line 1622, in get_forum
    if context.has_tags:
AttributeError: 'Context' object has no attribute 'has_tags'

Attachments

Change History

05/25/11 12:54:02 changed by Blackhex

  • status changed from new to assigned.

Lastest revision is commit of unfinished work on TagPlugin? support. Use some older revision for now.

05/26/11 09:22:10 changed by lucid

Ok thanks for the information. Is there a known stable / preferred latest version? It might be a good idea to mention this on the wiki page under PluginVersions?

05/26/11 10:31:29 changed by Blackhex

Wiki page updated, thanks for provoking me to it :-).

05/26/11 11:13:32 changed by lucid

You're welcome ;) Thanks for the update

09/05/12 15:05:22 changed by sdegrande

Here is a small patch that fixes the issue, but I have no real idea if that's a smart one :

diff -r ec2c58e517b9 discussionplugin/0.11/tracdiscussion/wiki.py
--- a/discussionplugin/0.11/tracdiscussion/wiki.py	Sat Aug 11 22:09:49 2012 +0000
+++ b/discussionplugin/0.11/tracdiscussion/wiki.py	Wed Sep 05 15:02:47 2012 +0200
@@ -120,6 +120,12 @@
 
         # Get API component.
         api = self.env[DiscussionApi]
+        
+        # Get list of Trac users and availability of tags
+        context.users = api.get_users(context)
+        context.has_tags = api.env.is_component_enabled(
+          'tracdiscussion.tags.DiscussionTags')
+
 
         # Get topic by subject
         try:
@@ -175,8 +181,10 @@
         # Get API object.
         api = self.env[DiscussionApi]
 
-        # Get list of Trac users.
+        # Get list of Trac users and availability of tags
         context.users = api.get_users(context)
+        context.has_tags = api.env.is_component_enabled(
+          'tracdiscussion.tags.DiscussionTags')
 
         # Parse macro arguments.
         arguments = []

10/10/12 20:53:12 changed by rjollos

(In [12141]) Fixes #10461, Refs #8832: The components tracdiscussion.tags.DiscussionTags and tractags.api.TagSystem must be enabled in order for TagsPlugin support to be enabled. This is a workaround that will likely be improved on in #8832 as the tags module is redesigned.

(follow-up: ↓ 9 ) 10/10/12 21:21:45 changed by rjollos

  • status changed from assigned to new.
  • owner changed from Blackhex to rjollos.

The implementation of tags needs to be refactored/redesigned, but we can just fix this issue for now. Please report back if it is working after upgrading to the latest revision of the 0.11 branch.

10/10/12 21:22:44 changed by rjollos

  • status changed from new to closed.
  • resolution set to fixed.

(In [12142]) Fixes #8832: Check for existence of tags when calling the RecentTopics macro.

(in reply to: ↑ 7 ) 11/02/12 12:05:59 changed by sdegrande

Replying to rjollos:

The implementation of tags needs to be refactored/redesigned, but we can just fix this issue for now. Please report back if it is working after upgrading to the latest revision of the 0.11 branch.

Works well. Thanks.


Add/Change #8832 (AttributeError: 'Context' object has no attribute 'has_tags')




Change Properties
Action