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


Python Element.append方法代码示例

本文整理汇总了Python中suds.sax.element.Element.append方法的典型用法代码示例。如果您正苦于以下问题:Python Element.append方法的具体用法?Python Element.append怎么用?Python Element.append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在suds.sax.element.Element的用法示例。


在下文中一共展示了Element.append方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from suds.sax.element import Element [as 别名]
# 或者: from suds.sax.element.Element import append [as 别名]
	def main(self):
		items = self.adsm_lists.service.GetListItems(self.args.list, self.args.view).listitems.data.row

		method_idx = 1
		batch = Element('Batch')\
		       .append(Attribute('OnError', 'Continue'))\
		       .append(Attribute('ListVersion', 1))

		def update(b):
			if not self.args.d:
				updates = Element('ns1:updates').append(b)
				print self.adsm_lists.service.UpdateListItems(listName=self.args.list, updates=updates)

		for item in items:
			method = Element('Method')\
			        .append(Attribute('ID', method_idx))\
			        .append(Attribute('Cmd', 'Delete'))\
			        .append(Element('Field')\
			          .append(Attribute('Name', 'ID'))\
			          .setText(item['_ows_ID']))
			batch.append(method)
			print method
			method_idx += 1

			if len(batch) > 20:
				update(batch)
				batch.detachChildren()

		if len(batch) > 0:
			update(batch)
开发者ID:kinghuang,项目名称:itsm,代码行数:32,代码来源:delete-items.py

示例2: init_client

# 需要导入模块: from suds.sax.element import Element [as 别名]
# 或者: from suds.sax.element.Element import append [as 别名]
def init_client(faults=True):
    ENTREPRISE_WSDL = getattr(settings,     'SALESFORCE_ENTERPRISE_WSDL')
    DJANGO_WSDL = getattr(settings,         'SALESFORCE_DJANGO_WSDL')
    SALESFORCE_ENDPOINT = getattr(settings, 'SALESFORCE_ENDPOINT')
    
    SALESFORCE_USER = getattr(settings,     'SALESFORCE_USER')
    SALESFORCE_PASS = getattr(settings,     'SALESFORCE_PASS')
    SALESFORCE_TOKEN = getattr(settings,    'SALESFORCE_TOKEN')
    
    # Use the entreprise login to get a session id
    entreprise_client = Client(ENTREPRISE_WSDL)
    #entreprise_client.wsdl.url = SALESFORCE_ENDPOINT
    
    login_result = entreprise_client.service.login(SALESFORCE_USER, 
                                                   SALESFORCE_PASS+SALESFORCE_TOKEN)
    

    # our client specific methods are in this specific       
   
    # NOTE we have to create the endpoint url using values from the serverUrl in the loginResponse plus 
    # the djangoAdapter schema
    
    options = urlparse(login_result.serverUrl)
    
    #DJANGO_SF_ENDPOINT = '%s://%s/services/Soap/class/dJangoAdapter' % (options.scheme, options.netloc)
    
    django_client = Client(DJANGO_WSDL, location = SALESFORCE_ENDPOINT, faults=faults)
         
    session_name_space = ('djan', 'http://soap.sforce.com/schemas/class/dJangoAdapter')
    session = Element('sessionId').setText(login_result.sessionId)
    wrapper = Element('SessionHeader')
    wrapper.append(session)
    
    django_client.set_options(soapheaders=wrapper)
    return django_client
开发者ID:jason5001001,项目名称:savings-champion,代码行数:37,代码来源:salesforce_sync.py

示例3: marshalled

# 需要导入模块: from suds.sax.element import Element [as 别名]
# 或者: from suds.sax.element.Element import append [as 别名]
    def marshalled(self, context):
        userid = self.userid
        timestamp = rfc3339(datetime.datetime.now())
        secret = self.secret
        signature = sign(secret, timestamp+userid)
        auth = self.authfragment % locals()
        envelope = context.envelope

        #Set the right ns prefixes
        envelope.nsprefixes[ 'ns1' ] = envelope.nsprefixes[ 'ns0' ]
        envelope.clearPrefix( 'ns0' )

        #Add our auth to the header element
        header = envelope.getChild('Header')
        authns = Element( 'ns1:AuthenticationHeader' )
        authns.append( Element( 'mktowsUserId' ).setText(self.userid) )
        authns.append( Element( 'requestSignature' ).setText(signature) )
        authns.append( Element( 'requestTimestamp' ).setText(timestamp) )
        header.append( authns )

        #Set the proper body prefixes
        body = envelope.getChild( 'Body' )
        body.prefix = 'SOAP-ENV'
        body.children[0].prefix = 'ns1'

        if self.debug:
            with open("/tmp/envelope.txt","w") as f: f.write(envelope.str())
开发者ID:sirsgriffin,项目名称:pymarketo,代码行数:29,代码来源:client.py

示例4: encryptMessage

# 需要导入模块: from suds.sax.element import Element [as 别名]
# 或者: from suds.sax.element.Element import append [as 别名]
    def encryptMessage(self, env, use_encrypted_header=False, second_pass=False):
        encrypted_parts = second_pass and self.second_pass_encrypted_parts or self.encrypted_parts
        elements_to_encrypt = []
        encrypted_headers = []

        for elements_to_encrypt_func in encrypted_parts:
            addl_elements = elements_to_encrypt_func(env)
            if addl_elements[0] is None:
                continue
            if not isinstance(addl_elements[0], list):
                addl_elements = ([addl_elements[0]], addl_elements[1])
            for element in addl_elements[0]:
                if element not in elements_to_encrypt:
                    if element[0].parent.match("Header") and use_encrypted_header:
                        enc_hdr = Element("EncryptedHeader", ns=wsse11ns)
                        element[0].parent.replaceChild(element[0], enc_hdr)
                        enc_hdr.append(element[0])
                        elements_to_encrypt.append((enc_hdr, "Content"))
                        encrypted_headers.append(enc_hdr)
                    else:
                        elements_to_encrypt.append((element, addl_elements[1]))

        ref_list = xmlsec.encryptMessage(
            self.cert, self.symmetricKey, elements_to_encrypt, "#" + self.keyId, self.keyReference, self.keyTransport
        )

        for enc_hdr in encrypted_headers:
            enc_hdr.set("wsu:Id", enc_hdr[0].get("Id"))
            enc_hdr[0].unset("Id")
        if self.includeRefList:
            self.encryptedKey.append(ref_list)
            return self.encryptedKey
        else:
            return (self.encryptedKey, ref_list)
开发者ID:evandeaubl,项目名称:suds,代码行数:36,代码来源:__init__.py

示例5: _ensure_service

# 需要导入模块: from suds.sax.element import Element [as 别名]
# 或者: from suds.sax.element.Element import append [as 别名]
    def _ensure_service(self):
        """Trying to add service if no one definied explicitly. EWS workaround."""
        if (self.services
            or not self.bindings
            or len(self.bindings) > 1
            or not self.bindings.keys()[0][0].startswith('Exchange')):
            return

        service = Element('service')
        service.set('name', 'ExchangeServices')

        port = Element('port', service)
        port.set('name', 'ExchangeServicePort')
        port.set('binding', self.bindings.keys()[0][0])

        address = Element('address', port)
        address.set('location', urljoin(self.url, 'exchange.asmx'))

        port.append(address)
        service.append(port)

        service = Factory.create(service, self)
        service.resolve(self)

        self.children.append(service)
        self.services.append(service)

        log.debug('Auto created service: %s', service)
开发者ID:emergence,项目名称:suds-philpem,代码行数:30,代码来源:wsdl.py

示例6: xml

# 需要导入模块: from suds.sax.element import Element [as 别名]
# 或者: from suds.sax.element.Element import append [as 别名]
 def xml(self):
     root = Element("Timestamp", ns=wsuns)
     created = Element('Created', ns=wsuns)
     created.setText(str(DateTime(self.created)))
     expires = Element('Expires', ns=wsuns)
     expires.setText(str(DateTime(self.expires)))
     root.append(created)
     root.append(expires)
     return root
开发者ID:BhallaLab,项目名称:moose-gui,代码行数:11,代码来源:wsse.py

示例7: xml

# 需要导入模块: from suds.sax.element import Element [as 别名]
# 或者: from suds.sax.element.Element import append [as 别名]
 def xml(self):
     root = Element("Timestamp", ns=wsuns)
     # xsd:datetime format does not have fractional seconds
     created = Element("Created", ns=wsuns)
     created.setText(str(UTC(self.created - timedelta(microseconds=self.created.microsecond))))
     expires = Element("Expires", ns=wsuns)
     expires.setText(str(UTC(self.expires - timedelta(microseconds=self.expires.microsecond))))
     root.append(created)
     root.append(expires)
     return root
开发者ID:evandeaubl,项目名称:suds,代码行数:12,代码来源:__init__.py

示例8: body

# 需要导入模块: from suds.sax.element import Element [as 别名]
# 或者: from suds.sax.element.Element import append [as 别名]
 def body(self, content):
     """
     Build the B{<Body/>} for an soap outbound message.
     @param content: The body content.
     @type content: L{Element}
     @return: the soap body fragment.
     @rtype: L{Element}
     """
     body = Element('Body', ns=envns)
     body.append(content)
     return body
开发者ID:propars,项目名称:python-suds,代码行数:13,代码来源:binding.py

示例9: header

# 需要导入模块: from suds.sax.element import Element [as 别名]
# 或者: from suds.sax.element.Element import append [as 别名]
 def header(self, content):
     """
     Build the B{<Body/>} for an soap outbound message.
     @param content: The header content.
     @type content: L{Element}
     @return: the soap body fragment.
     @rtype: L{Element}
     """
     header = Element('Header', ns=envns)
     header.append(content)
     return header
开发者ID:propars,项目名称:python-suds,代码行数:13,代码来源:binding.py

示例10: xml

# 需要导入模块: from suds.sax.element import Element [as 别名]
# 或者: from suds.sax.element.Element import append [as 别名]
 def xml(self):
     self.created = Token.utc()
     root = Element("Timestamp", ns=WSUNS)
     created = Element('Created', ns=WSUNS)
     created.setText(self._trim_to_ms(str(UTC(self.created))))
     root.append(created)
     if self.validity is not None:
         self.expires = self.created + timedelta(seconds=self.validity)
         expires = Element('Expires', ns=WSUNS)
         expires.setText(self._trim_to_ms(str(UTC(self.expires))))
         root.append(expires)
     return root
开发者ID:w00fel,项目名称:cloudera,代码行数:14,代码来源:wsse.py

示例11: set_session

# 需要导入模块: from suds.sax.element import Element [as 别名]
# 或者: from suds.sax.element.Element import append [as 别名]
 def set_session(self, session_id):
     """
     Record the session info.
     """
     self.session = session_id
     self.session_expiration = datetime.now() + timedelta(
         seconds=self.session_duration)
     session_namespace = ('ns1', 'http://api.zuora.com/')
     session = Element('session', ns=session_namespace).setText(session_id)
     header = Element('SessionHeader', ns=session_namespace)
     header.append(session)
     self.client.set_options(soapheaders=[header])
开发者ID:a1ph4g33k,项目名称:zuora-client,代码行数:14,代码来源:client.py

示例12: xml

# 需要导入模块: from suds.sax.element import Element [as 别名]
# 或者: from suds.sax.element.Element import append [as 别名]
 def xml(self):
     self.created = datetime.utcnow()
     root = Element("Timestamp", ns=WSUNS)
     created = Element('Created', ns=WSUNS)
     created.setText(iso_utc(self.created))
     root.append(created)
     if self.validity is not None:
         self.expires = self.created + timedelta(seconds=self.validity)
         expires = Element('Expires', ns=WSUNS)
         expires.setText(iso_utc(self.expires))
         root.append(expires)
     return root
开发者ID:metaspace,项目名称:robotframework-sudslibrary,代码行数:14,代码来源:wsse.py

示例13: _fault

# 需要导入模块: from suds.sax.element import Element [as 别名]
# 或者: from suds.sax.element.Element import append [as 别名]
        def _fault(code, msg):
            '''Generate fault XML'''

            faultcode = Element('faultcode').setText(code)
            faultstring = Element('faultstring').setText(msg)
            fault = Element('Fault').append([faultcode, faultstring])
            body = Element('Body').append(fault)
            envelope = Element('Envelope', ns=soap_envns)
            envelope.append(body)
            envelope.refitPrefixes()

            return envelope.str()
开发者ID:vvojvoda,项目名称:fiscal-hr-python,代码行数:14,代码来源:fiscal.py

示例14: startElement

# 需要导入模块: from suds.sax.element import Element [as 别名]
# 或者: from suds.sax.element.Element import append [as 别名]
 def startElement(self, name, attrs):
     top = self.top()
     node = Element(unicode(name), parent=top)
     for a in attrs.getNames():
         n = unicode(a)
         v = unicode(attrs.getValue(a))
         attribute = Attribute(n,v)
         if self.mapPrefix(node, attribute):
             continue
         node.append(attribute)
     top.append(node)
     self.push(node)
开发者ID:tic-ull,项目名称:defensatfc-proto,代码行数:14,代码来源:parser.py

示例15: xml

# 需要导入模块: from suds.sax.element import Element [as 别名]
# 或者: from suds.sax.element.Element import append [as 别名]
 def xml(self):
     """
     Get xml representation of the object.
     @return: The root node.
     @rtype: L{Element}
     """
     root = Element('Security', ns=wssens)
     root.set('mustUnderstand', 1 if self.mustUnderstand else 0)
     if self.timestamp:
         root.append(Timestamp().xml())
     for t in self.tokens:
         root.append(t.xml())
     return root
开发者ID:tic-ull,项目名称:defensatfc-proto,代码行数:15,代码来源:wsse.py


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