def get_post_intro_and_remainder(contentProvider, text): """Get the introduction and remainder text of the formatted post :param object contentProvider: The content provider renderning the message, providing access to the context, groupInfo and other useful tidbits. :parm str text: The text to split into an introduction and remainder :returns: A 2-tuple of the strings that represent the email intro and the remainder.""" if not contentProvider.groupInfo.groupObj: raise ValueError("The groupInfo object should always have a groupObj") if not text: # Sorry, Dijkstra return SplitMessage('', '') mailBody = wrap_message(text) plain = split_message(mailBody) messages = contentProvider.groupInfo.groupObj.messages perm = get_visibility(messages) ml = IGSMailingListInfo(contentProvider.groupInfo.groupObj) okAddresses = (contentProvider.siteInfo.get_support_email(), ml.get_property('mailto')) markedUpIntro = '' if plain.intro: markedUpIntro = unicode(OnlineHTMLBody(plain.intro, perm, okAddresses)) markedUpRemainder = '' if plain.remainder: markedUpRemainder = unicode(OnlineHTMLBody(plain.remainder, perm, okAddresses)) retval = SplitMessage(markedUpIntro, markedUpRemainder) return retval
def __init__(self, originalText, perm, okAddresses): super(OnlineHTMLBody, self).__init__(originalText) self.matchers = [youTubeMatcher, vimeoMatcher, boldMatcher, wwwMatcher, uriMatcher] if perm == PERM_ANN: # The messages are visible to Anon p = PublicEmailMatcher(okAddresses) self.matchers.append(p) else: self.matchers.append(emailMatcher) sorted(self.matchers, key=attrgetter('weight')) @cache('gs.group.messages.post.postintroremainder', lambda contentProvider, text: ':'.join( (str(contentProvider.post['post_id']), str((get_visibility(contentProvider.groupInfo.groupObj)))) ), 3600) def get_post_intro_and_remainder(contentProvider, text): """Get the introduction and remainder text of the formatted post :param object contentProvider: The content provider renderning the message, providing access to the context, groupInfo and other useful tidbits. :parm str text: The text to split into an introduction and remainder :returns: A 2-tuple of the strings that represent the email intro and the remainder.""" if not contentProvider.groupInfo.groupObj: raise ValueError("The groupInfo object should always have a groupObj") if not text: # Sorry, Dijkstra return SplitMessage('', '') mailBody = wrap_message(text)
def permission(self): retval = get_visibility(self.messages) return retval