本文整理汇总了Python中validate.is_boolean函数的典型用法代码示例。如果您正苦于以下问题:Python is_boolean函数的具体用法?Python is_boolean怎么用?Python is_boolean使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_boolean函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: index
def index(req):
zato_clusters = req.odb.query(Cluster).order_by('name').all()
choose_cluster_form = ChooseClusterForm(zato_clusters, req.GET)
cluster_id = req.GET.get('cluster')
items = []
create_form = CreateForm()
edit_form = EditForm(prefix='edit')
if cluster_id and req.method == 'GET':
cluster = req.odb.query(Cluster).filter_by(id=cluster_id).first()
zato_message = Element('{%s}zato_message' % zato_namespace)
zato_message.data = Element('data')
zato_message.data.cluster_id = cluster_id
_, zato_message, soap_response = invoke_admin_service(cluster,
'zato:definition.jms_wmq.get-list', zato_message)
if zato_path('data.definition_list.definition').get_from(zato_message) is not None:
for definition_elem in zato_message.data.definition_list.definition:
id = definition_elem.id.text
name = definition_elem.name.text
host = definition_elem.host.text
port = definition_elem.port.text
queue_manager = definition_elem.queue_manager.text
channel = definition_elem.channel.text
cache_open_send_queues = is_boolean(definition_elem.cache_open_send_queues.text)
cache_open_receive_queues = is_boolean(definition_elem.cache_open_receive_queues.text)
use_shared_connections = is_boolean(definition_elem.use_shared_connections.text)
ssl = is_boolean(definition_elem.ssl.text)
ssl_cipher_spec = definition_elem.ssl_cipher_spec.text
ssl_key_repository = definition_elem.ssl_key_repository.text
needs_mcd = is_boolean(definition_elem.needs_mcd.text)
max_chars_printed = definition_elem.max_chars_printed.text
def_jms_wmq = ConnDefWMQ(id, name, host, port, queue_manager, channel,
cache_open_send_queues, cache_open_receive_queues, use_shared_connections,
ssl, ssl_cipher_spec, ssl_key_repository, needs_mcd, max_chars_printed)
items.append(def_jms_wmq)
return_data = {'zato_clusters':zato_clusters,
'cluster_id':cluster_id,
'choose_cluster_form':choose_cluster_form,
'items':items,
'create_form':create_form,
'edit_form':edit_form,
}
# TODO: Should really be done by a decorator.
if logger.isEnabledFor(TRACE1):
logger.log(TRACE1, 'Returning render_to_response [{0}]'.format(return_data))
return render_to_response('zato/definition/jms_wmq.html', return_data,
context_instance=RequestContext(req))
开发者ID:brtsz,项目名称:zato,代码行数:60,代码来源:jms_wmq.py
示例2: get_data
def get_data(self, session):
return_internal = is_boolean(self.server.fs_server_config.misc.return_internal_objects)
internal_del = is_boolean(self.server.fs_server_config.misc.internal_services_may_be_deleted)
out = []
sl = service_list(session, self.request.input.cluster_id, return_internal, False)
name_filter = self.request.input.get('name_filter')
if name_filter:
name_filter = [elem.strip().lower() for elem in name_filter.strip().split() if elem]
else:
name_filter = [_no_such_service_name] # So it matches nothing
for item in sl:
if self.request.input.name_filter != '*':
skip_item = False
for filter in name_filter:
if not filter in item.name.lower():
skip_item = True
if skip_item:
continue
item.may_be_deleted = internal_del if item.is_internal else True
item.usage = self.server.kvdb.conn.get('{}{}'.format(KVDB.SERVICE_USAGE, item.name)) or 0
out.append(item)
return out
开发者ID:Aayush-Kasurde,项目名称:zato,代码行数:30,代码来源:service.py
示例3: handle
def handle(self, *args, **kwargs):
with closing(self.server.odb.session()) as session:
payload = kwargs.get('payload')
core_params = ['id', 'cluster_id', 'name', 'is_active', 'host', 'port', 'dircache']
core_params = _get_params(payload, core_params, 'data.')
optional_params = ['user', 'acct', 'timeout']
optional_params = _get_params(payload, optional_params, 'data.', default_value=None)
id = core_params['id']
name = core_params['name']
cluster_id = core_params['cluster_id']
existing_one = session.query(OutgoingFTP.id).\
filter(OutgoingFTP.cluster_id==cluster_id).\
filter(OutgoingFTP.name==name).\
filter(OutgoingFTP.id!=core_params['id']).\
first()
if existing_one:
raise Exception('An outgoing FTP connection [{0}] already exists on this cluster'.format(name))
xml_item = Element('out_ftp')
try:
core_params['id'] = int(core_params['id'])
core_params['is_active'] = is_boolean(core_params['is_active'])
core_params['dircache'] = is_boolean(core_params['dircache'])
item = session.query(OutgoingFTP).filter_by(id=id).one()
old_name = item.name
item.name = core_params['name']
item.is_active = core_params['is_active']
item.cluster_id = core_params['cluster_id']
item.dircache = core_params['dircache']
item.host = core_params['host']
item.port = core_params['port']
item.user = optional_params['user']
item.acct = optional_params['acct']
item.timeout = optional_params['timeout']
session.add(item)
session.commit()
xml_item.id = item.id
self.update_facade(core_params, optional_params, old_name)
return ZATO_OK, etree.tostring(xml_item)
except Exception, e:
msg = 'Could not update the outgoing FTP connection, e=[{e}]'.format(e=format_exc(e))
self.logger.error(msg)
session.rollback()
raise
开发者ID:brtsz,项目名称:zato,代码行数:58,代码来源:ftp.py
示例4: handle
def handle(self, *args, **kwargs):
with closing(self.server.odb.session()) as session:
payload = kwargs.get('payload')
request_params = ['cluster_id', 'name', 'host', 'port', 'queue_manager',
'channel', 'cache_open_send_queues', 'cache_open_receive_queues',
'use_shared_connections', 'ssl', 'ssl_cipher_spec',
'ssl_key_repository', 'needs_mcd', 'max_chars_printed']
params = _get_params(payload, request_params, 'data.')
name = params['name']
params['port'] = int(params['port'])
params['cache_open_send_queues'] = is_boolean(params['cache_open_send_queues'])
params['cache_open_receive_queues'] = is_boolean(params['cache_open_receive_queues'])
params['use_shared_connections'] = is_boolean(params['use_shared_connections'])
params['ssl'] = is_boolean(params['ssl'])
params['needs_mcd'] = is_boolean(params['needs_mcd'])
params['max_chars_printed'] = int(params['max_chars_printed'])
cluster_id = params['cluster_id']
cluster = session.query(Cluster).filter_by(id=cluster_id).first()
# Let's see if we already have an object of that name before committing
# any stuff into the database.
existing_one = session.query(ConnDefWMQ).\
filter(ConnDefWMQ.cluster_id==Cluster.id).\
filter(ConnDefWMQ.name==name).\
first()
if existing_one:
raise Exception('JMS WebSphere MQ definition [{0}] already exists on this cluster'.format(name))
created_elem = Element('def_jms_wmq')
try:
def_ = ConnDefWMQ(None, name, params['host'], params['port'], params['queue_manager'],
params['channel'], params['cache_open_send_queues'], params['cache_open_receive_queues'],
params['use_shared_connections'], params['ssl'], params['ssl_cipher_spec'],
params['ssl_key_repository'], params['needs_mcd'], params['max_chars_printed'],
cluster_id)
session.add(def_)
session.commit()
created_elem.id = def_.id
return ZATO_OK, etree.tostring(created_elem)
except Exception, e:
msg = "Could not create a JMS WebSphere MQ definition, e=[{e}]".format(e=format_exc(e))
self.logger.error(msg)
session.rollback()
raise
开发者ID:brtsz,项目名称:zato,代码行数:53,代码来源:jms_wmq.py
示例5: index
def index(req):
zato_clusters = req.odb.query(Cluster).order_by("name").all()
choose_cluster_form = ChooseClusterForm(zato_clusters, req.GET)
cluster_id = req.GET.get("cluster")
items = []
create_form = CreateForm()
edit_form = EditForm(prefix="edit")
change_password_form = ChangePasswordForm()
if cluster_id and req.method == "GET":
cluster = req.odb.query(Cluster).filter_by(id=cluster_id).first()
zato_message = Element("{%s}zato_message" % zato_namespace)
zato_message.data = Element("data")
zato_message.data.cluster_id = cluster_id
_, zato_message, soap_response = invoke_admin_service(cluster, "zato:outgoing.ftp.get-list", zato_message)
if zato_path("data.item_list.item").get_from(zato_message) is not None:
for msg_item in zato_message.data.item_list.item:
id = msg_item.id.text
name = msg_item.name.text
is_active = is_boolean(msg_item.is_active.text)
host = msg_item.host.text if msg_item.host else ""
user = msg_item.user.text if msg_item.user else ""
acct = msg_item.acct.text if msg_item.acct else ""
timeout = msg_item.timeout.text if msg_item.timeout else ""
port = msg_item.port.text if msg_item.port else ""
dircache = is_boolean(msg_item.dircache.text)
item = OutgoingFTP(id, name, is_active, host, user, None, acct, timeout, port, dircache)
items.append(item)
return_data = {
"zato_clusters": zato_clusters,
"cluster_id": cluster_id,
"choose_cluster_form": choose_cluster_form,
"items": items,
"create_form": create_form,
"edit_form": edit_form,
"change_password_form": change_password_form,
}
# TODO: Should really be done by a decorator.
if logger.isEnabledFor(TRACE1):
logger.log(TRACE1, "Returning render_to_response [{0}]".format(return_data))
return render_to_response("zato/outgoing/ftp.html", return_data, context_instance=RequestContext(req))
开发者ID:brtsz,项目名称:zato,代码行数:52,代码来源:ftp.py
示例6: index
def index(req):
zato_clusters = req.odb.query(Cluster).order_by('name').all()
choose_cluster_form = ChooseClusterForm(zato_clusters, req.GET)
cluster_id = req.GET.get('cluster')
items = []
create_form = CreateForm()
edit_form = EditForm(prefix='edit')
if cluster_id and req.method == 'GET':
cluster = req.odb.query(Cluster).filter_by(id=cluster_id).first()
def_ids = _get_def_ids(cluster)
create_form.set_def_id(def_ids)
edit_form.set_def_id(def_ids)
zato_message = Element('{%s}zato_message' % zato_namespace)
zato_message.data = Element('data')
zato_message.data.cluster_id = cluster_id
_, zato_message, soap_response = invoke_admin_service(cluster, 'zato:outgoing.amqp.get-list', zato_message)
if zato_path('data.item_list.item').get_from(zato_message) is not None:
for msg_item in zato_message.data.item_list.item:
id = msg_item.id.text
name = msg_item.name.text
is_active = is_boolean(msg_item.is_active.text)
delivery_mode = int(msg_item.delivery_mode.text)
priority = msg_item.priority.text
content_type = msg_item.content_type.text
content_encoding = msg_item.content_encoding.text
expiration = msg_item.expiration.text
user_id = msg_item.user_id.text
app_id = msg_item.app_id.text
delivery_mode_text = delivery_friendly_name[delivery_mode]
def_name = msg_item.def_name.text
def_id = msg_item.def_id.text
item = OutgoingAMQP(id, name, is_active, delivery_mode, priority,
content_type, content_encoding, expiration, user_id, app_id,
def_id, delivery_mode_text, def_name)
items.append(item)
return_data = {'zato_clusters':zato_clusters,
'cluster_id':cluster_id,
'choose_cluster_form':choose_cluster_form,
'items':items,
'create_form':create_form,
'edit_form':edit_form,
}
# TODO: Should really be done by a decorator.
if logger.isEnabledFor(TRACE1):
logger.log(TRACE1, 'Returning render_to_response [{0}]'.format(return_data))
return render_to_response('zato/outgoing/amqp.html', return_data,
context_instance=RequestContext(req))
开发者ID:brtsz,项目名称:zato,代码行数:60,代码来源:amqp.py
示例7: parse_extra_into_dict
def parse_extra_into_dict(lines):
""" Creates a dictionary out of key=value lines.
"""
_extra = {}
if lines:
extra = ';'.join(lines.splitlines())
for line in extra.split(';'):
original_line = line
if line:
line = line.split('=')
if not len(line) == 2:
raise ValueError('Each line must be a single key=value entry, not [{}]'.format(original_line))
key, value = line
value = value.strip()
try:
value = is_boolean(value)
except VdtTypeError:
# It's cool, not a boolean
pass
try:
value = is_integer(value)
except VdtTypeError:
# OK, not an integer
pass
_extra[key.strip()] = value
return _extra
开发者ID:rafael84,项目名称:zato,代码行数:33,代码来源:util.py
示例8: handle
def handle(self):
input = self.request.input
with closing(self.odb.session()) as session:
try:
service = session.query(Service).filter_by(id=input.id).one()
service.is_active = input.is_active
service.slow_threshold = input.slow_threshold
session.add(service)
session.commit()
input.action = SERVICE.EDIT.value
input.impl_name = service.impl_name
self.broker_client.publish(input)
self.response.payload = service
internal_del = is_boolean(self.server.fs_server_config.misc.internal_services_may_be_deleted)
self.response.payload.may_be_deleted = internal_del if service.is_internal else True
except Exception, e:
msg = 'Could not update the service, e:[{e}]'.format(e=format_exc(e))
self.logger.error(msg)
session.rollback()
raise
开发者ID:Aayush-Kasurde,项目名称:zato,代码行数:26,代码来源:service.py
示例9: details
def details(req, service_id):
zato_clusters = req.odb.query(Cluster).order_by('name').all()
choose_cluster_form = ChooseClusterForm(zato_clusters, req.GET)
cluster_id = req.GET.get('cluster')
service = None
create_form = CreateForm()
edit_form = EditForm(prefix='edit')
if cluster_id and req.method == 'GET':
cluster = req.odb.query(Cluster).filter_by(id=cluster_id).first()
zato_message = Element('{%s}zato_message' % zato_namespace)
zato_message.data = Element('data')
zato_message.data.id = service_id
zato_message.data.cluster_id = cluster_id
_, zato_message, soap_response = invoke_admin_service(cluster, 'zato:service.get-by-id', zato_message)
if zato_path('data.item').get_from(zato_message) is not None:
msg_item = zato_message.data.item
id = msg_item.id.text
name = msg_item.name.text
is_active = is_boolean(msg_item.is_active.text)
impl_name = msg_item.impl_name.text
is_internal = is_boolean(msg_item.is_internal.text)
usage_count = msg_item.usage_count.text
service = Service(id, name, is_active, impl_name, is_internal, None, usage_count)
return_data = {'zato_clusters':zato_clusters,
'service': service,
'cluster_id':cluster_id,
'choose_cluster_form':choose_cluster_form,
'create_form':create_form,
'edit_form':edit_form,
}
# TODO: Should really be done by a decorator.
if logger.isEnabledFor(TRACE1):
logger.log(TRACE1, 'Returning render_to_response [{0}]'.format(return_data))
return render_to_response('zato/service/details.html', return_data, context_instance=RequestContext(req))
开发者ID:brtsz,项目名称:zato,代码行数:46,代码来源:service.py
示例10: index
def index(req):
zato_clusters = req.odb.query(Cluster).order_by('name').all()
choose_cluster_form = ChooseClusterForm(zato_clusters, req.GET)
cluster_id = req.GET.get('cluster')
items = []
create_form = CreateForm()
edit_form = EditForm(prefix='edit')
change_password_form = ChangePasswordForm()
if cluster_id and req.method == 'GET':
cluster = req.odb.query(Cluster).filter_by(id=cluster_id).first()
zato_message = Element('{%s}zato_message' % zato_namespace)
zato_message.data = Element('data')
zato_message.data.cluster_id = cluster_id
_ignored, zato_message, soap_response = invoke_admin_service(cluster,
'zato:security.wss.get-list', zato_message)
if zato_path('data.definition_list.definition').get_from(zato_message) is not None:
for definition_elem in zato_message.data.definition_list.definition:
id = definition_elem.id.text
name = definition_elem.name.text
is_active = is_boolean(definition_elem.is_active.text)
username = definition_elem.username.text
password_type = ZATO_WSS_PASSWORD_TYPES[definition_elem.password_type.text]
password_type_raw = definition_elem.password_type.text
reject_empty_nonce_ts = definition_elem.reject_empty_nonce_ts
reject_stale_username = definition_elem.reject_stale_username
expiry_limit = definition_elem.expiry_limit
nonce_freshness = definition_elem.nonce_freshness
wss = WSSDefinition(id, name, is_active, username, None,
password_type, reject_empty_nonce_ts, reject_stale_username,
expiry_limit, nonce_freshness, password_type_raw=password_type_raw)
items.append(wss)
return_data = {'zato_clusters':zato_clusters,
'cluster_id':cluster_id,
'choose_cluster_form':choose_cluster_form,
'items':items,
'create_form': create_form,
'edit_form': edit_form,
'change_password_form': change_password_form
}
# TODO: Should really be done by a decorator.
if logger.isEnabledFor(TRACE1):
logger.log(TRACE1, 'Returning render_to_response [%s]' % return_data)
return render_to_response('zato/security/wss.html', return_data,
context_instance=RequestContext(req))
开发者ID:brtsz,项目名称:zato,代码行数:56,代码来源:wss.py
示例11: handle
def handle(self, *args, **kwargs):
with closing(self.server.odb.session()) as session:
payload = kwargs.get('payload')
core_params = ['id', 'cluster_id', 'name', 'is_active', 'url_path', 'connection', 'transport']
core_params = _get_params(payload, core_params, 'data.')
optional_params = ['method', 'soap_action', 'soap_version']
optional_params = _get_params(payload, optional_params, 'data.', default_value=None)
id = core_params['id']
name = core_params['name']
cluster_id = core_params['cluster_id']
existing_one = session.query(HTTPSOAP.id).\
filter(HTTPSOAP.cluster_id==cluster_id).\
filter(HTTPSOAP.id!=id).\
filter(HTTPSOAP.name==name).\
first()
if existing_one:
raise Exception('An object of that name [{0}] already exists on this cluster'.format(name))
xml_item = Element('http_soap')
try:
core_params['id'] = int(core_params['id'])
core_params['is_active'] = is_boolean(core_params['is_active'])
item = session.query(HTTPSOAP).filter_by(id=id).one()
item.name = core_params['name']
item.is_active = core_params['is_active']
item.url_path = core_params['url_path']
item.connection = core_params['connection']
item.transport = core_params['transport']
item.cluster_id = core_params['cluster_id']
item.method = optional_params.get('method')
item.soap_action = optional_params.get('soap_action')
item.soap_version = optional_params.get('soap_version')
session.add(item)
session.commit()
xml_item.id = item.id
return ZATO_OK, etree.tostring(xml_item)
except Exception, e:
msg = 'Could not update the object, e=[{e}]'.format(e=format_exc(e))
self.logger.error(msg)
session.rollback()
raise
开发者ID:brtsz,项目名称:zato,代码行数:55,代码来源:http_soap.py
示例12: _edit_create_response
def _edit_create_response(verb, service_elem):
return_data = {'id': str(service_elem.id),
'is_internal':is_boolean(service_elem.is_internal.text),
'impl_name':service_elem.impl_name.text,
'usage_count':str(service_elem.usage_count.text),
'message': 'Successfully {0} the service [{1}]'.format(verb, service_elem.name.text),
}
print(dumps(return_data))
return HttpResponse(dumps(return_data), mimetype='application/javascript')
开发者ID:brtsz,项目名称:zato,代码行数:12,代码来源:service.py
示例13: handle
def handle(self, *args, **kwargs):
with closing(self.server.odb.session()) as session:
payload = kwargs.get('payload')
core_params = ['id', 'cluster_id', 'name', 'is_active', 'address', 'socket_type']
core_params = _get_params(payload, core_params, 'data.')
id = core_params['id']
name = core_params['name']
cluster_id = core_params['cluster_id']
existing_one = session.query(OutgoingZMQ.id).\
filter(OutgoingZMQ.cluster_id==cluster_id).\
filter(OutgoingZMQ.name==name).\
filter(OutgoingZMQ.id!=core_params['id']).\
first()
if existing_one:
raise Exception('An outgoing ZeroMQ connection [{0}] already exists on this cluster'.format(name))
xml_item = Element('out_zmq')
try:
core_params['id'] = int(core_params['id'])
core_params['is_active'] = is_boolean(core_params['is_active'])
item = session.query(OutgoingZMQ).filter_by(id=id).one()
old_name = item.name
item.name = name
item.is_active = core_params['is_active']
item.address = core_params['address']
item.socket_type = core_params['socket_type']
session.add(item)
session.commit()
xml_item.id = item.id
core_params['action'] = OUTGOING.ZMQ_EDIT
core_params['old_name'] = old_name
self.broker_client.send_json(core_params, msg_type=MESSAGE_TYPE.TO_ZMQ_CONNECTOR_SUB)
return ZATO_OK, etree.tostring(xml_item)
except Exception, e:
msg = 'Could not update the outgoing ZeroMQ connection, e=[{e}]'.format(e=format_exc(e))
self.logger.error(msg)
session.rollback()
raise
开发者ID:brtsz,项目名称:zato,代码行数:52,代码来源:zmq.py
示例14: get_data
def get_data(self, session):
out = []
sl = service_list(session, self.request.input.cluster_id, False)
internal_del = is_boolean(self.server.fs_server_config.misc.internal_services_may_be_deleted)
for item in sl:
item.may_be_deleted = internal_del if item.is_internal else True
item.usage = self.server.kvdb.conn.get('{}{}'.format(KVDB.SERVICE_USAGE, item.name)) or 0
out.append(item)
return out
开发者ID:dsuch,项目名称:zato,代码行数:13,代码来源:service.py
示例15: handle
def handle(self, *args, **kwargs):
with closing(self.server.odb.session()) as session:
payload = kwargs.get('payload')
core_params = ['id', 'cluster_id', 'name', 'is_active', 'prefix', 'separator', 'key_sync_timeout']
core_params = _get_params(payload, core_params, 'data.')
id = core_params['id']
name = core_params['name']
cluster_id = core_params['cluster_id']
existing_one = session.query(OutgoingS3.id).\
filter(OutgoingS3.cluster_id==cluster_id).\
filter(OutgoingS3.name==name).\
filter(OutgoingS3.id!=core_params['id']).\
first()
if existing_one:
raise Exception('An outgoing S3 connection [{0}] already exists on this cluster'.format(name))
xml_item = Element('out_s3')
try:
core_params['id'] = int(core_params['id'])
core_params['is_active'] = is_boolean(core_params['is_active'])
item = session.query(OutgoingS3).filter_by(id=id).one()
old_name = item.name
item.name = name
item.is_active = core_params['is_active']
item.prefix = core_params['prefix']
item.separator = core_params['separator']
item.key_sync_timeout = core_params['key_sync_timeout']
session.add(item)
session.commit()
xml_item.id = item.id
return ZATO_OK, etree.tostring(xml_item)
except Exception, e:
msg = 'Could not update the outgoing S3 connection, e=[{e}]'.format(e=format_exc(e))
self.logger.error(msg)
session.rollback()
raise
开发者ID:brtsz,项目名称:zato,代码行数:49,代码来源:s3.py
示例16: index
def index(req):
""" Lists all the SQL connections.
"""
items = []
create_form = CreateForm()
edit_form = EditForm(prefix='edit')
change_password_form = ChangePasswordForm()
if req.zato.cluster_id and req.method == 'GET':
zato_message, soap_response = invoke_admin_service(req.zato.cluster, 'zato:outgoing.sql.get-list', {'cluster_id': req.zato.cluster_id})
if zato_path('response.item_list.item').get_from(zato_message) is not None:
for msg_item in zato_message.response.item_list.item:
id = msg_item.id.text
name = msg_item.name.text
is_active = is_boolean(msg_item.is_active.text)
engine = msg_item.engine.text if msg_item.engine else ''
host = msg_item.host.text if msg_item.host else ''
port = msg_item.port.text if msg_item.port else ''
db_name = msg_item.db_name.text if msg_item.db_name else ''
username = msg_item.username.text if msg_item.username else ''
pool_size = msg_item.pool_size.text if msg_item.pool_size else ''
extra = msg_item.extra.text if msg_item.extra else ''
item = SQLConnectionPool()
item.id = id
item.name = name
item.is_active = is_active
item.engine = engine
item.engine_text = odb_engine_friendly_name[engine]
item.host = host
item.port = port
item.db_name = db_name
item.username = username
item.pool_size = pool_size
item.extra = extra
items.append(item)
return_data = {'zato_clusters':req.zato.clusters,
'cluster_id':req.zato.cluster_id,
'choose_cluster_form':req.zato.choose_cluster_form,
'items':items,
'create_form':create_form,
'edit_form':edit_form,
'change_password_form': change_password_form
}
return TemplateResponse(req, 'zato/outgoing/sql.html', return_data)
开发者ID:dsuch,项目名称:zato,代码行数:49,代码来源:sql.py
示例17: index
def index(req):
zato_clusters = req.odb.query(Cluster).order_by('name').all()
choose_cluster_form = ChooseClusterForm(zato_clusters, req.GET)
cluster_id = req.GET.get('cluster')
items = []
create_form = CreateForm()
edit_form = EditForm(prefix='edit')
change_password_form = ChangePasswordForm()
if cluster_id and req.method == 'GET':
cluster = req.odb.query(Cluster).filter_by(id=cluster_id).first()
zato_message = Element('{%s}zato_message' % zato_namespace)
zato_message.data = Element('data')
zato_message.data.cluster_id = cluster_id
_, zato_message, soap_response = invoke_admin_service(cluster,
'zato:security.tech-account.get-list', zato_message)
if zato_path('data.definition_list.definition').get_from(zato_message) is not None:
for definition_elem in zato_message.data.definition_list.definition:
id = definition_elem.id.text
name = definition_elem.name.text
is_active = is_boolean(definition_elem.is_active.text)
account = TechnicalAccount(id, name, is_active=is_active)
items.append(account)
return_data = {'zato_clusters':zato_clusters,
'cluster_id':cluster_id,
'choose_cluster_form':choose_cluster_form,
'items':items,
'create_form':create_form,
'edit_form':edit_form,
'change_password_form':change_password_form
}
# TODO: Should really be done by a decorator.
if logger.isEnabledFor(TRACE1):
logger.log(TRACE1, 'Returning render_to_response [{0}]'.format(return_data))
return render_to_response('zato/security/tech-account.html', return_data,
context_instance=RequestContext(req))
开发者ID:brtsz,项目名称:zato,代码行数:48,代码来源:tech_account.py
示例18: __init__
def __init__(self, name, config, config_no_sensitive):
self.name = name
self.config = config
self.logger = getLogger(self.__class__.__name__)
# Safe for printing out to logs, any sensitive data has been shadowed
self.config_no_sensitive = config_no_sensitive
_extra = {}
extra = self.config.get('extra') # Will be None at times
if extra:
extra = ';'.join(extra.splitlines())
for line in extra.split(';'):
original_line = line
if line:
line = line.split('=')
if not len(line) == 2:
raise ValueError('Each line must be a single key=value entry, not [{}]'.format(original_line))
key, value = line
value = value.strip()
try:
value = is_boolean(value)
except VdtTypeError:
# It's cool, not a boolean
pass
try:
value = is_integer(value)
except VdtTypeError:
# OK, not an integer
pass
_extra[key.strip()] = value
engine_url = engine_def.format(**config)
self.engine = create_engine(engine_url, pool_size=int(config['pool_size']), **_extra)
event.listen(self.engine, 'checkin', self.on_checkin)
event.listen(self.engine, 'checkout', self.on_checkout)
event.listen(self.engine, 'connect', self.on_connect)
event.listen(self.engine, 'first_connect', self.on_first_connect)
开发者ID:Adniel,项目名称:zato,代码行数:43,代码来源:sql.py
示例19: handle
def handle(self, *args, **kwargs):
with closing(self.server.odb.session()) as session:
payload = kwargs.get("payload")
request_params = ["cluster_id", "tech_account_id", "name", "is_active"]
params = _get_params(payload, request_params, "data.")
cluster_id = params["cluster_id"]
tech_account_id = params["tech_account_id"]
name = params["name"]
existing_one = (
session.query(TechnicalAccount)
.filter(Cluster.id == cluster_id)
.filter(TechnicalAccount.name == name)
.filter(TechnicalAccount.id != tech_account_id)
.first()
)
if existing_one:
raise Exception("Technical account [{0}] already exists on this cluster".format(name))
tech_account = session.query(TechnicalAccount).filter(TechnicalAccount.id == tech_account_id).one()
old_name = tech_account.name
tech_account.name = name
tech_account.is_active = is_boolean(params["is_active"])
tech_account_elem = Element("tech_account")
try:
session.add(tech_account)
session.commit()
tech_account_elem.id = tech_account.id
except Exception, e:
msg = "Could not update the technical account, e=[{e}]".format(e=format_exc(e))
self.logger.error(msg)
session.rollback()
raise
else:
开发者ID:brtsz,项目名称:zato,代码行数:43,代码来源:tech_account.py
示例20: parse_extra_into_dict
def parse_extra_into_dict(lines, convert_bool=True):
""" Creates a dictionary out of key=value lines.
"""
_extra = {}
if lines:
extra = ';'.join(lines.splitlines())
for line in extra.split(';'):
original_line = line
if line:
line = line.split('=')
if not len(line) == 2:
raise ValueError('Each line must be a single key=value entry, not [{}]'.format(original_line))
key, value = line
value = value.strip()
if convert_bool:
try:
value = is_boolean(value)
except VdtTypeError:
# It's cool, not a boolean
pass
try:
value = is_integer(value)
except VdtTypeError:
# OK, not an integer
pass
# Could be a dict or another simple type then
try:
value = literal_eval(value)
except Exception:
pass
# OK, let's just treat it as string
_extra[key.strip()] = value
return _extra
开发者ID:CptJason,项目名称:zato,代码行数:41,代码来源:util.py
注:本文中的validate.is_boolean函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论