[MERGE] An EmailMessage class for bzrlib (v3)
Martin Pool
mbp at canonical.com
Tue Jul 10 05:49:48 BST 2007
Martin Pool has voted -0.
Status is now: Waiting
Comment:
+ self._init_message(self, from_address, to_address, subject,
body)
+
+ @staticmethod
+ def _init_message(msg, from_address, to_address, subject,
body=None):
It does seem pretty strange to have a static method that takes (usually)
an instance of this class as its first parameter, and then switching on
isinstance within it is also a bad sign. To me it looks like rather
than
subclassing this type, we should have our own class which acts as a
facade
to one class or the other.
+
+ @staticmethod
+ def string_with_encoding(string):
+ """Return a str object together with an encoding.
+
+ :param string: A str or unicode object.
+ :return: A tuple (str, encoding), where encoding is one of
'ascii',
+ 'utf-8', or '8-bit', in that preferred order.
Having automatic behaviour depending on whether something is a unicode
or
str object has been a bit problematic in the past. Would it be feasible
to have different interfaces and insist on the caller knowing whether
they're putting in binary, ascii or unicode data?
Also it would be good if the docstring explained more about _why_ you
would call this method - it's meant to guess the right encoding to use
for
sending this file.
For details, see:
http://bundlebuggy.aaronbentley.com/request/%3C20070709194921.GA6731%40chistera.yi.org%3E
More information about the bazaar
mailing list