gs.group.list.command¶
Contents:
Introduction¶
This product provides support for email-commands. It does this by providing a function for processing commands (to check for a command in an email message), a way to register command processors, and the result enumeration for returning the result of a command.
Register command processors¶
The commands are named adaptors that implement the
gs.group.list.command.interfaces.IEmailCommand
interface. The name is the command-name in lower case. So
the command to unsubscribe someone from a group will have the
adaptor name unsubscribe. The adaptor must
- Take the group in the
__init__()method (it adapts the group), - Provide a
process()method that takes the email and browser-request as an argument.
Example¶
I prefer to declare adaptors using ZCML. This will declare a
command named example. This command will be executed by
process_command() whenever the subject line of an email
message contains starts with example (in upper or lower
case). The command itself is implemented by the
ExampleCommand class in the example module in the
local directory:
<adapter
name="example"
for="gs.group.base.interfaces.IGSGroupMarker"
provides="gs.group.list.command.interfaces.IEmailCommand"
factory=".example.ExampleCommand" />
The example module would contain the
ExampleCommand class, which inherits from the abstract
base-class for commands.
from gs.group.list.command import CommandABC, CommandResult
class ExampleCommand(CommandABC):
def process(email, request):
# TODO: Stuff
return CommandResult.commandStop
The request is passed in to the process() method so the
class can issue email-notifications.