cement.ext.ext_dummy
Cement dummy extension module.
- class cement.ext.ext_dummy.DummyMailHandler(**kw: Any)[source]
Bases:
MailHandler
This class implements the
cement.core.mail.IMail
interface, but is intended for use in development as no email is actually sent.Example:
class MyApp(App): class Meta: label = 'myapp' mail_handler = 'dummy' with MyApp() as app: app.run() app.mail.send('This is my fake message', subject='This is my subject', to=['john@example.com', 'rita@example.com'], from_addr='me@example.com', )
The above will print the following to console:
====================================================================== DUMMY MAIL MESSAGE ---------------------------------------------------------------------- To: john@example.com, rita@example.com From: me@example.com CC: BCC: Subject: This is my subject --- This is my fake message ----------------------------------------------------------------------
Configuration
This handler supports the following configuration settings:
to - Default
to
addresses (list, or comma separated depending on the ConfigHandler in use)from_addr - Default
from_addr
addresscc - Default
cc
addresses (list, or comma separated depending on the ConfigHandler in use)bcc - Default
bcc
addresses (list, or comma separated depending on the ConfigHandler in use)subject - Default
subject
subject_prefix - Additional string to prepend to the
subject
You can add these to any application configuration file under a
[mail.dummy]
section, for example:~/.myapp.conf
[myapp] # set the mail handler to use mail_handler = dummy [mail.dummy] # default to addresses (comma separated list) to = me@example.com # default from address from = someone_else@example.com # default cc addresses (comma separated list) cc = jane@example.com, rita@example.com # default bcc addresses (comma separated list) bcc = blackhole@example.com, someone_else@example.com # default subject subject = This is The Default Subject # additional prefix to prepend to the subject subject_prefix = MY PREFIX >
- send(body: str, **kw: Any) bool [source]
Mimic sending an email message, but really just print what would be sent to console. Keyword arguments override configuration defaults (cc, bcc, etc).
- Parameters:
body (str) – The message body to send
- Keyword Arguments:
- Returns:
True
if message is sent successfully,False
otherwise- Return type:
Example
# Using all configuration defaults app.mail.send('This is my message body') # Overriding configuration defaults app.mail.send('My message body' to=['john@example.com'], from_addr='me@example.com', cc=['jane@example.com', 'rita@example.com'], subject='This is my subject', )
- class cement.ext.ext_dummy.DummyOutputHandler(**kw: Any)[source]
Bases:
OutputHandler
This class is an internal implementation of the
cement.core.output.OutputHandlerBase
interface. It does not take any parameters on initialization, and does not actually output anything.
- class cement.ext.ext_dummy.DummyTemplateHandler(*args: Any, **kwargs: Any)[source]
Bases:
TemplateHandler
This class is an internal implementation of the
cement.core.template.TemplateHandlerBase
interface. It does not take any parameters on initialization, and does not actually render anything.