This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# zato-labs | |
from zato.invoke_retry import InvokeRetry, NeedsRetry | |
# Zato | |
from zato.server.service import Service | |
retry_repeats = 5 | |
retry_seconds = 1 | |
class Example1(InvokeRetry): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from zato.openerp import OpenERPService | |
class MyOEService(OpenERPService): | |
def handle(self): | |
# Fetch connection to OpenERP | |
oe = self.openerp.get('my-oe-instance') | |
# Grab info on user by their login | |
model = oe.conn.get_model('res.users') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[startup_services] | |
my.service1=Sample payload for a startup service | |
my.service2=file://../../my-payload.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from zato.server.service import Service | |
class MyService(Service): | |
def handle(self): | |
msg = 'My message' | |
conn_name = 'My CRM connection' | |
exchange_name = 'My exchange' | |
routing_key = '' | |
self.outgoing.amqp.send(msg, conn_name, exchange_name, routing_key) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> from uuid import uuid4 | |
>>> from redis import StrictRedis | |
>>> from zato.redis_paginator import ListPaginator | |
>>> | |
>>> conn = StrictRedis() | |
>>> key = 'paginator:{}'.format(uuid4().hex) | |
>>> | |
>>> for x in range(1, 18): | |
... conn.rpush(key, x) | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# stdlib | |
from json import dumps | |
def to_json(model): | |
""" Returns a JSON representation of an SQLAlchemy-backed object. | |
""" | |
json = {} | |
json['fields'] = {} | |
json['pk'] = getattr(model, 'id') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# stdlib | |
from json import dumps | |
# Zato | |
from zato.server.service import Service | |
class MyService(Service): | |
def handle(self): | |
endpoint = self.outgoing.plain_http.get('Get Last Payment') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" | |
xmlns:ns="http://example.com/ns"> | |
<soapenv:Header/> | |
<soapenv:Body> | |
<ns:request> | |
<ns:customer> | |
<ns:id>123</ns:id> | |
<ns:name type="NCHZ">John Brown</ns:name> | |
</ns:customer> | |
</ns:request> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from zato.server.service import Service | |
class MyService(Service): | |
def handle(self): | |
root = self.request.payload | |
self.logger.info(type(root)) | |
self.logger.info(root.customer.id.text) | |
self.logger.info(root.customer.name.text) | |
self.logger.info(root.customer.name.get('type')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
INFO - <type 'lxml.objectify.ObjectifiedElement'> | |
INFO - 123 | |
INFO - John Brown | |
INFO - NCHZ |