User Tools

Site Tools


programming:python:libgal3

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
programming:python:libgal3 [2010/12/26 00:11] – [Working With Images] jayprogramming:python:libgal3 [2023/11/10 20:06] (current) – [Donations] jay
Line 1: Line 1:
-====== What is it? ======+====== Python Gallery 3 Library ====== 
 + 
 +===== What is it? =====
 This is a library to wrap the new Gallery 3 REST API in a nice, handy Python library.  This makes using accessing and manipulating your Gallery 3 site a breeze. This is a library to wrap the new Gallery 3 REST API in a nice, handy Python library.  This makes using accessing and manipulating your Gallery 3 site a breeze.
  
 This is still an early release, but it functions quite well and has some nice features from a performance standpoint like //lazy// access to sub-items (the images in an album, for example). This is still an early release, but it functions quite well and has some nice features from a performance standpoint like //lazy// access to sub-items (the images in an album, for example).
-====== License ======+===== License =====
 This project is licensed under the GPLv3.  A copy of the license is included in the source and is available at [[http://www.gnu.org/licenses/gpl-3.0.txt]]. This project is licensed under the GPLv3.  A copy of the license is included in the source and is available at [[http://www.gnu.org/licenses/gpl-3.0.txt]].
  
-====== Downloading ====== +===== Downloading ===== 
-You can download the package here: {{:programming:python:pylibgal3-0.1.3.tar.gz|pylibgal3-0.1.3.tar.gz}}.+You can download the package here: {{:programming:python:pylibgal3-0.1.6.tar.gz|pylibgal3-0.1.6.tar.gz}}.
  
 You can also track this project on [[https://github.com/crustymonkey/pylibgal3|github]] You can also track this project on [[https://github.com/crustymonkey/pylibgal3|github]]
  
-====== Installing ======+ 
 + 
 + 
 +===== Installing =====
 Install is pretty easy if you've ever installed another Python package.  It's the standard ''python setup.py install'' as root thing. Install is pretty easy if you've ever installed another Python package.  It's the standard ''python setup.py install'' as root thing.
  
 <code> <code>
-tar -xvzf pylibgal3-*.tar.gz +tar -xvzf pylibgal3-*.tar.gz 
-cd pylibgal3-* +cd pylibgal3-* 
-sudo python setup.py install+sudo python setup.py install
 </code> </code>
  
 That's about it for the install. That's about it for the install.
  
-====== Usage ====== +===== Usage ===== 
-===== Logging In =====+==== Logging In ====
  
 This is a pretty simple to use library.  First, we'll go through the 2 ways you can log in. This is a pretty simple to use library.  First, we'll go through the 2 ways you can log in.
Line 40: Line 45:
 # access with ssl=True.  If you were running your gallery on an ssl connection on the # access with ssl=True.  If you were running your gallery on an ssl connection on the
 # standard ssl port of 443, you would use this for your constructor: # standard ssl port of 443, you would use this for your constructor:
-# gal = libg3.Gallery3(hostname , apiKey , g3Base=g3Base , port=443 , ssl=True+# gal = libg3.Gallery3(hostname , apiKey , g3Base=g3Base , port=443 , ssl=True)
 </code> </code>
 We'll get to usage on the ''gal'' object in a minute.  Before that, let's cover the other way to get your base Gallery3 object.  You can use the ''login()'' function instead to pass in a username and password rather than your api key directly.  This basically subs out the ''apiKey'' in the Gallery3 constructor with a username and password.  You can still set the ''g3Base'', ''port'' and ''ssl'' options like you would in the Gallery3 constructor call. We'll get to usage on the ''gal'' object in a minute.  Before that, let's cover the other way to get your base Gallery3 object.  You can use the ''login()'' function instead to pass in a username and password rather than your api key directly.  This basically subs out the ''apiKey'' in the Gallery3 constructor with a username and password.  You can still set the ''g3Base'', ''port'' and ''ssl'' options like you would in the Gallery3 constructor call.
Line 56: Line 61:
 Now that you have your Gallery3 object, let's get to what you can do with it. Now that you have your Gallery3 object, let's get to what you can do with it.
  
-===== Core Gallery Items =====+==== Core Gallery Items ====
 First, lets give you a brief explanation of the basic elements you will be dealing with,  There are a total of five core Gallery elements that we will explore here. First, lets give you a brief explanation of the basic elements you will be dealing with,  There are a total of five core Gallery elements that we will explore here.
   - **Album** - Basically, this is a container to hold other items, including other albums.  The root of your gallery is an album.   - **Album** - Basically, this is a container to hold other items, including other albums.  The root of your gallery is an album.
Line 65: Line 70:
  
  
-===== Exploring the Root Album =====+==== Exploring the Root Album ====
 As you may, or may not, be aware, the root of your gallery is considered to be an album just like any other album you create within it.  This means that it is the base of a tree structure you create.  The examples for the root album will actually apply to any other sub-albums with one exception, the root album does not have a parent. As you may, or may not, be aware, the root of your gallery is considered to be an album just like any other album you create within it.  This means that it is the base of a tree structure you create.  The examples for the root album will actually apply to any other sub-albums with one exception, the root album does not have a parent.
  
Line 148: Line 153:
 updatedDatetime = root.getUpdDT() updatedDatetime = root.getUpdDT()
 </code> </code>
-An important thing to note with some of the above.  All the "members", "tags", "album_cover", and as we will see with images, "comments" are created on the fly with a //lazy// pull from the server.  If you are not familiar with what I mean by "lazy", that means that when, in your code, you access the "members" property of your album, a call will be made to the //at that time// to generate the objects for each member.  It is an on-demand approach to object creation.  It keeps the server access to a minimum so that there aren't calls being made to retrieve items that aren't going to be used.  The calls to the server for these items is only made once and all the "members" will be stored in memory for access after that.  **NOTE**: this also means that there will be a bit of a delay when you are first accessing properties like "members", "tags", "comments", etc.+An important thing to note with some of the above.  All the "members", "tags", "album_cover", and as we will see with images, "comments"are created on the fly with a //lazy// pull from the server.  If you are not familiar with what I mean by "lazy", it means that when, in your code, you access the "members" property of your album, a call will be made to the //at that time// to generate the objects for each member.  It is an on-demand approach to object creation.  It keeps the server access to a minimum so that there aren't calls being made to retrieve items that aren't going to be used.  The calls to the server for these items are only made once and all the "members" will be stored in memory for access after that.  **NOTE**: this also means that there will be a bit of a delay when you are first accessing properties like "members", "tags", "comments", etc.
  
-===== Images =====+==== Images ====
 Now, let's take a look at a RemoteImage: Now, let's take a look at a RemoteImage:
 <code python> <code python>
Line 224: Line 229:
 </code> </code>
  
-===== Comments =====+==== Comments ====
 We will only look at comments (and tags) briefly. We will only look at comments (and tags) briefly.
  
Line 259: Line 264:
 </code> </code>
  
-===== Tags =====+==== Tags ====
 Tags are a bit like comments.  We are going to cover these briefly as well. Tags are a bit like comments.  We are going to cover these briefly as well.
 <code python> <code python>
Line 285: Line 290:
 </code> </code>
  
-===== Additional Info =====+==== Additional Info ====
 That about finishes up with the basics of the readable attributes for each of the core items.  You can access more documentation for each type on the command line with the ''pydoc'' command: That about finishes up with the basics of the readable attributes for each of the core items.  You can access more documentation for each type on the command line with the ''pydoc'' command:
   * pydoc libg3.G3Items.Album   * pydoc libg3.G3Items.Album
Line 296: Line 301:
 Now, let's move on to working with our different items. Now, let's move on to working with our different items.
  
-===== Working With Albums =====+==== Working With Albums ====
 This is about as easy as it gets.  You just call the ''addAlbum()'' method on any album object. This is about as easy as it gets.  You just call the ''addAlbum()'' method on any album object.
 <code python> <code python>
Line 333: Line 338:
 To do the same with a movie, just use "LocalMovie" instead of "LocalImage". To do the same with a movie, just use "LocalMovie" instead of "LocalImage".
  
-===== Working With Images =====+==== Working With Images ====
 Now, there are not as many things you can do with images (or movies) as you can with albums so this will be brief. Now, there are not as many things you can do with images (or movies) as you can with albums so this will be brief.
  
Line 382: Line 387:
 You can perform all these same operations with a RemoteMovie object as well. You can perform all these same operations with a RemoteMovie object as well.
  
-===== Another Item of Interest =====+==== Another Item of Interest ====
 It should also be pointed out that almost all of the functionality described above can also be done with different objects and method calls to your main Gallery3 object.  This example will give you an idea of what I'm talking about: It should also be pointed out that almost all of the functionality described above can also be done with different objects and method calls to your main Gallery3 object.  This example will give you an idea of what I'm talking about:
 <code python> <code python>
Line 401: Line 406:
 </code> </code>
 It's worth noting that calling ''setCover()'' on album object is actually //exactly// the same as calling ''setAlbumCover()'' on the Gallery3 object.  In fact, this is exactly what happens behind the scenes for consistency.  This is the case with just about all the "item" object methods.  Basically, use whatever code path works the best/easiest for you in your code. It's worth noting that calling ''setCover()'' on album object is actually //exactly// the same as calling ''setAlbumCover()'' on the Gallery3 object.  In fact, this is exactly what happens behind the scenes for consistency.  This is the case with just about all the "item" object methods.  Basically, use whatever code path works the best/easiest for you in your code.
-===== The Future =====+==== The Future ====
 As you can see, there is a good deal of functionality here, but it is by no means complete.  Here are some of the plans I have for the future As you can see, there is a good deal of functionality here, but it is by no means complete.  Here are some of the plans I have for the future
   * Make images and thumbnails resizable   * Make images and thumbnails resizable
-  * Access to thumbnail downloads 
   * Reordering of members in an album   * Reordering of members in an album
   * Make all editable properties editable   * Make all editable properties editable
-  * I'm not sure about member access with large albums (over 100 images).  I haven't been able to test this yet, and therefore, I haven't been able to make sure it works. 
  
 If anyone has any problems, suggestions or whatever, feel free to email me directly at <admin@splitstreams.com> If anyone has any problems, suggestions or whatever, feel free to email me directly at <admin@splitstreams.com>
programming/python/libgal3.1293322272.txt.gz · Last modified: 2010/12/26 00:11 by jay