Пример #1
0
 def uid(self):
     mt = getToolByName(self.context, 'portal_membership')
     try:
         return mt.getAuthenticatedMember().getUser().getId()
     except:
         if IMemberData.providedBy(self.context):
             return self.context.getId()
         else:
             raise
Пример #2
0
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
Пример #3
0
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
Пример #4
0
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)
Пример #5
0
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)
Пример #6
0
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
Пример #7
0
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
Пример #8
0
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
Пример #9
0
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
Пример #10
0
 def is_plone_user(self, user):
     return IPropertiedUser.providedBy(user) or IMemberData.providedBy(user)
Пример #11
0
def author_cache_key(m, i, author):
    if IPropertiedUser.providedBy(author) or IMemberData.providedBy(author):
        return author.getId()
    else:
        return author
Пример #12
0
 def is_plone_user(self, user):
     return IPropertiedUser.providedBy(user) or IMemberData.providedBy(user)
Пример #13
0
def author_cache_key(m, i, author):
    if IPropertiedUser.providedBy(author) or IMemberData.providedBy(author):
        return author.getId()
    else:
        return author