--- a/iro/offer/provider.py Fri Mar 30 11:49:13 2012 +0200
+++ b/iro/offer/provider.py Fri Mar 30 15:55:44 2012 +0200
@@ -1,4 +1,5 @@
from functools import partial
+from collections import OrderedDict
from ..error import NoRoute, NoTyp, ValidateException, NoProvider
from ..config import Option, Config
@@ -9,34 +10,23 @@
testmode = False
"""- **True** -- no message to external provider should be send.
- **False** (default) -- message are send to external provider."""
- def __init__(self, name, typs={}):
+ def __init__(self, name, typs={}, options=[]):
"""Constructor for Provider class.
:param string name: Name of the Provider.
:param dict typs: A Dictonary with typs and routes.
+ :param items options: [("name",Option(...)),...]
>>> p = Provider("myProvider",{"sms":["route1","route2"]})
"""
- Config.__init__(self, name)
+ Config.__init__(self, name, OrderedDict([
+ ("typ",Option(vProvider, long="One available provider typ.", must=True, default=name))
+ ]+options)
+ )
self.typs=typs
self.testmode = False
- self.options = {
- "typ":Option(vProvider, long="One available provider typ.", must=True, default=name)
- }
- """Options dict for Options used in configuration file (see :class:`iro.config.Option`). Ordering of configuration fields are done by :attr:`order`.
-
- Sample::
-
- {"typ":Option(vProvider, long="One available provider typ.", must=True, default="default")}
-
- A child class typically use update to add more options (see code of :class:`iro.offer.smtp.SMTP`).
- """
-
- self.order = ["typ"]
- """ A list for ordering the options dict (:attr:`options`). """
-
def send(self, typ, route, recipient, message):
"""Main send function, that is called, for every single message.