Skip to content

/ Zope / gocept svn checkins / Archive / 2009 / 2009-08 / SVN: r30050 - webmailer/gocept.restmail/branches/render-refactoring

[ << ] [ >> ]

[ SVN: r30039 - redmine_timelog_update / Wolfgang ... ] [ SVN: r30052 - in redmine_issue_branch/trunk: . ... ]

SVN: r30050 - webmailer/gocept.restmail/branches/render-refactoring
Thomas Lotze <tl(at)gocept.com>
2009-08-05 16:01:43 [ FULL ]
Author: thomas
Date: Wed Aug  5 16:01:42 2009
New Revision: 30050

Log:
created branch to store what we have of a refactoring of how the rendering step
works



Added:
   webmailer/gocept.restmail/branches/render-refactoring/   (props changed)
      - copied from r30049, webmailer/gocept.restmail/trunk/

SVN: r30051 - in webmailer/gocept.restmail/branches/render-refactoring/gocept/restmail: . browser
Thomas Lotze <tl(at)gocept.com>
2009-08-05 16:01:59 [ FULL ]
Author: thomas
Date: Wed Aug  5 16:01:56 2009
New Revision: 30051

Log:
checkpoint


Modified:
  
webmailer/gocept.restmail/branches/render-refactoring/gocept/restmail/browser/configure.zcml
  
webmailer/gocept.restmail/branches/render-refactoring/gocept/restmail/browser/message.py
  
webmailer/gocept.restmail/branches/render-refactoring/gocept/restmail/configure.zcml
  
webmailer/gocept.restmail/branches/render-refactoring/gocept/restmail/draft.py
  
webmailer/gocept.restmail/branches/render-refactoring/gocept/restmail/draft.txt
  
webmailer/gocept.restmail/branches/render-refactoring/gocept/restmail/interfaces.py
  
webmailer/gocept.restmail/branches/render-refactoring/gocept/restmail/render.py
  
webmailer/gocept.restmail/branches/render-refactoring/gocept/restmail/render.txt
  
webmailer/gocept.restmail/branches/render-refactoring/gocept/restmail/reply.pt

Modified:
webmailer/gocept.restmail/branches/render-refactoring/gocept/restmail/browser/configure.zcml
==============================================================================
---
webmailer/gocept.restmail/branches/render-refactoring/gocept/restmail/browser/configure.zcml	(original)
+++
webmailer/gocept.restmail/branches/render-refactoring/gocept/restmail/browser/configure.zcml	Wed
Aug  5 16:01:56 2009
(at)(at) -19,15 +19,15 (at)(at)
 
   <browser:page
      name="inline"
-     for="gocept.restmail.interfaces.IRenderedInline"
+     for="gocept.restmail.interfaces.IRenderedPart"
      template="snippet_inline.pt"
      permission="gocept.restmail.Access"
      />
 
   <browser:page
      name="display"
-     for="gocept.restmail.interfaces.IRenderedInline"
-     class=".message.RenderedInline"
+     for="gocept.restmail.interfaces.IRenderedPart"
+     class=".message.RenderedPart"
      permission="gocept.restmail.Access"
      />
 

Modified:
webmailer/gocept.restmail/branches/render-refactoring/gocept/restmail/browser/message.py
==============================================================================
---
webmailer/gocept.restmail/branches/render-refactoring/gocept/restmail/browser/message.py	(original)
+++
webmailer/gocept.restmail/branches/render-refactoring/gocept/restmail/browser/message.py	Wed
Aug  5 16:01:56 2009
(at)(at) -179,8 +179,8 (at)(at)
         return gocept.imapapi.message.fallback_decode(self.context.raw)
 
 
-class RenderedInline(object):
-    """View helper for IRenderedInline."""
+class RenderedPart(object):
+    """View helper for IRenderedPart."""
 
     def __call__(self):
         body = self.context.body

Modified:
webmailer/gocept.restmail/branches/render-refactoring/gocept/restmail/configure.zcml
==============================================================================
---
webmailer/gocept.restmail/branches/render-refactoring/gocept/restmail/configure.zcml	(original)
+++
webmailer/gocept.restmail/branches/render-refactoring/gocept/restmail/configure.zcml	Wed
Aug  5 16:01:56 2009
(at)(at) -56,7 +56,7 (at)(at)
   <adapter factory=".draft.RenderedDraftMessage"
            provides=".interfaces.IRenderedMessage"/>
   <adapter factory=".draft.RenderedAttachment"
-           provides=".interfaces.IRenderedAttachment"/>
+           provides=".interfaces.IRenderedPart"/>
   <adapter factory=".draft.RenderedAttachment"
            provides=".interfaces.IDownloadable"/>
 
(at)(at) -105,4 +105,6 (at)(at)
 
   <adapter factory=".draft.reply_inline" />
 
+  <adapter factory=".draft.reply_image" />
+
 </configure>

Modified:
webmailer/gocept.restmail/branches/render-refactoring/gocept/restmail/draft.py
==============================================================================
---
webmailer/gocept.restmail/branches/render-refactoring/gocept/restmail/draft.py	(original)
+++
webmailer/gocept.restmail/branches/render-refactoring/gocept/restmail/draft.py	Wed
Aug  5 16:01:56 2009
(at)(at) -392,12 +392,18 (at)(at)
 
 
 (at)zope.interface.implementer(IReply)
-(at)zope.component.adapter(gocept.restmail.interfaces.IRenderedInline)
+(at)zope.component.adapter(gocept.restmail.interfaces.IRenderedPart)
 def reply_inline(part):
     return lxml.html.tostring(part.body)
 
 
-class RenderedDraftMessage(gocept.restmail.render.RenderedInline):
+(at)zope.interface.implementer(IReply)
+(at)zope.component.adapter(gocept.restmail.interfaces.IRenderedImage)
+def reply_image(part):
+    return '[%s]' % part.filename
+
+
+class RenderedDraftMessage(gocept.restmail.render.RenderedPart):
     """A structured rendition of a draft message."""
     # XXX This is a hack; RenderedDraftMessage's context will not behave as
     # IRenderedMessage's context. We get away with this only as long as we
(at)(at) -416,13 +422,14 (at)(at)
         else:
             body = None
 
-        rendered_body = gocept.restmail.render.RenderedInline(context, body)
+        rendered_body = gocept.restmail.render.RenderedPart(
+            context, body, attached=False)
         for attachment in context.objectValues():
             rendered_body.attachments.append(
-                gocept.restmail.interfaces.IRenderedAttachment(attachment))
+                gocept.restmail.interfaces.IRenderedPart(attachment))
 
         super(RenderedDraftMessage, self).__init__(
-            context, rendered_body)
+            context, rendered_body, attached=False)
 
 
     def annotate(self):
(at)(at) -432,7 +439,7 (at)(at)
 class RenderedAttachment(gocept.restmail.render.RenderedBase):
     """A structured rendition of an attached message body part."""
 
-    zope.interface.implements(gocept.restmail.interfaces.IRenderedAttachment,
+    zope.interface.implements(gocept.restmail.interfaces.IRenderedPart,
                               gocept.restmail.interfaces.IDownloadable)
     zope.component.adapts(gocept.restmail.interfaces.IDraftAttachment)
 

Modified:
webmailer/gocept.restmail/branches/render-refactoring/gocept/restmail/draft.txt
==============================================================================
---
webmailer/gocept.restmail/branches/render-refactoring/gocept/restmail/draft.txt	(original)
+++
webmailer/gocept.restmail/branches/render-refactoring/gocept/restmail/draft.txt	Wed
Aug  5 16:01:56 2009
(at)(at) -210,6 +210,51 (at)(at)
 </html>
 
 
+Quoting a message with an image body part
+=========================================
+
+Image body parts are considered part of the message proper iff they are
+declared inline. In that case, they ought to be mentioned by the quoted text
+inside a reply:
+
+>>> print get_html_text(messages[33])
+<html>
+<head></head>
+<body>
+<p>Wolfgang Schnerring &lt;ws(at)gocept.com&gt; wrote:</p>
+  <br />
+  <blockquote><pre>Text vor dem Bild:
+</pre></blockquote>
+  <br />
+  <blockquote>[mail-unread.jpg]</blockquote>
+  <br />
+  <blockquote><pre>Text nach dem Bild.
+</pre></blockquote>
+</body>
+</html>
+
+If, on the other hand, an image part is declared to be an attachment, we don't
+want to see it inside the quoted message test:
+
+>>> print get_html_text(messages[32])
+<html>
+<head></head>
+<body>
+<p>Thomas Lotze &lt;tl(at)gocept.com&gt; wrote:</p>
+  <br />
+  <blockquote><pre>Foo.
+Viele Gr&#252;&#223;e,
+Thomas Lotze
+--
+Thomas Lotze &#183; tl(at)gocept.com
+gocept gmbh &amp; co. kg &#183; forsterstra&#223;e 29 &#183;
06112 halle (saale) &#183; germany
+http://gocept.com &#183; tel +49 345
1229889 0 &#183; fax +49 345 1229889 1
+Zope and Plone consulting and development
+</pre></blockquote>
+</body>
+</html>
+
+
 .. [#getmessages]
     >>> from gocept.restmail.imapaccount import IMAPAccount
     >>> account = IMAPAccount('account', 'localhost', 10143, 'test',
'bsdf')

Modified:
webmailer/gocept.restmail/branches/render-refactoring/gocept/restmail/interfaces.py
==============================================================================
---
webmailer/gocept.restmail/branches/render-refactoring/gocept/restmail/interfaces.py	(original)
+++
webmailer/gocept.restmail/branches/render-refactoring/gocept/restmail/interfaces.py	Wed
Aug  5 16:01:56 2009
(at)(at) -127,23 +127,19 (at)(at)
     annotations = zope.schema.Dict(title=u'Annotations')
 
 
-class IRenderedInline(IRendered):
-    """A structured rendition of a message body part for inline display."""
+class IRenderedPart(IRendered):
+    """A structured rendition of a non-multipart message body part."""
 
-    body = zope.schema.Text(
-        title=u'Body',
-        description=u'Message body part rendered to HTML')
-
-
-class IRenderedAttachment(IRendered):
-    """A structured rendition of an attached message body part."""
+    body = zope.interface.Attribute("The rendered message body.")
 
     filename = zope.schema.TextLine(title=u'File name')
+
     content_type = zope.schema.ASCIILine(title=u'Content type')
+
     size = zope.schema.Int(title=u'Decoded size')
 
 
-class IRenderedImage(IRenderedAttachment):
+class IRenderedImage(IRenderedPart):
     """A structured rendition of an image message body part."""
 
 
(at)(at) -153,25 +149,23 (at)(at)
     parts = zope.schema.List(title=u'Rendered body parts')
 
 
-class IRenderedMessage(IRenderedInline):
+class IRenderedMessage(IRenderedPart):
     """A structured rendition of a message."""
 
     headers = zope.interface.Attribute("A mapping of headers.")
 
-    body = zope.interface.Attribute("The rendered message body.")
-
     def annotate():
         """Add annotations to rendered parts."""
 
 
-class IRenderedBroken(IRenderedInline):
+class IRenderedBroken(IRenderedPart):
     """A rendition of a part that could not be read by the IMAP server."""
 
 
 class IDownloadable(zope.interface.Interface):
     """A downloadable view on a body part."""
 
-    # XXX duplicated from IRenderedAttachment
+    # XXX duplicated from IRenderedPart
     filename = zope.schema.TextLine(title=u'File name')
     content_type = zope.schema.ASCIILine(title=u'Content type')
     size = zope.schema.Int(title=u'Decoded size')

Modified:
webmailer/gocept.restmail/branches/render-refactoring/gocept/restmail/render.py
==============================================================================
---
webmailer/gocept.restmail/branches/render-refactoring/gocept/restmail/render.py	(original)
+++
webmailer/gocept.restmail/branches/render-refactoring/gocept/restmail/render.py	Wed
Aug  5 16:01:56 2009
(at)(at) -41,26 +41,14 (at)(at)
         self.annotations = {}
 
 
-class RenderedInline(RenderedBase):
-    """A structured rendition of a message body part for inline display."""
+class RenderedPart(RenderedBase):
+    """A structured rendition of a non-multipart message body part."""
 
-    zope.interface.implements(gocept.restmail.interfaces.IRenderedInline)
+    zope.interface.implements(gocept.restmail.interfaces.IRenderedPart)
 
-    def __init__(self, context, body):
-        super(RenderedInline, self).__init__(context)
-        self.inline.append(self)
+    def __init__(self, context, body=None, attached=None):
+        super(RenderedPart, self).__init__(context)
         self.body = body
-
-
-class RenderedAttachment(RenderedBase):
-    """A structured rendition of an attached message body part."""
-
-    zope.interface.implements(gocept.restmail.interfaces.IRenderedAttachment)
-
-    def __init__(self, context):
-        super(RenderedAttachment, self).__init__(context)
-        self.attachments.append(self)
-
         self.filename = (
            
self.context.mime_headers().params('Content-Disposition').get('filename')
             or self.context['parameters'].get('name')
(at)(at) -70,18 +58,22 (at)(at)
         # but there is no test for this edge case yet (see bug #4627).
         self.size = self.context.get('size')
 
+        if attached is None:
+            disposition = self.context.mime_headers()['Content-Disposition']
+            attached = (disposition == 'attachment')
+
+        if attached:
+            self.attachments.append(self)
+        else:
+            self.inline.append(self)
 
-class RenderedImage(RenderedAttachment):
+
+class RenderedImage(RenderedPart):
     """A structured rendition of an image message body part."""
 
-    zope.interface.implements(gocept.restmail.interfaces.IRenderedImage,
-                              gocept.restmail.interfaces.IRenderedInline)
+    zope.interface.implements(gocept.restmail.interfaces.IRenderedImage)
     zope.component.adapts(gocept.imapapi.interfaces.IBodyPart)
 
-    def __init__(self, context):
-        super(RenderedImage, self).__init__(context)
-        self.inline.append(self)
-
 
 class RenderedMultipart(RenderedBase):
     """A structured rendition of a multipart message body part."""
(at)(at) -97,7 +89,7 (at)(at)
             self.attachments.extend(part.attachments)
 
 
-class RenderedMessage(RenderedInline):
+class RenderedMessage(RenderedPart):
     """A structured rendition of a message."""
 
     zope.interface.implements(gocept.restmail.interfaces.IRenderedMessage)
(at)(at) -113,17 +105,11 (at)(at)
         pass
 
 
-class RenderedBroken(RenderedInline):
+class RenderedBroken(RenderedPart):
     """A rendition of a part that could not be read by the IMAP server."""
 
     zope.interface.implements(gocept.restmail.interfaces.IRenderedBroken)
 
-    def __init__(self, context):
-        super(RenderedBroken, self).__init__(context, None)
-
-
-clean_html = lxml.html.clean.Cleaner()
-
 
 (at)zope.interface.implementer(gocept.restmail.interfaces.IRendered)
 (at)zope.component.adapter(gocept.imapapi.interfaces.IBodyPart)
(at)(at) -150,7 +136,7 (at)(at)
     except gocept.imapapi.interfaces.BrokenMIMEPart:
         return RenderedBroken(part)
 
-    return RenderedAttachment(part)
+    return RenderedPart(part, attached=True)
 
 
 (at)zope.interface.implementer(gocept.restmail.interfaces.IRendered)
(at)(at) -188,7 +174,8 (at)(at)
     """Provide a body representation for multipart/related."""
     subparts = part.parts()
     rendered = [gocept.restmail.interfaces.IRendered(subparts[0])]
-    rendered.extend(RenderedAttachment(part) for part in subparts[1:])
+    rendered.extend(RenderedPart(part, attached=True)
+                    for part in subparts[1:])
     return RenderedMultipart(part, rendered)
 
 
(at)(at) -205,20 +192,21 (at)(at)
 (at)zope.component.adapter(gocept.imapapi.interfaces.IBodyPart)
 def body_text_html(part):
     """Provide a body representation for text/html."""
-    return RenderedInline(part, BodyTextHTML(part))
+    return RenderedPart(part, BodyTextHTML(part))
 
 
 (at)zope.interface.implementer(gocept.restmail.interfaces.IRendered)
 (at)zope.component.adapter(gocept.imapapi.interfaces.IBodyPart)
 def body_text_plain(part):
     """Provide a body representation for text/plain."""
-    return RenderedInline(part, BodyTextPlain(part))
+    return RenderedPart(part, BodyTextPlain(part))
 
 
 class BodyTextHTML(object):
     """View helper for body parts of type text/html."""
 
     def __new__(cls, part):
+        clean_html = lxml.html.clean.Cleaner()
         text = part.fetch()
         encoding = part['parameters'].get('charset')
         try:

Modified:
webmailer/gocept.restmail/branches/render-refactoring/gocept/restmail/render.txt
==============================================================================
---
webmailer/gocept.restmail/branches/render-refactoring/gocept/restmail/render.txt	(original)
+++
webmailer/gocept.restmail/branches/render-refactoring/gocept/restmail/render.txt	Wed
Aug  5 16:01:56 2009
(at)(at) -131,13 +131,13 (at)(at)
 
 >>> rendered = gocept.restmail.interfaces.IRendered(messages[30])
 >>> rendered.body.inline
-[<gocept.restmail.render.RenderedInline object at 0xb21c44c>,
+[<gocept.restmail.render.RenderedPart object at 0xb21c44c>,
  <gocept.restmail.render.RenderedMessage object at 0xb21c9ac>]
 >>> rendered.body.attachments
 []
 >>> nested = rendered.body.inline[1]
 >>> nested.body.inline
-[<gocept.restmail.render.RenderedInline object at 0xb21c44c>,
+[<gocept.restmail.render.RenderedPart object at 0xb21c44c>,
  <gocept.restmail.render.RenderedImage object at 0xb21ce7bc>]
 >>> nested.body.attachments
 [<gocept.restmail.render.RenderedImage object at 0xb21ce7bc>]

Modified:
webmailer/gocept.restmail/branches/render-refactoring/gocept/restmail/reply.pt
==============================================================================
---
webmailer/gocept.restmail/branches/render-refactoring/gocept/restmail/reply.pt	(original)
+++
webmailer/gocept.restmail/branches/render-refactoring/gocept/restmail/reply.pt	Wed
Aug  5 16:01:56 2009
(at)(at) -2,9 +2,9 (at)(at)
 <head></head>
 <body>
 <p tal:content="options/attribution" />
-<tal:parts repeat="part options/parts">
+<tal:parts repeat="part options/parts"><tal:block
condition="part">
   <br />
   <blockquote tal:content="structure part" />
-</tal:parts>
+</tal:block></tal:parts>
 </body>
 </html>

SVN: r30061 - webmailer/gocept.imapapi/branches/4896
Thomas Lotze <tl(at)gocept.com>
2009-08-06 10:19:29 [ FULL ]
Author: thomas
Date: Thu Aug  6 10:19:28 2009
New Revision: 30061

Log:
created branch for #4896: Inline Darstellungen von Attachments (Bilder)



Added:
   webmailer/gocept.imapapi/branches/4896/   (props changed)
      - copied from r30060, webmailer/gocept.imapapi/trunk/

SVN: r30063 - webmailer/gocept.restmail/branches/4896
Thomas Lotze <tl(at)gocept.com>
2009-08-06 10:23:16 [ FULL ]
Author: thomas
Date: Thu Aug  6 10:23:15 2009
New Revision: 30063

Log:
created feature branch for #4896



Added:
   webmailer/gocept.restmail/branches/4896/   (props changed)
      - copied from r30062, webmailer/gocept.restmail/trunk/

SVN: r30067 - webmailer/gocept.restmail/trunk/gocept/restmail
Thomas Lotze <tl(at)gocept.com>
2009-08-06 12:52:29 [ FULL ]
Author: thomas
Date: Thu Aug  6 12:52:27 2009
New Revision: 30067

Log:
re #5919: fixed identity retrieval when sending a message


Added:
   webmailer/gocept.restmail/trunk/gocept/restmail/draft-regression.txt  
(contents, props changed)
Modified:
   webmailer/gocept.restmail/trunk/gocept/restmail/draft.py
   webmailer/gocept.restmail/trunk/gocept/restmail/tests.py

Added: webmailer/gocept.restmail/trunk/gocept/restmail/draft-regression.txt
==============================================================================
--- (empty file)
+++ webmailer/gocept.restmail/trunk/gocept/restmail/draft-regression.txt	Thu
Aug  6 12:52:27 2009
(at)(at) -0,0 +1,84 (at)(at)
+===========================
+Regression tests for drafts
+===========================
+
+Using identity sources
+----------------------
+
+[#setup]_
+
+>>> import gocept.restmail.identity
+>>> import gocept.restmail.interfaces
+>>> import zope.interface
+>>> import zope.component
+>>> class DummyIdentitySource(object):
+...
+...     zope.interface.implements(gocept.restmail.interfaces.IIdentitySource)
+...     zope.component.adapts(gocept.restmail.interfaces.IProfile)
+...
+...     def __init__(self, context):
+...         self.context = context
+...
+...     def __iter__(self):
+...         return iter(self.keys())
+...
+...     def keys(self):
+...         return ['1', '2', '3']
+...
+...     def values(self):
+...         return [self[key] for key in self.keys()]
+...
+...     def __getitem__(self, name):
+...         identity = gocept.restmail.identity.Identity(
+...             'id' + name, 'name' + name, 'address' + name, 'account', 'mh')
+...         return identity.__of__(profile)
+...
+>>> zope.component.provideAdapter(DummyIdentitySource,
name='testing')
+
+Create a draft with an identity from the dummy source:
+
+>>> from gocept.restmail.draft import new_draft
+>>> reply = new_draft(profile['drafts'], messages[0])
+>>> reply.identity = '1'
+
+Sending should work:
+
+>>> reply.send()
+MIME-Version: 1.0
+...
+Subject: Re: something simple
+...
+
+
+Teardown
+--------
+
+>>>
zope.component.getSiteManager().unregisterAdapter(DummyIdentitySource,
+...                                                   name='testing')
+True
+
+
+.. [#setup]
+    >>> from gocept.restmail.imapaccount import IMAPAccount
+    >>> account = IMAPAccount('account', 'localhost', 10143, 'test',
'bsdf')
+    >>> account = account.__of__(app)
+    >>> folder = account.folders(u'Testmessages')[0]
+    >>> messages = folder.messages()
+
+    >>> from OFS.ObjectManager import ObjectManager
+    >>> from gocept.restmail.profile import Profile
+    >>> container = ObjectManager()
+    >>> container = container.__of__(app)
+    >>> _ = container._setObject('asdf', Profile('asdf'))
+    >>> profile = container['asdf']
+    >>> ignore = profile._setObject('account', account)
+
+    >>> import Products.MailHost.MailHost
+    >>> mailhost = Products.MailHost.MailHost.MailHost(
+    ...     id='mh',
+    ...     smtp_host='localhost',
+    ...     smtp_port='25',
+    ...     smtp_uid='user',
+    ...     smtp_pwd='password')
+    >>> ignore = profile._setObject('mh', mailhost)
+

Modified: webmailer/gocept.restmail/trunk/gocept/restmail/draft.py
==============================================================================
--- webmailer/gocept.restmail/trunk/gocept/restmail/draft.py	(original)
+++ webmailer/gocept.restmail/trunk/gocept/restmail/draft.py	Thu Aug  6
12:52:27 2009
(at)(at) -159,7 +159,7 (at)(at)
 
     def raw(self, headers=None):
         profile = gocept.restmail.interfaces.IProfile(self)
-        identity = profile[self.identity]
+        identity = profile.get_identity(self.identity)
 
         # 1. Convert to RFC 822 message
         # XXX We really want to use MIMEText, which unfortunately treats the
(at)(at) -241,7 +241,7 (at)(at)
 
     def send(self):
         profile = gocept.restmail.interfaces.IProfile(self)
-        identity = profile[self.identity]
+        identity = profile.get_identity(self.identity)
         account = profile[identity.account_id]
         message = self.raw({'Date': email.Utils.formatdate(),
                             'Message-ID': email.Utils.make_msgid()})

Modified: webmailer/gocept.restmail/trunk/gocept/restmail/tests.py
==============================================================================
--- webmailer/gocept.restmail/trunk/gocept/restmail/tests.py	(original)
+++ webmailer/gocept.restmail/trunk/gocept/restmail/tests.py	Thu Aug  6
12:52:27 2009
(at)(at) -159,9 +159,11 (at)(at)
             gocept.restmail.draft,
             optionflags=doctest.NORMALIZE_WHITESPACE))
    
suite.addTest(unittest.makeSuite(gocept.restmail.test_draft.DraftFolderTest))
+
     suite.addTest(FunctionalDocFileSuite(
         'connection.txt',
         'render.txt',
         'draft.txt',
+        'draft-regression.txt',
         ))
     return suite

SVN: r30071 - webmailer/gocept.imapapi/branches/4896/gocept/imapapi
Wolfgang Schnerring <ws(at)gocept.com>
2009-08-06 13:35:59 [ FULL ]
Author: wosc
Date: Thu Aug  6 13:35:58 2009
New Revision: 30071

Log:
Re #4896: be more dict-like and differentiate getitem/get



Modified:
   webmailer/gocept.imapapi/branches/4896/gocept/imapapi/message.py
   webmailer/gocept.imapapi/branches/4896/gocept/imapapi/message.txt

Modified: webmailer/gocept.imapapi/branches/4896/gocept/imapapi/message.py
==============================================================================
--- webmailer/gocept.imapapi/branches/4896/gocept/imapapi/message.py	(original)
+++ webmailer/gocept.imapapi/branches/4896/gocept/imapapi/message.py	Thu Aug  6
13:35:58 2009
(at)(at) -64,9 +64,15 (at)(at)
     def __getitem__(self, key):
         header = self.headers.get_params(header=key)
         if not header:
-            return None
+            raise KeyError(key)
         return header[0][0]
 
+    def get(self, key, default=None):
+        try:
+            return self[key]
+        except KeyError:
+            return default
+
     def params(self, key):
         header = self.headers.get_params(header=key)
         if not header:

Modified: webmailer/gocept.imapapi/branches/4896/gocept/imapapi/message.txt
==============================================================================
---
webmailer/gocept.imapapi/branches/4896/gocept/imapapi/message.txt	(original)
+++ webmailer/gocept.imapapi/branches/4896/gocept/imapapi/message.txt	Thu Aug 
6 13:35:58 2009
(at)(at) -169,6 +169,9 (at)(at)
 >>> message = INBOX.messages.values()[2]
 >>> part = message.body.parts[0]
 >>> print part.mime_headers['Content-Disposition']
+Traceback (most recent call last):
+KeyError: 'Content-Disposition'
+>>> print part.mime_headers.get('Content-Disposition')
 None
 >>> part = message.body.parts[1]
 >>> part.mime_headers['Content-Disposition']

SVN: r30072 - webmailer/gocept.restmail/branches/4896/gocept/restmail
Wolfgang Schnerring <ws(at)gocept.com>
2009-08-06 14:07:55 [ FULL ]
Author: wosc
Date: Thu Aug  6 14:07:53 2009
New Revision: 30072

Log:
Re #4896: implemented quoting images in replies



Modified:
   webmailer/gocept.restmail/branches/4896/gocept/restmail/configure.zcml
   webmailer/gocept.restmail/branches/4896/gocept/restmail/draft.py
   webmailer/gocept.restmail/branches/4896/gocept/restmail/draft.txt
   webmailer/gocept.restmail/branches/4896/gocept/restmail/reply.pt

Modified:
webmailer/gocept.restmail/branches/4896/gocept/restmail/configure.zcml
==============================================================================
---
webmailer/gocept.restmail/branches/4896/gocept/restmail/configure.zcml	(original)
+++ webmailer/gocept.restmail/branches/4896/gocept/restmail/configure.zcml	Thu
Aug  6 14:07:53 2009
(at)(at) -105,4 +105,5 (at)(at)
 
   <adapter factory=".draft.reply_inline" />
 
+  <adapter factory=".draft.reply_image" />
 </configure>

Modified: webmailer/gocept.restmail/branches/4896/gocept/restmail/draft.py
==============================================================================
--- webmailer/gocept.restmail/branches/4896/gocept/restmail/draft.py	(original)
+++ webmailer/gocept.restmail/branches/4896/gocept/restmail/draft.py	Thu Aug  6
14:07:53 2009
(at)(at) -397,6 +397,15 (at)(at)
     return lxml.html.tostring(part.body)
 
 
+(at)zope.interface.implementer(IReply)
+(at)zope.component.adapter(gocept.restmail.interfaces.IRenderedImage)
+def reply_image(part):
+    if part.context.mime_headers().get('Content-Disposition') == 'inline':
+        return '[%s]' % part.filename
+    else:
+        return ''
+
+
 class RenderedDraftMessage(gocept.restmail.render.RenderedInline):
     """A structured rendition of a draft message."""
     # XXX This is a hack; RenderedDraftMessage's context will not behave as

Modified: webmailer/gocept.restmail/branches/4896/gocept/restmail/draft.txt
==============================================================================
---
webmailer/gocept.restmail/branches/4896/gocept/restmail/draft.txt	(original)
+++ webmailer/gocept.restmail/branches/4896/gocept/restmail/draft.txt	Thu Aug 
6 14:07:53 2009
(at)(at) -209,6 +209,50 (at)(at)
 </body>
 </html>
 
+Quoting a message with an image body part
+=========================================
+
+Image body parts are considered part of the message proper iff they are
+declared inline. In that case, they ought to be mentioned by the quoted text
+inside a reply:
+
+>>> print get_html_text(messages[33])
+<html>
+<head></head>
+<body>
+<p>Wolfgang Schnerring &lt;ws(at)gocept.com&gt; wrote:</p>
+  <br />
+  <blockquote><pre>Text vor dem Bild:
+</pre></blockquote>
+  <br />
+  <blockquote>[mail-unread.jpg]</blockquote>
+  <br />
+  <blockquote><pre>Text nach dem Bild.
+</pre></blockquote>
+</body>
+</html>
+
+If, on the other hand, an image part is declared to be an attachment, we don't
+want to see it inside the quoted message test:
+
+>>> print get_html_text(messages[32])
+<html>
+<head></head>
+<body>
+<p>Thomas Lotze &lt;tl(at)gocept.com&gt; wrote:</p>
+  <br />
+  <blockquote><pre>Foo.
+Viele Gr&#252;&#223;e,
+Thomas Lotze
+--
+Thomas Lotze &#183; tl(at)gocept.com
+gocept gmbh &amp; co. kg &#183; forsterstra&#223;e 29 &#183;
06112 halle (saale) &#183; germany
+http://gocept.com &#183; tel +49 345
1229889 0 &#183; fax +49 345 1229889 1
+Zope and Plone consulting and development
+</pre></blockquote>
+</body>
+</html>
+
 
 .. [#getmessages]
     >>> from gocept.restmail.imapaccount import IMAPAccount

Modified: webmailer/gocept.restmail/branches/4896/gocept/restmail/reply.pt
==============================================================================
--- webmailer/gocept.restmail/branches/4896/gocept/restmail/reply.pt	(original)
+++ webmailer/gocept.restmail/branches/4896/gocept/restmail/reply.pt	Thu Aug  6
14:07:53 2009
(at)(at) -2,9 +2,9 (at)(at)
 <head></head>
 <body>
 <p tal:content="options/attribution" />
-<tal:parts repeat="part options/parts">
+<tal:parts repeat="part options/parts"><tal:block
condition="part">
   <br />
   <blockquote tal:content="structure part" />
-</tal:parts>
+</tal:block></tal:parts>
 </body>
 </html>

SVN: r30075 - webmailer/gocept.restmail/branches/4896
Wolfgang Schnerring <ws(at)gocept.com>
2009-08-06 14:34:10 [ FULL ]
Author: wosc
Date: Thu Aug  6 14:34:08 2009
New Revision: 30075

Log:
remove branch after merge



Removed:
   webmailer/gocept.restmail/branches/4896/

SVN: r30076 - webmailer/gocept.webmail/trunk
Wolfgang Schnerring <ws(at)gocept.com>
2009-08-06 14:45:09 [ FULL ]
Author: wosc
Date: Thu Aug  6 14:45:07 2009
New Revision: 30076

Log:
beginnings of a changelog



Added:
   webmailer/gocept.webmail/trunk/CHANGES.txt

Added: webmailer/gocept.webmail/trunk/CHANGES.txt
==============================================================================
--- (empty file)
+++ webmailer/gocept.webmail/trunk/CHANGES.txt	Thu Aug  6 14:45:07 2009
(at)(at) -0,0 +1,14 (at)(at)
+=======
+CHANGES
+=======
+
+2009-07/2009-08
+===============
+
+- Folder management (#4600)
+
+- Display images directly (#4896)
+
+- Menu layout (#4668)
+
+- hashedresource (#4709)
\ No newline at end of file

SVN: r30085 - webmailer/gocept.imapapi/trunk/gocept/imapapi
Thomas Lotze <tl(at)gocept.com>
2009-08-10 15:05:17 [ FULL ]
Author: thomas
Date: Mon Aug 10 15:05:16 2009
New Revision: 30085

Log:
fixed behaviour of MIME headers when used with the body of a non-multipart
message


Modified:
   webmailer/gocept.imapapi/trunk/gocept/imapapi/message.py
   webmailer/gocept.imapapi/trunk/gocept/imapapi/message.txt

Modified: webmailer/gocept.imapapi/trunk/gocept/imapapi/message.py
==============================================================================
--- webmailer/gocept.imapapi/trunk/gocept/imapapi/message.py	(original)
+++ webmailer/gocept.imapapi/trunk/gocept/imapapi/message.py	Mon Aug 10
15:05:16 2009
(at)(at) -81,7 +81,7 (at)(at)
 
     def fetch_headers(self):
         if not self.part_id:
-            return
+            return email.Message.Message()
         header_lines = _fetch(self.message.server, self.message.parent,
                               self.message.UID,
                               'BODY.PEEK[%s.MIME]' % self.part_id)

Modified: webmailer/gocept.imapapi/trunk/gocept/imapapi/message.txt
==============================================================================
--- webmailer/gocept.imapapi/trunk/gocept/imapapi/message.txt	(original)
+++ webmailer/gocept.imapapi/trunk/gocept/imapapi/message.txt	Mon Aug 10
15:05:16 2009
(at)(at) -179,6 +179,12 (at)(at)
 >>> part.mime_headers.params('Content-Disposition')
 {'filename': 'img.jpg'}
 
+The body of a non-multipart message has empty MIME headers:
+
+>>> message = INBOX.messages.values()[0]
+>>> message.body.mime_headers.params('Content-Type')
+{}
+
 
 Accessing parts using the Content-ID header
 -------------------------------------------

MailBoxer