Skip to main content

A Python client for the Saleforce.com SOAP API

Project description

(‘Introductionn============nnThis is a distutils-packaged and updated version of the beatbox modulenby Simon Fell, which is a Python implementation of a client for thenSalesforce.com Partner Web Services API.nn.. beatbox module: http://www.pocketsoap.com/beatbox/nnThis module contains 2 versions of the Salesforce.com client:nn XMLClientn The original beatbox version of the client which returns xmltramp objects.n PythonClientn Marshalls the returned objects into proper Python data types. e.g. integern fields return integers.nnnCompatibilityn=============nnBeatbox supports versions 16.0 through 20.0 of the Salesforce Partner WebnServices API. However, the following API calls have not been implemented atnthis time:nn * convertLeadn * emptyRecycleBinn * invalidateSessionsn * logoutn * mergen * processn * queryAlln * undeleten * describeSObjectn * sendEmailn * describeDataCategoryGroupsn * describeDataCategoryGroupStructuresnnBeatbox has been tested with Python 2.4 and Python 2.6.nnnBasic Usage Examplesn====================nnInstantiate a Python Salesforce.com client:n >>> svc = beatbox.PythonClient()n >>> svc.login('username', 'passwordTOKEN')n n(Note that interacting with Salesforce.com via the API requires the use of an'security token' which must be appended to the password.)nnQuery for contacts with last name 'Doe':n >>> res = svc.query(“SELECT Id, FirstName, LastName FROM Contact WHERE LastName='Doe'”)n >>> res[0]n {'LastName': 'Doe', 'type': 'Contact', 'Id': '0037000000eRf6vAAC', 'FirstName': 'John'}n >>> res[0].Idn '0037000000eRf6vAAC'nnAdd a new Lead:n >>> contact = {'type': 'Lead', 'LastName': 'Glick', 'FirstName': 'David', 'Company': 'Individual'}n >>> res = svc.create(contact)nGet the ID of the newly created Lead:n >>> res[0]['id']n '00Q7000000RVyiHEAT'nnnMore Examplesn=============nnThe examples folder contains the examples for the original beatbox. Fornexamples on how to use the PythonClient seensrc/beatbox/tests/test_pythonClient.py.nnSome of these other products that have been built on top of beatbox can alsonprovide example of use:n n * Salesforce Base Connectorn * Salesforce PFG Adaptern * Salesforce Auth Pluginn * RSVP for Salesforcenn.. Salesforce Base Connector: http://plone.org/products/salesforcebaseconnectorn.. Salesforce PFG Adapter: http://plone.org/products/salesforcepfgadaptern.. Salesforce Auth Plugin: http://plone.org/products/salesforceauthpluginn.. RSVP for Salesforce: http://plone.org/products/collective.salesforce.rsvpnnnAlternativesn============nnDavid Lanstein has created a Python Salesforce Toolkit that is based on then`suds`_ SOAP library. Based on limited tests it appears to be somewhat slowernthan beatbox for operations that return a lot of data; however, it may be anbetter option if you want to be able to automatically generate a service proxynfor a new WSDL (such as for the Enterprise web services API).nn.. Python Salesforce Toolkit: http://code.google.com/p/salesforce-python-toolkit/n.. suds: https://fedorahosted.org/suds/nnRon Hess from Salesforce.com has adapted beatbox for use with Google AppnEngine. See http://code.google.com/p/force-app-engine/nnnRunning Testsn=============nnFirst, we need to add some custom fields to the Contacts object in your Salesforce instance:nn * Login to your Salesforce.com instancen * Browse to Setup –> Customize –> Contacts –> Fields –> “New” buttonn * Add a Picklist (multi-select) labeled “Favorite Fruit”, then addn * Applen * Orangen * Pearn * Leave default of 3 lines and field name should default to “Favorite_Fruit”n * Add a Number labeled “Favorite Integer”, with 18 places, 0 decimal placesn * Add a Number labeled “Favorite Float”, with 13 places, 5 decimal placesnnCreate a sfconfig file in your python path with the following format::nn USERNAME='your salesforce username'n PASSWORD='your salesforce passwordTOKEN'nnwhere TOKEN is your Salesforce API login token.nnAdd './src' to your PYTHONPATHnnRun the tests::nn python src/beatbox/tests/test_beatbox.pyn python src/beatbox/tests/test_pythonClient.pynnnChangelogn=========nn21.0 (2013-06-03)n—————–nn* Fix AttributeError: BeatBoxXmlGenerator instance has no attribute '_out'nn* Fix typo for childRelationships within describeSObjects methodnn20.0 (2010-11-30)n—————–nn* Add 'encryptedstring' to the list of types marshalled as strings. Thanksn sobyone.n [davisagli]nn* Update to use version 20.0 of the Salesforce.com partner WSDL by default.n [davisagli]nn19.0 (2010-08-23)n—————–nn* Update marshalling of describeGlobal and describeSObjects responses ton include new properties now returned by the API. For backwardsn compatibility, we set the types property of the describeGlobal responsen to a list of the names of all types (which Salesforce now returns inn separate DescribeGlobalSObjectResult objects).n [davisagli]nn* Update to use version 19.0 of the Salesforce.com partner WSDL by default.n Also, use the new login.salesforce.com login endpoint by default.n [davisagli]nn16.1 (2010-03-11)n—————–nn* Catch and retry on exceptions from the socket library, in addition to onesn from httplib. This fixes a regression introduced in version 16.0.n [davisagli]nnn16.0 (2009-11-12)n—————–nn* Don't strip newlines when marshalling the values of textarea fields.n [davisagli]nn* Make sure to add a field to fieldsToNull if its Python value is None.n [rhettg, davisagli]nn* Fix issue where numbers of type long weren't converted to a string.n [spleeman, davisagli]nn* Only catch HTTP exceptions when retrying a connection.n [spleeman, davisagli]nnn16.0b1 (2009-09-08)n——————-nn* Log beatbox calls at the debug level.n [davisagli]nn* Fixed a string exception for compatibility with Python 2.6.n [davisagli]nn* Added support for SOSL searches via the search method. Thanks to Alex Tokarn of Web Collective.n [davisagli]nn* Added an optional cache for the sObject type descriptions needed forn marshalling query results into Python objects. This can avoid an extran describeSObjects API call for each query, but means that the informationn could become stale if the type metadata is modified in Salesforce.com.n The cache is off by default. Turn it on by passingn cacheTypeDescriptions=True when instantiating a Python client. The cache mayn be reset by calling the flushTypeDescriptionsCache method of the Pythonn client.n [davisagli]nn* Support a full SOQL statement as a parameter to the query method of then Python client. The old 3-part method signature (fields, sObjectType,n conditionalExpression) should continue to work.n [davisagli]nn* In the Python client, support relationship queries and other queries that mayn return multiple types of objects. Object type descriptions (required forn marshalling field values into the correct Python type) are cached for then duration of the query after the first time they are used. Thanks ton Melnychuk Taras of Quintagroup.n [davisagli]nn* In the Python client, queries now return a list-like QueryRecordSet holdingn a sequence of dict-like QueryRecord objects, instead of a dict containing an list of dicts. This allows for more Pythonic access such as results[0].Idn instead of results['results'][0]['Id']. The old syntax should still work.n Thanks to Melnychuk Taras of Quintagroup.n [davisagli]nn* Update to use version 16.0 of the Salesforce.com partner WSDL.n [davisagli]nnn0.12 (2009-05-13)n—————–nn* Use the default serverUrl value if the passed value evaluates to booleann False.n [davisagli]nn0.11 (2009-05-13)n—————–nn* Access 'created' instead of 'isCreated' in the upsert result. This closesn http://code.google.com/p/salesforce-beatbox/issues/detail?id=4n [davisagli]nn0.10 (2009-05-06)n—————–nn* Added optional serverUrl parameter when creating a Client.n [davisagli]nnpre 0.9.1.1n———–nn* ancient historyn’,)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

beatboxxx-21.0.tar.gz (30.4 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page