Put epsilon.modal in Twisted Core.

[email protected]
Newsgroups gmane.comp.python.twisted.bugs
Message-ID <[email protected]>
New submission from ralphm <[email protected]>:

Processing protocols usually requires some kind of state machine. The `modal` module in Divmod's Epsilon package provides a way to define namespaces using subclasses. Each subclass represents a mode, and methods in such mode classes are available on the containing class instance whenever that instance is in the mode associated with these method implementations.

The implementation of `Modal` in Epsilon has some issues that need to be resolved before inclusion in Twisted (there might be more):

 * The `__enter__` and `__exit__` methods of the base `mode` class are never called. This is caused by the way the `ModalMethod`s are built upon class definition through `ModalType.__new__`. It doesn't deal with inheritance properly.
 * Because of the above, the `transitionTo` method of `Modal` can only be used if every mode class explicitely defines (possibly empty) `__enter__` and `__exit__` methods. This is sometimes avoided by just assigning to `self.mode` directly.
 * Tests are severely lacking.

The way I suggest this module is incorporated into Twisted is the following:

 * Create a branch for this ticket
 * Copy the current `epsilon.modal` module to `twisted.python.modal`, and its associated tests to `twisted.test.test_modal`.
 * Fix up imports to reflect the move
 * Fix up the tests to have at least full statement coverage
 * Put up for a first review, along with some questions about desired behaviour.

----------
Type     : enhancement
Component: core
Keywords : 
Priority : normal
Nosy     : 
----------
http://twistedmatrix.com/trac/ticket/3902
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.