当前位置: 首页>>代码示例>>Python>>正文


Python objectify.Element类代码示例

本文整理汇总了Python中lxml.objectify.Element的典型用法代码示例。如果您正苦于以下问题:Python Element类的具体用法?Python Element怎么用?Python Element使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Element类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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()
        
        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

示例2: _get_security_list

def _get_security_list(cluster):
    zato_message = Element('{%s}zato_message' % zato_namespace)
    zato_message.data = Element('data')
    zato_message.data.cluster_id = cluster.id
    
    _, zato_message, _  = invoke_admin_service(cluster, 'zato:security.get-list', zato_message)
    return zato_message
开发者ID:brtsz,项目名称:zato,代码行数:7,代码来源:http_soap.py

示例3: handle

    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 
开发者ID:brtsz,项目名称:zato,代码行数:60,代码来源:jms_wmq.py

示例4: _get_edit_create_message

def _get_edit_create_message(params, prefix=''):
    """ Creates a base document which can be used by both 'edit' and 'create' actions
    for channels and outgoing connections.
    """
    zato_message = Element('{%s}zato_message' % zato_namespace)
    zato_message.data = Element('data')
    zato_message.data.is_internal = False
    zato_message.data.connection = params['connection']
    zato_message.data.transport = params['transport']
    zato_message.data.id = params.get('id')
    zato_message.data.cluster_id = params['cluster_id']
    zato_message.data.name = params[prefix + 'name']
    zato_message.data.is_active = bool(params.get(prefix + 'is_active'))
    zato_message.data.url_path = params[prefix + 'url_path']
    zato_message.data.method = params[prefix + 'method']
    zato_message.data.soap_action = params.get(prefix + 'soap_action', '')
    zato_message.data.soap_version = params.get(prefix + 'soap_version', '')
    zato_message.data.service = params[prefix + 'service']

    security = params[prefix + 'security']
    if security != ZATO_NONE:
        _, sec_def_id = security.split('/')
    else:
        _, sec_def_id = ZATO_NONE, ZATO_NONE
        
    zato_message.data.sec_def_id = sec_def_id

    return zato_message
开发者ID:brtsz,项目名称:zato,代码行数:28,代码来源:http_soap.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')

    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

示例6: to_xml

 def to_xml(self, value, param_name):
     wrapper = Element(param_name)
     for item_value in value:
         xml_item = Element('item')
         wrapper.append(xml_item)
         wrapper.item[-1] = item_value
     return wrapper
开发者ID:grenzi,项目名称:ctakes_exploration,代码行数:7,代码来源:sio.py

示例7: edit

def edit(req):
    
    prefix = 'edit-'

    cluster_id = req.POST['cluster_id']
    tech_account_id = req.POST['id']
    name = req.POST[prefix + 'name']
    is_active = req.POST.get(prefix + 'is_active')
    is_active = True if is_active else False
    
    cluster = req.odb.query(Cluster).filter_by(id=cluster_id).first()

    try:
        zato_message = Element('{%s}zato_message' % zato_namespace)
        zato_message.data = Element('data')
        zato_message.data.cluster_id = cluster_id
        zato_message.data.tech_account_id = tech_account_id
        zato_message.data.name = name
        zato_message.data.is_active = is_active
        
        _, zato_message, soap_response = invoke_admin_service(cluster,
                        'zato:security.tech-account.edit', zato_message)
    
    except Exception, e:
        msg = "Could not update the technical account, e=[{e}]".format(e=format_exc(e))
        logger.error(msg)
        return HttpResponseServerError(msg)
开发者ID:brtsz,项目名称:zato,代码行数:27,代码来源:tech_account.py

示例8: convert

 def convert(self, param, param_name, value, has_simple_io_config, is_xml, date_time_format=None):
     try:
         if any(param_name.startswith(prefix) for prefix in self.bool_parameter_prefixes) or isinstance(param, Boolean):
             value = asbool(value or None) # value can be an empty string and asbool chokes on that
             
         if value and value is not None: # Can be a 0
             if isinstance(param, Boolean):
                 value = asbool(value)
                 
             elif isinstance(param, CSV):
                 value = value.split(',')
                 
             elif isinstance(param, List):
                 if is_xml:
                     # We are parsing XML to create a SIO request
                     if isinstance(value, EtreeElement):
                         return [elem.text for elem in value.getchildren()]
                     
                     # We are producing XML out of an SIO response
                     else:
                         wrapper = Element(param_name)
                         for item_value in value:
                             xml_item = Element('item')
                             wrapper.append(xml_item)
                             wrapper.item[-1] = item_value
                         return wrapper
                         
                 # This is a JSON list
                 return value
             
             elif isinstance(param, Integer):
                 value = int(value)
                 
             elif isinstance(param, Unicode):
                 value = unicode(value)
                 
             elif isinstance(param, UTC):
                 value = value.replace('+00:00', '')
                 
             else:
                 if value and value != ZATO_NONE and has_simple_io_config:
                     if any(param_name==elem for elem in self.int_parameters) or \
                        any(param_name.endswith(suffix) for suffix in self.int_parameter_suffixes):
                         value = int(value)
                         
             if date_time_format and isinstance(value, datetime):
                 value = value.strftime(date_time_format)
                 
         if isinstance(param, CSV) and not value:
             value = []
             
         return value
     except Exception, e:
         msg = 'Conversion error, param:[{}], param_name:[{}], repr(value):[{}], e:[{}]'.format(
             param, param_name, repr(value), format_exc(e))
         logger.error(msg)
         
         raise ZatoException(msg=msg)
开发者ID:systamonster,项目名称:zato,代码行数:58,代码来源:__init__.py

示例9: 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

示例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: _get_edit_create_message

def _get_edit_create_message(params, prefix=''):
    """ Creates a base document which can be used by both 'edit' and 'create' actions.
    """
    zato_message = Element('{%s}zato_message' % zato_namespace)
    zato_message.data = Element('data')
    zato_message.data.id = params.get('id')
    zato_message.data.cluster_id = params['cluster_id']
    zato_message.data.name = params[prefix + 'name']
    zato_message.data.is_active = bool(params.get(prefix + 'is_active'))
    
    return zato_message
开发者ID:brtsz,项目名称:zato,代码行数:11,代码来源:service.py

示例13: _execute

def _execute(server_address, params):
    """ Submits a request for an execution of a job.
    """
    logger.info('About to submit a request for an execution of a job, server_address=[%s], params=[%s]' % (server_address, params))

    zato_message = Element('{%s}zato_message' % zato_namespace)
    zato_message.job = Element('job')
    zato_message.job.name = params['name']
    invoke_admin_service(server_address, 'zato:scheduler.job.execute', etree.tostring(zato_message))

    logger.info('Successfully submitted a request, server_address=[%s], params=[%s]' % (server_address, params))
开发者ID:brtsz,项目名称:zato,代码行数:11,代码来源:scheduler.py

示例14: 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

示例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', '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


注:本文中的lxml.objectify.Element类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。