GithubHelp home page GithubHelp logo

cplusplus-api's Introduction


Shotgun C++ / Python API

http://github.com/shotgunsoftware/cplusplus-api



Background
----------

    Tippett Studio has been using Shotgun in production for several years. 
During that time, we've developed a number of tools and processes that work with
data in Shotgun, almost all of which are written in Python.  

We wanted an object-oriented framework for adding "business logic" to Shotgun. 
That is, we wanted to work with Shotgun's entities in an object-oriented
fashion, and extend them by adding useful behavior that was meaningful to 
our shop.  From this desire, an extensive Python library grew.  

Thought it was a very successful first-gen API, unfortunately, there wasn't a
good separation between the object/entity interface, and a lot of
Tippett-specific attributes and behavior crept into our original API.  It didn't
provide a C++ interface either.

This library is a ground-up rewrite, with the following design goals:

    - C++ core and a thin Python wrapper, possible to extend to other languages.

    - Clean separation between the object/entity representation and any
      business logic.

    - Easy to use.  Don't expose the underlying transport.  Users don't need
      to know about the underlying xmlrpc transport.

    - Easy to extend.  Using this library as a core, studios can derive
      site-specific classes to add business logic and manage dynamic
      attributes.


Directory hierarchy
-------------------

  * Source code and "Makefile.am" are omitted:

        |-- AUTHORS
        |-- COPYING
        |-- ChangeLog
        |-- INSTALL
        |-- Makefile.am
        |-- NEWS
        |-- README
        |-- TODO
        |-- bootstrap                   // Autoconf script that generates the configure file
        |-- configure.ac
        |-- lib                         // Cplusplus lib source
        |   `-- Shotgun
        |       |-- *.cpp
        |       `-- *.h
        |-- test                        // Cplusplus lib tests
        |   `-- *.cpp
        |-- plugins
        |   `-- python
        |       |-- configure.py        // SIP configuration script used to generate SIP .cpp source
        |       |-- shotgun.py          // Python wrapper module that strips off namespaces
        |       |-- sip                 // SIP source
        |       |   |-- *.sip
        |       |   `-- _shotgun.sip
        |       `-- test                // Python module tests
        |           `-- *.py
        |-- doc                         // Where the Doxygen configuration file and the generated HTML files live
        |   `-- config.dox
        `-- example                     // Example source code on how to derive a site-specific Shotgun library


Building
--------

  * The only dependency is the xmlrpc-c library, available at
    http://xmlrpc-c.sourceforge.net/  Make sure the xmlrpc-c-config binary is in
    your path so configure can find it.

  * Run "bootstrap" first to generate a "configure" file

  * configure

      --with-default-url
      Specify a URL to use by default when creating a Shotgun instance (you can
      always override it at runtime).  If you don't give it a default URL, 'make
      check' skips the tests, but you can still run them manually with a URL on
      the command line.

      --with-authenticate-name
      Specify an authentication "script_name" when transfering Shotgun data. It
      corresponds to "Script Name" on Shotgun's [Admin] > [Scripts] page. It is
      recommended that the default value is set when building the library. If not, 
      it can be set within the end-user application when the Shotgun class object 
      is instantiated.

      --with-authenticate-key
      Specify an authentication "script_key" when transfering Shotgun data. It
      corresponds to "Application Key" on Shotgun's [Admin] > [Scripts] page. 
      It is recommended that the default value is set when building the library. 
      If not, it can be set within the end-user application when the Shotgun class 
      object is instantiated.

      --enable-python
      Turning this on will also build the sip-based Python interface.  

      --with-pic --disable-shared
      These flags are recommended for building the sip-based Python module. 
      Linking against the dynamic C++ lib will cause Python not be able to catch 
      the exceptions that are defined in C++ API.

  * make 

  * make install


Examples
--------

  * The /example/ directory contains sample source code on how to derive a 
    site-specific Shotgun library from the main library. The structure in
    this directory mirrors the one in the main library. Here is a hierarchical
    representation of the directory (source code and "Makefile.am" are omitted):

        example
        |-- lib
        |   `-- SiteShotgun                 // Site-specific cplusplus lib source
        |       |-- *.cpp
        |       `-- *.h
        |-- test                            // Site-specific cplusplus lib tests
        |   `-- *.cpp
        `-- plugins
            `-- python
                |-- siteconfigure.py        // Site-specific SIP configuration script used to generate SIP .cpp source
                |-- siteshotgun.py          // Site-specific Python wrapper module that strips off namespaces
                |-- sip                     // Site-specific SIP source
                |   |-- *.sip
                |   `-- _siteshotgun.sip
                `-- test                    // Site-specific Python module tests
                    `-- *.py


Testing
-------

  * Make sure to include the paths of the sip-based Python modules to PYTHONPATH
    before doing any Python tests.

      - $(TOP_DIR)/plugins/python/          (shotgun module)
      - $(TOP_DIR)/example/plugins/python   (siteshotgun module)

  * make check - To check on the test programs


cplusplus-api's People

Contributors

mike1158 avatar qinheppe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cplusplus-api's Issues

HTTP error #403 with simplest test

Hi All,
I am trying to run a simplest test of C++ API like this:

SG::Dict auth;
auth.add("script_name", "ClientApi").add("script_key", "<undisclosed>");
SG::Dict findMap;
findMap.add("filters", SG::Dict("logical_operator", "and")
                           .add("conditions", SG::List()));
findMap.add("return_only", "retired");
SG::Dict paging("current_page", 1);
paging.add("entities_per_page", 1);
findMap.add("paging", paging);

xmlrpc_c::paramList params;
params.add(toXmlrpcValue(auth));
params.add(toXmlrpcValue(findMap));

std::clog<<"param size "<<params.size()<<"\n";
for(int i = 0; i < params.size(); i++)
    std::clog<<" param["<<i<<"] = '"<<params.getStruct(i)<<"'\n";

cout<<"rpc test\n";
xmlrpc_c::clientXmlTransport_wininet transport;
xmlrpc_c::client_xml client = xmlrpc_c::client_xml(&transport);
xmlrpc_c::carriageParm_wininet0 myCarriageParm("http://<undisclosed>");
xmlrpc_c::rpcPtr myRpcP("read", params);
cout<<"rpc call\n";
try {   
myRpcP->call(&client, &myCarriageParm);
  } catch (exception const& e) {
      cerr << "Client threw error: " << e.what() << endl;
} catch (...) {
cerr << "Client threw unexpected error." << endl;
}    

RPC->call() always encounter error

Client threw error: Unable to transport XML to server and get XML response back. HTTP error #403 occurred.

I am sure there is a Shotgun site up-and-running, and there is no issue access server via Python API. So what could go wrong?

zhang

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.