Skip to content

Instantly share code, notes, and snippets.

from sqlalchemy import create_engine
config = {
'username': 'zato1',
'password': 'zato1',
'database': 'zato1',
}
url = 'postgresql+pg8000://{username}:{password}@localhost/{database}'.format(**config)
engine = create_engine(url, echo=True)
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
config = {
'username': 'zato1',
'password': 'zato1',
'database': 'zato1',
}
from zato.server.service import Service
class GetFullSecurityDefinitions(Service):
def handle(self):
for value in self.worker_store.request_dispatcher.url_data.basic_auth_config.values():
self.logger.info('\n%s', value.config)
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
# gevent
from gevent import sleep
# Zato
from zato.common.broker_message import SERVICE
from zato.common.util import new_cid
@dsuch
dsuch / client.py
Created May 22, 2015 11:19
Obtaining self.broker_client without self
# stdlib
import gc
# Zato
from zato.common.broker_message import SERVICE
from zato.common.util import new_cid
from zato.server.base.parallel import ParallelServer
from zato.server.service import Integer, Service
@dsuch
dsuch / zato_pymqi.py
Created April 21, 2015 11:02
PyMQI directly under Zato
from zato.server.service import Service
class MyService(Service):
def handle(self):
import pymqi
queue_manager = 'IDM'
@dsuch
dsuch / sqlserver.txt
Created March 23, 2015 16:39
SQL Server + Zato
I have solved the problem by modifying these lines in zato. I do not know if this has been the best method , but it has worked to give ZATO connectivity with SqlServer.
First of all , I installed and configured FreeTDS and unixODBC (http://blog.tryolabs.com/2012/06/25/connecting-sql-server-database-python-under-ubuntu/)
Then:
In /opt/zato/2.0.0/local/zato-common/src/zato/common/init.py,
add 'mssql+pyodbc': 'SELECT 1',
to var: ping_queries
In /opt/zato/2.0.0/zato-web-admin/src/zato/admin/zato_settings.py,
@dsuch
dsuch / orders.py
Last active August 29, 2015 14:15
How to use async callbacks
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
# Zato
from zato.server.service import Service
ORDER_CACHE_PREFIX = 'order.{}'
class AcceptOrder(Service):
@dsuch
dsuch / dicts1.py
Created February 4, 2015 20:37
Using KVDB get-key-list and get-value-list
from zato.server.service import Service
class Dicts(Service):
def handle(self):
service = 'zato.kvdb.data-dict.dictionary.get-key-list'
request = {'system':'System'}
response = self.invoke(service, request)
@dsuch
dsuch / getcust2.py
Created February 3, 2015 19:17
customer.get2
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
# stdlib
from random import choice
# Zato
from zato.server.service import Service