Added checks
authorThierry Florac <thierry.florac@onf.fr>
Mon, 09 Jul 2018 11:12:17 +0200
changeset 806 9a308106275c
parent 805 c477732d8d62
child 807 cf45aeb4dd61
Added checks
src/pyams_content/shared/common/skin/opengraph.py
--- a/src/pyams_content/shared/common/skin/opengraph.py	Fri Jul 06 18:05:59 2018 +0200
+++ b/src/pyams_content/shared/common/skin/opengraph.py	Mon Jul 09 11:12:17 2018 +0200
@@ -53,16 +53,20 @@
         yield PropertyMeta('og:description', i18n.query_attribute('description', lang=lang, request=request) or '')
         yield PropertyMeta('og:type', 'article')
         # workflow informations
-        yield PropertyMeta('article:modified_time', IZopeDublinCore(context).modified.isoformat())
-        pub_info = IWorkflowPublicationInfo(context)
-        if pub_info.first_publication_date:
-            yield PropertyMeta('article:published_time', pub_info.first_publication_date.isoformat())
-        if pub_info.publication_expiration_date:
-            yield PropertyMeta('article:expiration_time', pub_info.publication_expiration_date.isoformat())
+        dc = IZopeDublinCore(context, None)
+        if (dc is not None) and dc.modified:
+            yield PropertyMeta('article:modified_time', dc.modified.isoformat())
+        pub_info = IWorkflowPublicationInfo(context, None)
+        if pub_info is not None:
+            if pub_info.first_publication_date:
+                yield PropertyMeta('article:published_time', pub_info.first_publication_date.isoformat())
+            if pub_info.publication_expiration_date:
+                yield PropertyMeta('article:expiration_time', pub_info.publication_expiration_date.isoformat())
         # tags
-        tags = ITagsInfo(context)
-        for tag in tags.tags or ():
-            yield PropertyMeta('article:tag', tag.label)
+        tags = ITagsInfo(context, None)
+        if tags is not None:
+            for tag in tags.tags or ():
+                yield PropertyMeta('article:tag', tag.label)
         # URL and site name
         yield PropertyMeta('og:url', canonical_url(context, request))
         configuration = IConfiguration(request.root)