|
Like most of the other software, applications you develop with Pythomnic
cannot live in isolation. This is what makes it so difficult to write reliable
software - the need to cope with something not under your control.
Network services you develop, good if they are entirely self-contained,
but it is very improbable. For an integration middleware Pythomnic has
been originally created for, it is downright impossible. Instead you typically
pick a request and turn it into a train of calls to databases, message queues,
application servers and so on. The role of middleware is to glue systems
together. The question is how do you access these external systems.
Pythomnic application modules access external systems in a uniform way -
through a pool of connections. The connection is an adapter which hides
the external systems specifics from the application code. The pool is what
isolates and protects the Pythomnic service from the external system and
vice versa.
Technically, all calls to all external systems look the same:
result = pmnc.the_system.execute(*args, **kwargs)
The call is presumably synchronous and may return a result. It is always
execute method which is being called. In fact, pmnc.the_system refers
to a static module which is identical for all external systems and contains
the code for pool of connections. The pool's execute method delegates
the call to any of the available connections. If all the connections are busy,
the call is queued up and delayed until a connection becomes available.
The interpretation of the arguments and the result depends on what kind of a
system is that and is done by the connection adapter. For example, a call to
a database may look like
records = pmnc.foo_db.execute("SELECT a, b FROM t WHERE k = %(k)s", k = 10)
for record in records:
print record["a"], record["b"]
whereas for sending an SMS you would do
message_id = pmnc.prov_smpp.execute(0x01, 0x01, "9123456789", "Hi there",
schedule_delivery_time = "20080101...")
print "sent as %s" % message_id
|
Features Download Documentation Tutorial |