def readable_ogds_user(item, user): if not isinstance(user, unicode): if user is not None: user = user.decode('utf-8') else: user = '' if IPropertiedUser.providedBy(user) or IMemberData.providedBy(user): user = user.getId() info = getUtility(IContactInformation) if info.is_user(user) or info.is_contact(user) or info.is_inbox(user): return info.describe(user) else: return user
def author_cache_key(m, i, author): """Cache key that discriminates on the user ID of the provided user (Plone user or string), and the hostname. The hostname is required because this cache key is used to cache generated URLs, which are dependent on the hostname that is used to access the system (might be localhost + SSH tunnel). """ hostname = get_hostname(getRequest()) if IPropertiedUser.providedBy(author) or IMemberData.providedBy(author): userid = author.getId() else: userid = author return (userid, hostname)
def readable_author(author): """Helper method which returns the author description, instead of the userid""" if not isinstance(author, unicode): if author is not None: author = author.decode('utf-8') else: return author if IPropertiedUser.providedBy(author) or IMemberData.providedBy(author): author = author.getId() info = getUtility(IContactInformation) if info.is_user(author) or info.is_contact(author) \ or info.is_inbox(author): return info.describe(author) else: return author
def readable_ogds_author(item, author): if getattr(item, 'portal_type', None) == 'ftw.mail.mail': if getattr(item, 'msg', None): # Object author = get_header(item.msg, 'From') else: # Brain author = item.document_author if not isinstance(author, unicode): if author is not None: author = author.decode('utf-8') else: author = '' if IPropertiedUser.providedBy(author) or IMemberData.providedBy(author): author = author.getId() info = getUtility(IContactInformation) if info.is_user(author) or info.is_contact( author) or info.is_inbox(author): return info.describe(author) else: return author
def readable_ogds_author(item, author): if getattr(item, 'portal_type', None) == 'ftw.mail.mail': if getattr(item, 'msg', None): # Object author = get_header(item.msg, 'From') else: # Brain author = item.document_author if not isinstance(author, unicode): if author is not None: author = author.decode('utf-8') else: author = '' if IPropertiedUser.providedBy(author) or IMemberData.providedBy(author): author = author.getId() info = getUtility(IContactInformation) if info.is_user(author) or info.is_contact(author) or info.is_inbox( author): return info.describe(author) else: return author
def is_plone_user(self, user): return IPropertiedUser.providedBy(user) or IMemberData.providedBy(user)
def author_cache_key(m, i, author): if IPropertiedUser.providedBy(author) or IMemberData.providedBy(author): return author.getId() else: return author