home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2012 January / maximum-cd-2012-01.iso / DiscContents / digsby_setup.exe / lib / ZSI / __init__.pyo (.txt) next >
Encoding:
Python Compiled Bytecode  |  2011-10-05  |  15.7 KB  |  269 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.6)
  3.  
  4. _copyright = 'ZSI:  Zolera Soap Infrastructure.\n\nCopyright 2001, Zolera Systems, Inc.  All Rights Reserved.\nCopyright 2002-2003, Rich Salz. All Rights Reserved.\n\nPermission is hereby granted, free of charge, to any person obtaining a\ncopy of this software and associated documentation files (the "Software"),\nto deal in the Software without restriction, including without limitation\nthe rights to use, copy, modify, merge, publish, distribute, and/or\nsell copies of the Software, and to permit persons to whom the Software\nis furnished to do so, provided that the above copyright notice(s) and\nthis permission notice appear in all copies of the Software and that\nboth the above copyright notice(s) and this permission notice appear in\nsupporting documentation.\n\nTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT\nOF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS\nINCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT\nOR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS\nOF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE\nOR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE\nOR PERFORMANCE OF THIS SOFTWARE.\n\nExcept as contained in this notice, the name of a copyright holder\nshall not be used in advertising or otherwise to promote the sale, use\nor other dealings in this Software without prior written authorization\nof the copyright holder.\n\n\nPortions are also:\n\nCopyright (c) 2003, The Regents of the University of California,\nthrough Lawrence Berkeley National Laboratory (subject to receipt of\nany required approvals from the U.S. Dept. of Energy). All rights\nreserved. Redistribution and use in source and binary forms, with or\nwithout modification, are permitted provided that the following\nconditions are met:\n\n(1) Redistributions of source code must retain the above copyright\nnotice, this list of conditions and the following disclaimer.\n(2) Redistributions in binary form must reproduce the above copyright\nnotice, this list of conditions and the following disclaimer in the\ndocumentation and/or other materials provided with the distribution.\n(3) Neither the name of the University of California, Lawrence Berkeley\nNational Laboratory, U.S. Dept. of Energy nor the names of its contributors\nmay be used to endorse or promote products derived from this software without\nspecific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED\nTO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS\nBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE\nGOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\nHOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\nLIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\nOUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\nSUCH DAMAGE.\n\nYou are under no obligation whatsoever to provide any bug fixes,\npatches, or upgrades to the features, functionality or performance of\nthe source code ("Enhancements") to anyone; however, if you choose to\nmake your Enhancements available either publicly, or directly to\nLawrence Berkeley National Laboratory, without imposing a separate\nwritten license agreement for such Enhancements, then you hereby grant\nthe following license: a non-exclusive, royalty-free perpetual license\nto install, use, modify, prepare derivative works, incorporate into\nother computer software, distribute, and sublicense such Enhancements\nor derivative works thereof, in binary and source code form.\n\n\nFor wstools also:\n\nZope Public License (ZPL) Version 2.0\n-----------------------------------------------\n\nThis software is Copyright (c) Zope Corporation (tm) and\nContributors. All rights reserved.\n\nThis license has been certified as open source. It has also\nbeen designated as GPL compatible by the Free Software\nFoundation (FSF).\n\nRedistribution and use in source and binary forms, with or\nwithout modification, are permitted provided that the\nfollowing conditions are met:\n\n1. Redistributions in source code must retain the above\n   copyright notice, this list of conditions, and the following\n   disclaimer.\n\n2. Redistributions in binary form must reproduce the above\n   copyright notice, this list of conditions, and the following\n   disclaimer in the documentation and/or other materials\n   provided with the distribution.\n\n3. The name Zope Corporation (tm) must not be used to\n   endorse or promote products derived from this software\n   without prior written permission from Zope Corporation.\n\n4. The right to distribute this software or to use it for\n   any purpose does not give you the right to use Servicemarks\n   (sm) or Trademarks (tm) of Zope Corporation. Use of them is\n   covered in a separate agreement (see\n   http://www.zope.com/Marks).\n\n5. If any files are modified, you must cause the modified\n   files to carry prominent notices stating that you changed\n   the files and the date of any change.\n\nDisclaimer\n\n  THIS SOFTWARE IS PROVIDED BY ZOPE CORPORATION ``AS IS\'\'\n  AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT\n  NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY\n  AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN\n  NO EVENT SHALL ZOPE CORPORATION OR ITS CONTRIBUTORS BE\n  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\n  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n  OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH\n  DAMAGE.\n\n\nThis software consists of contributions made by Zope\nCorporation and many individuals on behalf of Zope\nCorporation.  Specific attributions are listed in the\naccompanying credits file.\n'
  5. from xml.dom import Node as _Node
  6. import types as _types
  7. from ZSI.wstools.Namespaces import ZSI_SCHEMA_URI
  8. UNICODE_ENCODING = 'utf-8'
  9. _inttypes = [
  10.     _types.IntType,
  11.     _types.LongType]
  12. _floattypes = [
  13.     _types.FloatType]
  14. _seqtypes = [
  15.     _types.TupleType,
  16.     _types.ListType]
  17. _stringtypes = [
  18.     _types.StringType,
  19.     _types.UnicodeType]
  20.  
  21. _attrs = lambda E: if not E.attributes or E.attributes.values():
  22. pass[]
  23.  
  24. _children = lambda E: if not E.childNodes:
  25. pass[]
  26.  
  27. _child_elements = lambda E: if not E.childNodes:
  28. pass_[1]
  29. from ZSI.wstools.Namespaces import SOAP as _SOAP, SCHEMA as _SCHEMA, XMLNS as _XMLNS
  30.  
  31. _find_arraytype = lambda E: if not E.getAttributeNS(_SOAP.ENC, 'arrayType'):
  32. passE.getAttributeNS(_SOAP.ENC12, 'arrayType')
  33.  
  34. _find_encstyle = lambda E: if not E.getAttributeNS(_SOAP.ENV, 'encodingStyle'):
  35. passE.getAttributeNS(_SOAP.ENV12, 'encodingStyle')
  36.  
  37. try:
  38.     from xml.dom import EMPTY_NAMESPACE
  39.     _empty_nsuri_list = [
  40.         EMPTY_NAMESPACE]
  41. except:
  42.     _empty_nsuri_list = [
  43.         None,
  44.         '']
  45.  
  46.  
  47. def _find_attr(E, attr):
  48.     for nsuri in _empty_nsuri_list:
  49.         
  50.         try:
  51.             v = E.getAttributeNS(nsuri, attr)
  52.             if v:
  53.                 return v
  54.         continue
  55.         continue
  56.  
  57.     
  58.  
  59.  
  60. def _find_attrNS(E, namespaceURI, localName):
  61.     
  62.     try:
  63.         v = E.getAttributeNS(namespaceURI, localName)
  64.         if v:
  65.             return v
  66.     except:
  67.         pass
  68.  
  69.  
  70.  
  71. def _find_attrNodeNS(E, namespaceURI, localName):
  72.     attr = E.getAttributeNodeNS(namespaceURI, localName)
  73.     if attr is None:
  74.         return None
  75.     
  76.     try:
  77.         return attr.value
  78.     except:
  79.         attr is None
  80.  
  81.     return E.getAttributeNS(namespaceURI, localName)
  82.  
  83.  
  84. _find_href = lambda E: _find_attr(E, 'href')
  85.  
  86. _find_xsi_attr = lambda E, attr: if not E.getAttributeNS(_SCHEMA.XSI3, attr) and E.getAttributeNS(_SCHEMA.XSI1, attr):
  87. passE.getAttributeNS(_SCHEMA.XSI2, attr)
  88.  
  89. _find_type = lambda E: _find_xsi_attr(E, 'type')
  90.  
  91. _find_xmlns_prefix = lambda E, attr: E.getAttributeNS(_XMLNS.BASE, attr)
  92.  
  93. _find_default_namespace = lambda E: E.getAttributeNS(_XMLNS.BASE, None)
  94.  
  95. _get_element_nsuri_name = lambda E: (E.namespaceURI, E.localName)
  96.  
  97. _is_element = lambda E: E.nodeType == _Node.ELEMENT_NODE
  98.  
  99. def _resolve_prefix(celt, prefix):
  100.     namespace = None
  101.     while _is_element(celt):
  102.         if prefix:
  103.             namespaceURI = _find_xmlns_prefix(celt, prefix)
  104.         else:
  105.             namespaceURI = _find_default_namespace(celt)
  106.         if namespaceURI:
  107.             break
  108.         
  109.         celt = celt.parentNode
  110.     if prefix:
  111.         raise EvaluateException, 'cant resolve xmlns:%s' % prefix
  112.     prefix
  113.     return namespaceURI
  114.  
  115.  
  116. def _valid_encoding(elt):
  117.     enc = _find_encstyle(elt)
  118.     if not enc or enc in (_SOAP.ENC, _SOAP.ENC12):
  119.         return 1
  120.     for e in enc.split():
  121.         if e.startswith(_SOAP.ENC) or e.startswith(_SOAP.ENC12):
  122.             return 1
  123.     
  124.     return 0
  125.  
  126.  
  127. def _backtrace(elt, dom):
  128.     s = ''
  129.     for c in _child_elements(parent):
  130.         if c.nodeName == name:
  131.             continue
  132.         _[1][c]
  133.         matches = _[1]
  134.         elt = parent
  135.         None if len(matches) == 1 else []
  136.     return s
  137.  
  138.  
  139. def _get_idstr(pyobj):
  140.     x = id(pyobj)
  141.     if x < 0:
  142.         return 'x%x' % abs(x)
  143.     return 'o%x' % x
  144.  
  145.  
  146. def _get_postvalue_from_absoluteURI(url):
  147.     cache = _get_postvalue_from_absoluteURI.cache
  148.     path = cache.get(url, '')
  149.     if not path:
  150.         (scheme, authpath) = url.split('://')
  151.         s = authpath.split('/', 1)
  152.         if len(s) == 2:
  153.             path = '/%s' % s[1]
  154.         
  155.         if len(cache) > _get_postvalue_from_absoluteURI.MAXLEN:
  156.             cache.clear()
  157.         
  158.         cache[url] = path
  159.     
  160.     return path
  161.  
  162. _get_postvalue_from_absoluteURI.cache = { }
  163. _get_postvalue_from_absoluteURI.MAXLEN = 20
  164.  
  165. class ZSIException(Exception):
  166.     pass
  167.  
  168.  
  169. class ParseException(ZSIException):
  170.     
  171.     def __init__(self, str, inheader, elt = None, dom = None):
  172.         Exception.__init__(self)
  173.         self.str = str
  174.         self.inheader = inheader
  175.         self.trace = None
  176.         if elt and dom:
  177.             self.trace = _backtrace(elt, dom)
  178.         
  179.  
  180.     
  181.     def __str__(self):
  182.         if self.trace:
  183.             return self.str + '\n[Element trace: ' + self.trace + ']'
  184.         return self.str
  185.  
  186.     
  187.     def __repr__(self):
  188.         return '<%s.ParseException %s>' % (__name__, _get_idstr(self))
  189.  
  190.  
  191.  
  192. class EvaluateException(ZSIException):
  193.     
  194.     def __init__(self, str, trace = None):
  195.         Exception.__init__(self)
  196.         self.str = str
  197.         self.trace = trace
  198.  
  199.     
  200.     def __str__(self):
  201.         if self.trace:
  202.             return self.str + '\n[Element trace: ' + self.trace + ']'
  203.         return self.str
  204.  
  205.     
  206.     def __repr__(self):
  207.         return '<%s.EvaluateException %s>' % (__name__, _get_idstr(self))
  208.  
  209.  
  210.  
  211. class FaultException(ZSIException):
  212.     
  213.     def __init__(self, fault):
  214.         self.fault = fault
  215.  
  216.     
  217.     def __str__(self):
  218.         return str(self.fault)
  219.  
  220.     
  221.     def __repr__(self):
  222.         return '<%s.FaultException %s>' % (__name__, _get_idstr(self))
  223.  
  224.  
  225.  
  226. class WSActionException(ZSIException):
  227.     pass
  228.  
  229. import version
  230.  
  231. def Version():
  232.     return version.Version
  233.  
  234. from writer import SoapWriter
  235. from parse import ParsedSoap
  236. from fault import Fault, FaultFromActor, FaultFromException, FaultFromFaultMessage, FaultFromNotUnderstood, FaultFromZSIException
  237. import TC
  238. TC.RegisterType(TC.String, minOccurs = 0, nillable = False)
  239. TC.RegisterType(TC.URI, minOccurs = 0, nillable = False)
  240. TC.RegisterType(TC.Base64String, minOccurs = 0, nillable = False)
  241. TC.RegisterType(TC.HexBinaryString, minOccurs = 0, nillable = False)
  242. for pyclass in (TC.IunsignedByte, TC.IunsignedShort, TC.IunsignedInt, TC.IunsignedLong, TC.Ibyte, TC.Ishort, TC.Iint, TC.Ilong, TC.InegativeInteger, TC.InonPositiveInteger, TC.InonNegativeInteger, TC.IpositiveInteger, TC.Iinteger, TC.FPfloat, TC.FPdouble):
  243.     TC.RegisterType(pyclass, minOccurs = 0, nillable = False)
  244.  
  245. TC.RegisterType(TC.Boolean, minOccurs = 0, nillable = False)
  246. TC.RegisterType(TC.Duration, minOccurs = 0, nillable = False)
  247. TC.RegisterType(TC.gDateTime, minOccurs = 0, nillable = False)
  248. TC.RegisterType(TC.gDate, minOccurs = 0, nillable = False)
  249. TC.RegisterType(TC.gYearMonth, minOccurs = 0, nillable = False)
  250. TC.RegisterType(TC.gYear, minOccurs = 0, nillable = False)
  251. TC.RegisterType(TC.gMonthDay, minOccurs = 0, nillable = False)
  252. TC.RegisterType(TC.gDay, minOccurs = 0, nillable = False)
  253. TC.RegisterType(TC.gTime, minOccurs = 0, nillable = False)
  254. TC.RegisterType(TC.Apache.Map, minOccurs = 0, nillable = False)
  255. import schema
  256. for i in [
  257.     int,
  258.     float,
  259.     str,
  260.     tuple,
  261.     list,
  262.     unicode]:
  263.     schema._GetPyobjWrapper.RegisterBuiltin(i)
  264.  
  265. schema.RegisterAnyElement()
  266. if __name__ == '__main__':
  267.     print _copyright
  268.  
  269.