本文整理汇总了Python中lxml.objectify.Element.id方法的典型用法代码示例。如果您正苦于以下问题:Python Element.id方法的具体用法?Python Element.id怎么用?Python Element.id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lxml.objectify.Element
的用法示例。
在下文中一共展示了Element.id方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handle
# 需要导入模块: from lxml.objectify import Element [as 别名]
# 或者: from lxml.objectify.Element import id [as 别名]
def handle(self, *args, **kwargs):
with closing(self.server.odb.session()) as session:
payload = kwargs.get('payload')
core_params = ['cluster_id', 'name', 'is_active', 'def_id', 'delivery_mode', 'priority']
core_params = _get_params(payload, core_params, 'data.')
optional_params = ['expiration']
optional_params = _get_params(payload, optional_params, 'data.', default_value=None)
priority = int(core_params['priority'])
if not(priority >= 0 and priority <= 9):
msg = 'Priority should be between 0 and 9, not [{0}]'.format(repr(priority))
raise ValueError(msg)
name = core_params['name']
cluster_id = core_params['cluster_id']
core_params['def_id'] = int(core_params['def_id'])
existing_one = session.query(OutgoingWMQ.id).\
filter(ConnDefWMQ.cluster_id==cluster_id).\
filter(OutgoingWMQ.def_id==ConnDefWMQ.id).\
filter(OutgoingWMQ.name==name).\
first()
if existing_one:
raise Exception('An outgoing JMS WebSphere MQ connection [{0}] already exists on this cluster'.format(name))
created_elem = Element('out_jms_wmq')
try:
core_params['delivery_mode'] = int(core_params['delivery_mode'])
core_params['priority'] = int(core_params['priority'])
core_params['is_active'] = is_boolean(core_params['is_active'])
item = OutgoingWMQ()
item.name = core_params['name']
item.is_active = core_params['is_active']
item.def_id = core_params['def_id']
item.delivery_mode = core_params['delivery_mode']
item.priority = core_params['priority']
item.expiration = optional_params['expiration']
session.add(item)
session.commit()
created_elem.id = item.id
start_connector(self.server.repo_location, item.id, item.def_id)
return ZATO_OK, etree.tostring(created_elem)
except Exception, e:
msg = 'Could not create an outgoing JMS WebSphere MQ connection, e=[{e}]'.format(e=format_exc(e))
self.logger.error(msg)
session.rollback()
raise
示例2: handle
# 需要导入模块: from lxml.objectify import Element [as 别名]
# 或者: from lxml.objectify.Element import id [as 别名]
def handle(self, *args, **kwargs):
params = _get_params(kwargs.get('payload'), ['cluster_id', 'connection', 'transport'], 'data.')
with closing(self.server.odb.session()) as session:
item_list = Element('item_list')
db_items = http_soap_list(session, params['cluster_id'], params['connection'], params['transport'])
for db_item in db_items:
item = Element('item')
item.id = db_item.id
item.name = db_item.name
item.is_active = db_item.is_active
item.is_internal = db_item.is_internal
item.url_path = db_item.url_path
item.method = db_item.method
item.soap_action = db_item.soap_action
item.soap_version = db_item.soap_version
item.service_id = db_item.service_id
item.service_name = db_item.service_name
item.security_id = db_item.security_id
item.security_name = db_item.security_name
item.security_def_type = db_item.security_def_type
item_list.append(item)
return ZATO_OK, etree.tostring(item_list)
示例3: handle
# 需要导入模块: from lxml.objectify import Element [as 别名]
# 或者: from lxml.objectify.Element import id [as 别名]
def handle(self, *args, **kwargs):
with closing(self.server.odb.session()) as session:
params = _get_params(kwargs.get('payload'), ['cluster_id'], 'data.')
definition_list = Element('definition_list')
definitions = job_list(session, params['cluster_id'])
for definition in definitions:
definition_elem = Element('definition')
definition_elem.id = definition.id
definition_elem.name = definition.name
definition_elem.is_active = definition.is_active
definition_elem.job_type = definition.job_type
definition_elem.start_date = definition.start_date
definition_elem.extra = definition.extra.decode('utf-8')
definition_elem.service_id = definition.service_id
definition_elem.service_name = definition.service_name.decode('utf-8')
definition_elem.weeks = definition.weeks if definition.weeks else ''
definition_elem.days = definition.days if definition.days else ''
definition_elem.hours = definition.hours if definition.hours else ''
definition_elem.minutes = definition.minutes if definition.minutes else ''
definition_elem.seconds = definition.seconds if definition.seconds else ''
definition_elem.repeats = definition.repeats if definition.repeats else ''
definition_elem.cron_definition = (definition.cron_definition.decode('utf-8') if
definition.cron_definition else '')
definition_list.append(definition_elem)
return ZATO_OK, etree.tostring(definition_list)
示例4: handle
# 需要导入模块: from lxml.objectify import Element [as 别名]
# 或者: from lxml.objectify.Element import id [as 别名]
def handle(self, *args, **kwargs):
params = _get_params(kwargs.get('payload'), ['cluster_id'], 'data.')
with closing(self.server.odb.session()) as session:
item_list = Element('item_list')
db_items = out_amqp_list(session, params['cluster_id'])
for db_item in db_items:
item = Element('item')
item.id = db_item.id
item.name = db_item.name
item.is_active = db_item.is_active
item.delivery_mode = db_item.delivery_mode
item.priority = db_item.priority
item.content_type = db_item.content_type
item.content_encoding = db_item.content_encoding
item.expiration = db_item.expiration
item.user_id = db_item.user_id
item.app_id = db_item.app_id
item.def_name = db_item.def_name
item.def_id = db_item.def_id
item_list.append(item)
return ZATO_OK, etree.tostring(item_list)
示例5: handle
# 需要导入模块: from lxml.objectify import Element [as 别名]
# 或者: from lxml.objectify.Element import id [as 别名]
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
示例6: handle
# 需要导入模块: from lxml.objectify import Element [as 别名]
# 或者: from lxml.objectify.Element import id [as 别名]
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
示例7: handle
# 需要导入模块: from lxml.objectify import Element [as 别名]
# 或者: from lxml.objectify.Element import id [as 别名]
def handle(self, *args, **kwargs):
with closing(self.server.odb.session()) as session:
payload = kwargs.get('payload')
request_params = ['id', 'is_active', 'name', 'username', 'password_type',
'reject_empty_nonce_ts', 'reject_stale_username',
'expiry_limit', 'nonce_freshness', 'cluster_id']
new_params = _get_params(payload, request_params, 'data.')
def_id = new_params['id']
name = new_params['name']
cluster_id = new_params['cluster_id']
existing_one = session.query(WSSDefinition).\
filter(Cluster.id==cluster_id).\
filter(WSSDefinition.name==name).\
filter(WSSDefinition.id != def_id).\
first()
if existing_one:
raise Exception('WS-Security definition [{0}] already exists on this cluster'.format(name))
wss_elem = Element('wss')
try:
wss = session.query(WSSDefinition).filter_by(id=def_id).one()
old_name = wss.name
wss.name = name
wss.is_active = new_params['is_active']
wss.username = new_params['username']
wss.password_type = new_params['password_type']
wss.reject_empty_nonce_ts = new_params['reject_empty_nonce_ts']
wss.reject_stale_username = new_params['reject_stale_username']
wss.expiry_limit = new_params['expiry_limit']
wss.nonce_freshness = new_params['nonce_freshness']
session.add(wss)
session.commit()
wss_elem.id = wss.id
except Exception, e:
msg = "Could not update the WS-Security definition, e=[{e}]".format(e=format_exc(e))
self.logger.error(msg)
session.rollback()
raise
else:
示例8: handle
# 需要导入模块: from lxml.objectify import Element [as 别名]
# 或者: from lxml.objectify.Element import id [as 别名]
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
示例9: handle
# 需要导入模块: from lxml.objectify import Element [as 别名]
# 或者: from lxml.objectify.Element import id [as 别名]
def handle(self, *args, **kwargs):
with closing(self.server.odb.session()) as session:
definition_list = Element("definition_list")
params = _get_params(kwargs.get("payload"), ["cluster_id"], "data.")
definitions = tech_acc_list(session, params["cluster_id"])
for definition in definitions:
definition_elem = Element("definition")
definition_elem.id = definition.id
definition_elem.name = definition.name
definition_elem.is_active = definition.is_active
definition_list.append(definition_elem)
return ZATO_OK, etree.tostring(definition_list)
示例10: handle
# 需要导入模块: from lxml.objectify import Element [as 别名]
# 或者: from lxml.objectify.Element import id [as 别名]
def handle(self, *args, **kwargs):
params = _get_params(kwargs.get('payload'), ['id', 'cluster_id'], 'data.')
with closing(self.server.odb.session()) as session:
db_item = service(session, params['cluster_id'], params['id'])
item = Element('item')
item.id = db_item.id
item.name = db_item.name
item.is_active = db_item.is_active
item.impl_name = db_item.impl_name
item.is_internal = db_item.is_internal
item.usage_count = 'TODO getbyid'
return ZATO_OK, etree.tostring(item)
示例11: handle
# 需要导入模块: from lxml.objectify import Element [as 别名]
# 或者: from lxml.objectify.Element import id [as 别名]
def handle(self, *args, **kwargs):
with closing(self.server.odb.session()) as session:
try:
payload = kwargs.get('payload')
request_params = ['id', 'is_active', 'name', 'username', 'domain',
'cluster_id']
new_params = _get_params(payload, request_params, 'data.')
def_id = new_params['id']
name = new_params['name']
cluster_id = new_params['cluster_id']
existing_one = session.query(HTTPBasicAuth).\
filter(Cluster.id==cluster_id).\
filter(HTTPBasicAuth.name==name).\
filter(HTTPBasicAuth.id != def_id).\
first()
if existing_one:
raise Exception('HTTP Basic Auth definition [{0}] already exists on this cluster'.format(name))
auth_elem = Element('basic_auth')
definition = session.query(HTTPBasicAuth).filter_by(id=def_id).one()
old_name = definition.name
definition.name = name
definition.is_active = new_params['is_active']
definition.username = new_params['username']
definition.domain = new_params['domain']
session.add(definition)
session.commit()
auth_elem.id = definition.id
except Exception, e:
msg = "Could not update the HTTP Basic Auth definition, e=[{e}]".format(e=format_exc(e))
self.logger.error(msg)
session.rollback()
raise
else:
示例12: handle
# 需要导入模块: from lxml.objectify import Element [as 别名]
# 或者: from lxml.objectify.Element import id [as 别名]
def handle(self, *args, **kwargs):
with closing(self.server.odb.session()) as session:
params = _get_params(kwargs.get('payload'), ['cluster_id'], 'data.')
definition_list = Element('definition_list')
pairs = (('basic_auth', basic_auth_list),
('tech_acc', tech_acc_list),
('wss_username_password', wss_list))
for def_type, meth in pairs:
definitions = meth(session, params['cluster_id'])
for definition in definitions:
definition_elem = Element('definition')
definition_elem.id = definition.id
definition_elem.name = definition.name
definition_elem.def_type = def_type
definition_list.append(definition_elem)
return ZATO_OK, etree.tostring(definition_list)