how to change a factory use of rfc822.Message to mhlib.Message

Discussion in 'Python' started by John Doe, Aug 27, 2004.

  1. John Doe

    John Doe Guest

    I've never used a factory and would like to get some help.
    The class
    mailbox.UnixMailbox has a defination for a factory.

    __init__(self, fp, factory=<class rfc822.Message>)

    where fp is a file pointer.

    I don't want to use rfc822.Message. I'd like to use mhlib.Message instead.

    rfc822.Message requires:
    __init__(self, fp, seekable=1)

    mhlib.Message requires:
    __init__(self, f, n, fp=None)

    where f think the is a folder name. I've seen '.' used.
    (The documentation is very unclear here). And 'n' is the seekable.

    How do I call mailbox.UnixMailbox( fp ... ) with mhlib.Message?

    Thanks
     
    John Doe, Aug 27, 2004
    #1
    1. Advertising

  2. John Doe

    Steve Holden Guest

    John Doe wrote:

    > I've never used a factory and would like to get some help.
    > The class
    > mailbox.UnixMailbox has a defination for a factory.
    >
    > __init__(self, fp, factory=<class rfc822.Message>)
    >
    > where fp is a file pointer.
    >
    > I don't want to use rfc822.Message. I'd like to use mhlib.Message instead.
    >
    > rfc822.Message requires:
    > __init__(self, fp, seekable=1)
    >
    > mhlib.Message requires:
    > __init__(self, f, n, fp=None)
    >
    > where f think the is a folder name. I've seen '.' used.
    > (The documentation is very unclear here). And 'n' is the seekable.
    >
    > How do I call mailbox.UnixMailbox( fp ... ) with mhlib.Message?



    You'll need to write a "wrapper" class or function around mhlib.Message
    to make it look sufficiently similar to rfc822.Message. Then you provide
    the wrapper as the factory argument when you create your UnixMailbox.

    Clearly the __init__() signature of whatever factory you provide has to
    match that of rfc822.Message otherwise you'll get an error when the
    mailbox code tries to create a message instance.

    regards
    Steve
     
    Steve Holden, Aug 31, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Medi Montaseri
    Replies:
    17
    Views:
    877
    Medi Montaseri
    Sep 3, 2003
  2. shilpa
    Replies:
    5
    Views:
    6,150
    akila_natarajan
    May 12, 2011
  3. praba kar
    Replies:
    1
    Views:
    765
    Jorgen Grahn
    Aug 7, 2005
  4. Phoe6
    Replies:
    4
    Views:
    464
    Dennis Lee Bieber
    Nov 30, 2006
  5. message/rfc822 and perl

    , Aug 29, 2003, in forum: Perl Misc
    Replies:
    1
    Views:
    147
    James Willmore
    Aug 30, 2003
Loading...

Share This Page