Anonymous avatar Anonymous committed bd85b28

fixed exception when object to be edited has no get_website()

Comments (0)

Files changed (1)

semanticeditor/cms_plugins.py

         
             # if not, we can find the object it belongs to via placeholder._get_attached_model()
         
-            # all Arkestra models with placeholders will have a get_website() method - what about
-            # other models, that don't? For now, that's someone else's problem
+            # all Arkestra models with placeholders will (should) have a get_website() method
+            # for other models, that don't, we just do without
         
-            page = obj.page or model.objects.get(**{field: obj.placeholder.id}).get_website()
-        
+            try:
+                page = obj.page or model.objects.get(**{field: obj.placeholder.id}).get_website()
+            except AttributeError:
+                import warnings
+                warnings.warn("Couldn't work out get_website() for this item, which will result in problems with class list")
+
         plugins = plugin_pool.get_text_enabled_plugins(self.placeholder, page)
         form = self.get_form_class(request, plugins, page)
         kwargs['form'] = form # override standard form
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.