[Twisted-Python] Hacking imap

Jp Calderone exarkun at intarweb.us
Tue Jun 24 14:30:38 MDT 2003


On Tue, Jun 24, 2003 at 01:28:41PM +0200, Anders Hammarquist wrote:
> In a message of Tue, 24 Jun 2003 01:23:53 EDT, Jp Calderone writes:
> >On Tue, Jun 24, 2003 at 01:38:32AM +0200, Anders Hammarquist wrote:
> >  Could you elaborate on "properly handle"?  I am currently making changes
> >in this area as well, mainly in the direction of avoiding all the in-memory
> >buffering the code currently does.
> 
> Certainly,
> 
> There are lots of places where literals aren't handled (I think that
> the only place where they are handled is in APPEND, at least from what
> my testing show). Anyplace where the syntax allows a string, a literal
> is allowed.

  Ahh yes, I believe I blocked out that particular memory :(  Thanks for
tackling it :)

> 
> The idea is to have the command dispatcher parse the arguments for each
> command, and then pass the arguments to the command handling function.
> This way, if the argument is a literal or a string, it can be passed as
> a file object (but there is no need - for example, if a mailbox name
> is given as a literal, there is little reason to give it in a file object).
> 
> So instead of naming the handler functions <state>_<COMMAND>, I'll have
> <state>_<COMMAND> be a tuple containing ( <handler_function>,
> <arg_parser>, <arg_parser>, ...) and then call the handler_function
> with the results of the arg_parser functions.

  This sounds like a great approach.  If I could make a request (and maybe
you were going to do this anway), it would be nice if the arg_parsers could
work incrementally: this is mostly of use when receiving an actual message,
to avoid buffering it all in memory (or even buffering it on disk and
pushing off parsing it until it is completely received).

  Maybe this means <arg_parser> should be a factory that returns a parser,
so that state can be more easily managed when parsing the full
list-expression returned with from a fetch command.

  Sound reasonable?

  Jp

-- 
http://catandgirl.com/view.cgi?44
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: </pipermail/twisted-python/attachments/20030624/f361a576/attachment.sig>


More information about the Twisted-Python mailing list