3

Accessing Shotgun from Google App Engine Servers

From  http://code.google.com/appengine/

Google App Engine enables you to build and host web apps on the same systems that power Google applications. App Engine offers fast development and deployment; simple administration, with no need to worry about hardware, patches or backups; and effortless scalabilityThe Google App Engine provides a robust framework for developing web applications.

It turns out that is possible to use the Shotgun API from Google App Engine servers, which makes it possible to leverage the Google App Engine tools to build lightweight web based clients to the Shotgun database.

Here's how you can get started:

  1. Sign up for the Google App Engine account (from above link).  Download the SDK, and go through the Google App Engine tutorial.   As such things go this tutorial is super easy, and can be done in a leisurely two hours.
  2. Create a new application in the Google App Engine Launcher -- "File->Create New Application...", and check that the template application gives the "Hello World" result.
  3. Copy the "shotgun_api3.py" file into your google application folder.
  4. Copy the attached "shotgun_google_wrap.py" into the application folder.
  5. Replace "main.py" with the attached "main.py".
  6. Edit the "sg = Shotgun(...)" lines in the "main.py", replacing "YOUR_SG_SITE_NAME", "SG_REGISTERED_SCRIPT_NAME",  "SCRIPT_APPLICATION_KEY" with the appropriate values.
  7. Run the app from the "Launcher" and "Browse" the results

The only problem that I ran into was that the successive Shotgun API calls don't work within the Google App Engine.  I worked around this with the "shotgun_google_wrap" library, which is just a bunch of wrappers for the Shotgun API that creates a new "Shotgun" object before each API call.

--- John McLaughlin




main.py
reinitialization_wrapper.py

2 comments

  • 0
    Avatar
    Mike Romey

    Hi John,

    Very interesting.  What is the latency of not being able to run successive shotgun calls?  From our perspective we do a lot of calls to different entities per API tool we develop.  Having to connect and reconnect I assume would introduce some latency and would also build out more events in SG.  Not to fond of our IP on Googles servers.  To be frank not fond of it on anyone else servers but our own.  What specific advantages does Google offer aside from Hardware, Patches, Backups and Scalability.  Is the Google App engine tied to Google Analytics?  Do they have an iPad app of sorts to access the Google App Engine?

     

    -Romey

  • 0
    Avatar
    John McLaughlin

    Hi Mike,

    The main application of this is to be able to write custom tools for the Shotgun Database using an internet hosted web interface.   You can also look it as an approach to "server side" scripting for Shotgun.  This may not be important for facilities that have all their Shotgun custom tools within the company firewall.  However at Mass Animation we have practically zero internal infrastructure, and are working with many people outside our firewall that may need specialized access to Shotgun data.  

    Since I just got this working last week, it's too new for me to see if there are any deep problems with the approach, but so far it looks promising.  In particular I'm not seeing any horrible latency problems.  But on the other hand I'm doing most of my interactions with AJAX style asynchronous calls, and I'm trying to minimize the number of Shotgun API calls with the "batch" method where I can.   In other words I'm strictly avoiding tight loops of Google/Shotgun interaction.  

    I'm not worried at all about putting code on the Google servers.  In fact I suspect we'll be inclined to give away tools that make it easier for people to work with us.   Security of the actual Shotgun data is a huge deal though.  I'm looking into the best ways to authenticate users for our web based apps, and potentially using the Google App Engine as the firewall between certain web based users and the Shotgun database.  

    I think for us the main Google advantages over other web infrastructures would be rapid development, rapid deployment, and high reliability.  There may also be useful applications of their Datastore, though spreading info over multiple databases is something I'd like to avoid.

    I haven't looked into Google Analytics, and I don't think it's too important for my applications.  I know next to nothing about iPad/iPhone programming, but I assume that sticking to basic html in the web app will make things work fine in an iPad/iPhone browser.

    Thanks for asking, 

    John

Please sign in to leave a comment.