coherence.extern.galleryremote.gallery (module)

class Gallery(url, version=2)[source]

Bases: object

The Gallery class implements the Gallery Remote protocol as documented here: http://codex.gallery2.org/Gallery_Remote:Protocol

The Gallery project is an open source web based photo album organizer written in php. Gallery’s web site is:

This class is a 3rd party product which is not maintained by the creators of the Gallery project.

Example usage:

from coherence.extern.galleryremote import Gallery
my_gallery = Gallery('http://www.yoursite.com/gallery2', 2)
my_gallery.login('username','password')
albums = my_gallery.fetch_albums()

Create a Gallery for remote access.

Parameters
  • url (str) – base address of the gallery

  • version (int) – version of the gallery being connected to (default 2), either 1 for Gallery1 or 2 for Gallery2.

__init__(url, version=2)[source]

Create a Gallery for remote access.

Parameters
  • url (str) – base address of the gallery

  • version (int) – version of the gallery being connected to (default 2), either 1 for Gallery1 or 2 for Gallery2.

_do_request(request)[source]

Send a request, encoded as described in the Gallery Remote protocol. request - a dictionary of protocol parameters and values

_parse_response(response)[source]

Decode the response from a request.

Parameters

response (object) – The response from a gallery request, encoded according to the gallery remote protocol.

Returns

A request dict.

_get(response, kwd)[source]
login(username, password)[source]

Establish an authenticated session to the remote gallery. username - A valid gallery user’s username password - That valid user’s password

fetch_albums()[source]

Obtain a dict of albums contained in the gallery keyed by album name. In Gallery1, the name is alphanumeric. In Gallery2, the name is the unique identifying number for that album.

fetch_albums_prune()[source]

Obtain a dict of albums contained in the gallery keyed by album name. In Gallery1, the name is alphanumeric. In Gallery2, the name is the unique identifying number for that album.

From the protocol docs: “The fetch_albums_prune command asks the server to return a list of all albums that the user can either write to, or that are visible to the user and contain a sub-album that is writable (including sub-albums several times removed).”

add_item(album, filename, caption, description)[source]

Add a photo to the specified album. album - album name / identifier filename - image to upload caption - string caption to add to the image description - string description to add to the image

album_properties(album)[source]

Obtain album property information for the specified album. album - the album name / identifier to obtain information for

new_album(parent, name=None, title=None, description=None)[source]

Add an album to the specified parent album. parent - album name / identifier to contain the new album name - unique string name of the new album title - string title of the album description - string description to add to the image

fetch_album_images(album)[source]

Get the image information for all images in the specified album. album - specifies the album from which to obtain image information

get_URL_for_image(gallery2_id)[source]