<commit_before>from zope.interface import implements
from twisted.python.components import registerAdapter

from nevow import rend, inevow, static

from axiom.slotmachine import hyper as super
from axiom import item, attributes

from xquotient import webmail
from xmantissa import ixmantissa, webapp, webnav, webtheme
from xmantissa.publicresource import getLoader
from xmantissa.myaccount import MyAccount

# The big kahuna.  This, along with some kind of Person object, is the
# core of Quotient.

class Message(item.Item, item.InstallableMixin):
    implements(ixmantissa.INavigableElement)

    typeName = 'quotient_message'
    schemaVersion = 1

    # add installedOn
    received = attributes.timestamp()
    sender = attributes.text()
    recipient = attributes.text()
    subject = attributes.text()
    impl = attributes.reference()

    _prefs = attributes.inmemory()

    def installOn(self, other):
        super(Message, self).installOn(other)
        other.powerUp(self, ixmantissa.INavigableElement)

    def activate(self):
        self._prefs = ixmantissa.IPreferenceAggregator(self.store)

    def getTabs(self):
        return ()

    def walkMessage(self):
        preferred = self._prefs.getPreferenceValue('preferredMimeType')
        return self.impl.walkMessage(prefer=preferred)

    def getSubPart(self, partID):
        return self.impl.getSubPart(partID)

    def getPart(self, partID):
        if self.impl.partID == partID:
            return self.impl
        return self.getSubPart(partID)

class MessageDetail(webapp.NavMixin, rend.Page):
    '''i represent the viewable facet of some kind of message'''

    docFactory = getLoader('shell')
    contentFragment = getLoader('message-detail')

    def __init__(self, original):
        rend.Page.__init__(self, original)
        webapp.NavMixin.__init__(self,
            original.store.findUnique(webapp.PrivateApplication),
            self._getPageComponents())

    def _getPageComponents(self):
        # this is not nice.  it doesn't really make sense for webapp<commit_msg>allow construction of exmess.Message objects if there is no preference system installed<commit_after>from zope.interface import implements
from twisted.python.components import registerAdapter

from nevow import rend, inevow, static

from axiom.slotmachine import hyper as super
from axiom import item, attributes

from xquotient import webmail
from xmantissa import ixmantissa, webapp, webnav, webtheme
from xmantissa.publicresource import getLoader
from xmantissa.myaccount import MyAccount

# The big kahuna.  This, along with some kind of Person object, is the
# core of Quotient.

class Message(item.Item, item.InstallableMixin):
    implements(ixmantissa.INavigableElement)

    typeName = 'quotient_message'
    schemaVersion = 1

    # add installedOn
    received = attributes.timestamp()
    sender = attributes.text()
    recipient = attributes.text()
    subject = attributes.text()
    impl = attributes.reference()

    _prefs = attributes.inmemory()

    def installOn(self, other):
        super(Message, self).installOn(other)
        other.powerUp(self, ixmantissa.INavigableElement)

    def activate(self):
        self._prefs = ixmantissa.IPreferenceAggregator(self.store, None)

    def getTabs(self):
        return ()

    def walkMessage(self):
        preferred = self._prefs.getPreferenceValue('preferredMimeType')
        return self.impl.walkMessage(prefer=preferred)

    def getSubPart(self, partID):
        return self.impl.getSubPart(partID)

    def getPart(self, partID):
        if self.impl.partID == partID:
            return self.impl
        return self.getSubPart(partID)

class MessageDetail(webapp.NavMixin, rend.Page):
    '''i represent the viewable facet of some kind of message'''

    docFactory = getLoader('shell')
    contentFragment = getLoader('message-detail')

    def __init__(self, original):
        rend.Page.__init__(self, original)
        webapp.NavMixin.__init__(self,
            original.store.findUnique(webapp.PrivateApplication),
            self._getPageComponents())

    def _getPageComponents(self):
        # this is not nice.  it doesn't really make sense for webapp
{'fraction_non_alphanumeric': 0.08420551855375832, 'fraction_numerical': 0.0004757373929590866, 'mean_word_length': 3.5706521739130435, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5961856', 'n_tokens_mistral': 1222, 'n_tokens_neox': 1174, 'n_words': 321}