ana-balica avatar ana-balica committed 25a934c

fix is_subscribed_to()

Comments (0)

Files changed (1)

 from flask import current_app as app
 from flask import g as flaskg
 from flask import session, request, url_for, render_template
+from jinja2.runtime import Undefined
 
 from MoinMoin import log
 logging = log.getLogger(__name__)
         :returns: if user is subscribed to the item
         """
         from MoinMoin.items import NonExistent
-        if not self.valid or isinstance(item, NonExistent):
+        if not self.valid or isinstance(item, (NonExistent, Undefined)):
             return False
 
         meta = item.meta
         item_namespace = meta[NAMESPACE]
-        subscriptions = {"{0}:{1}".format(ITEMID, meta[ITEMID])}
+        subscriptions = set()
+        itemid = meta.get(ITEMID)
+        if itemid is not None:
+            subscriptions.update(["{0}:{1}".format(ITEMID, itemid)])
         subscriptions.update("{0}:{1}:{2}".format(NAME, item_namespace, name)
-                             for name in meta[NAME])
+                             for name in meta.get(NAME, []))
         subscriptions.update("{0}:{1}:{2}".format(TAGS, item_namespace, tag)
-                             for tag in meta[TAGS])
+                             for tag in meta.get(TAGS, []))
         if subscriptions & set(self.subscriptions):
             return True
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.