예제 #1
0
 def register_entry(self, target, action):
     if not self._active:
         return
     container = aq_parent(target)
     if container is None:
         # The object is not yet in the content tree.
         return
     self._follow()
     listing = None
     interface = None
     for name, interface, identifier in self._interfaces:
         if interface.providedBy(target):
             listing = identifier
             interface = name
             break
     data = {
         'action': action,
         'listing': listing,
         'interface': interface,
         'container': self._get_id(container),
         'content': self._get_id(target)}
     if action != 'remove':
         order = IOrderManager(container, None)
         if order is not None:
             position = order.get_position(target) + 1
             if not position:
                 if not (IPublishable.providedBy(target) and
                         target.is_default()):
                     position = -1
         else:
             position = -1
         data['position'] = position
     self.add_entry(data)
예제 #2
0
 def get_short_title(self):
     """Get short title.
     """
     content = self.get_haunted()
     if content is not None:
         if not IPublishable.providedBy(content) or content.is_published():
             return content.get_short_title()
     return _("Ghost target is broken")
예제 #3
0
 def get_short_title(self):
     """Get short title.
     """
     content = self.get_haunted()
     if content is not None:
         if not IPublishable.providedBy(content) or content.is_published():
             return content.get_short_title()
     return _(u"Ghost target is broken")
예제 #4
0
def version_published(version, event):
    """Content have been published. Send notifications.
    """
    service = queryUtility(ISubscriptionService)
    if service is not None:
        content = version.get_silva_object()
        if IPublishable.providedBy(content):
            # first send notification for content
            service.send_notification(content)
            # now send email for potential haunting ghosts
            for haunting in IHaunted(content).getHaunting():
                service.send_notification(haunting)
예제 #5
0
 def __call__(self, content):
     if IContainer.providedBy(content):
         path = list(content.getPhysicalPath()) + [
             'index.' + self.extension]
     elif IPublishable.providedBy(content):
         path = list(aq_parent(content).getPhysicalPath()) + [
             content.getId() + '.' + self.extension]
     elif IAsset.providedBy(content):
         path = list(aq_parent(content).getPhysicalPath()) + [
             content.get_filename()]
     else:
         path = content.getPhysicalPath()
     return '/'.join(relative_path(self._origin, path))
예제 #6
0
 def __call__(self, content=None, id=None):
     if content is None:
         # XXX Need to handle case where the object
         # disappeared. This can happen in case of conflict error
         # with the invalidation code.
         content = self.get_content(id)
     elif id is None:
         id = self.get_id(content)
     previewable = content.get_previewable()
     if previewable is not None:
         icon = self.get_icon(content)
         title = cgi.escape(previewable.get_title_or_id_editable())
         author = self.format_author(previewable.get_last_author_info())
         modified = self.get_metadata(
             previewable, 'silva-extra', 'modificationtime')
         if modified is None:
             modified = u'-'
         else:
             modified = self.format_date(modified)
     else:
         icon = self.get_icon(None)
         title = '<i>{0}</i>'.format(self.rest.translate(_('Broken content')))
         author = u'-'
         modified = u'-'
     data = {
         'ifaces': content_ifaces(content),
         'id': id,
         'identifier': content.getId(),
         'path': self.rest.get_content_path(content),
         'icon': icon,
         'title': title,
         'author': author,
         'modified': modified,
         'access': self.get_access(content),
         'position': -1}
     data.update(get_content_status(content))
     if IPublishable.providedBy(content):
         data['moveable'] = not content.is_default()
     return data
예제 #7
0
 def is_public_displayable(self, item):
     """Return true if the item is displayable in public mode.
     """
     return (IPublishable.providedBy(item) and (not item.is_default())
             and item.is_published())
예제 #8
0
 def is_preview_displayable(self, item):
     """Return true if the item is displayable in preview mode.
     """
     return IPublishable.providedBy(item) and not item.is_default()
예제 #9
0
 def is_public_displayable(self, item):
     """Return true if the item is displayable in public mode.
     """
     return (IPublishable.providedBy(item) and
             (not item.is_default()) and
             item.is_published())
예제 #10
0
 def is_preview_displayable(self, item):
     """Return true if the item is displayable in preview mode.
     """
     return IPublishable.providedBy(item) and not item.is_default()
예제 #11
0
 def _is_valid(self, content):
     return (self.order_only.providedBy(content) and
             not (IPublishable.providedBy(content) and content.is_default()))
예제 #12
0
 def _is_valid(self, content):
     return (self.order_only.providedBy(content)
             and not (IPublishable.providedBy(content)
                      and content.is_default()))