Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install menhir.contenttype.photoalbum

How to install menhir.contenttype.photoalbum

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install menhir.contenttype.photoalbum
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
0.4 Available View build log
0.3 Available View build log
0.1 Available View build log
Windows (64-bit)
0.4 Available View build log
0.3 Available View build log
0.1 Available View build log
Mac OS X (10.5+)
0.4 Available View build log
0.3 Available View build log
0.1 Available View build log
Linux (32-bit)
0.4 Available View build log
0.3 Available View build log
0.1 Available View build log
Linux (64-bit)
0.4 Available View build log
0.3 Available View build log
0.1 Available View build log
 
License
GPL
Lastest release
version 0.4 on Feb 15th, 2011

menhir.contenttype.photoalbum provides a single content type useable to display images as a collection. The content type has two different rendering views, allowing to render the images as static thumbnails or as an animated gallery.

Interfaces

The menhir.contenttype.photoalbum IPhotoAlbum interface extends IDescriptiveSchema from dolmen.app.content and IContainer from zope.container:

>>> from zope.container.interfaces import IContainer
>>> from dolmen.app.content import IDescriptiveSchema
>>> from menhir.contenttype.photoalbum import IPhotoAlbum

>>> IPhotoAlbum.isOrExtends(IContainer)
True

>>> IPhotoAlbum.isOrExtends(IDescriptiveSchema)
True

This interface is applied as a schema for the PhotoAlbum:

>>> from dolmen.content import schema
>>> from menhir.contenttype.photoalbum import PhotoAlbum
>>> schema.bind().get(PhotoAlbum)
[<InterfaceClass menhir.contenttype.photoalbum.album.IPhotoAlbum>]

The IPhotoAlbum interface defines a containership constraint, allowing only IImage contents, from menhir.contenttype.image:

>>> album = PhotoAlbum(title=u"My nice images")

>>> from zope.container.constraints import checkObject
>>> checkObject(album, 'temporary', object())
Traceback (most recent call last):
...
InvalidItemType: (<menhir.contenttype.photoalbum.album.PhotoAlbum ...>,
<object object at ...>, (<InterfaceClass menhir.contenttype...IImage>,))

A PhotoAlbum object provides the IPhotoAlbum interface but also the IViewSelector interface, defining the name of the view used to render the object:

>>> IPhotoAlbum.providedBy(album)
True

>>> from dolmen.app.viewselector import IViewSelector
>>> IViewSelector.providedBy(album)
True

Factory

The factory is protected by a common dolmen.app.security right:

>>> from dolmen.content import require
>>> print require.bind().get(album)
dolmen.content.Add

Icon

The content registers an icon, thanks to the dolmen.app.content package:

>>> from zope.component import getMultiAdapter
>>> from zope.publisher.browser import TestRequest

>>> request = TestRequest()
>>> icon = getMultiAdapter((album, request), name="icon")
>>> print icon
<zope.browserresource.icon.IconView object at ...>

Population

>>> import os.path
>>> from menhir.contenttype.image import Image
>>> testpath = os.path.join(os.path.dirname(__file__), 'tests')
>>> path1 = os.path.join(testpath, 'dolmen.png')
>>> path2 = os.path.join(testpath, 'dolmen-test-site.png')
>>> imagefile = open(path1)
>>> image1 = Image(title=u"Logo", image=imagefile)
>>> imagefile.close()
>>> imagefile = open(path2)
>>> image2 = Image(title=u"Example", image=imagefile)
>>> imagefile.close()
>>> from zope.component.hooks import getSite
>>> site = getSite()
>>> site['album'] = album
>>> site['album']['dolmen_logo'] = image1
>>> site['album']['dolmen_site_example'] = image2

Views

Thumbnails view
>>> print album.selected_view
thumbnails_view
>>> import fanstatic
>>> fanstatic.init_needed()
<fanstatic.core.NeededResources object at ...>
>>> index = getMultiAdapter((album, request), name="index")
>>> index.update()
>>> print index.content()
<h1>My nice images</h1>
<div class="photo-album">
  <div class="gallery-thumbs">
     <ul class="thumbs noscript">
       <li>
         <a class="thumb image-link"
            href="http://127.0.0.1/album/dolmen_logo/++thumbnail++image.preview"
            title="Logo" rel="gallery-...">
            <img src="http://127.0.0.1/album/dolmen_logo/++thumbnail++image.square"
                 title="Logo" alt="Logo" />
         </a>
      </li>
      <li>
         <a class="thumb image-link"
            href="http://127.0.0.1/album/dolmen_site_example/++thumbnail++image.preview"
            title="Example" rel="gallery-...">
            <img src="http://127.0.0.1/album/dolmen_site_example/++thumbnail++image.square"
                 title="Example" alt="Example" />
        </a>
      </li>
    </ul>
  </div>
</div>
>>> fanstatic.get_needed().resources()
[<Resource 'css/slimbox2.css' in library 'jquery_slimbox'>,
 <Resource 'gallery.css' in library 'photoalbum.resources'>,
 <Resource 'jquery.js' in library 'jquery'>,
 <Resource 'js/slimbox2.js' in library 'jquery_slimbox'>,
 <Resource 'popup.js' in library 'menhir.contenttype.image'>]
Animated view
>>> album.selected_view = "gallery_view"
>>> fanstatic.init_needed()
<fanstatic.core.NeededResources object at ...>
>>> index = getMultiAdapter((album, request), name="index")
>>> index.update()
>>> print index.content()
<h1>My nice images</h1>
<div class="photo-album">
  <div class="gallery-thumbs navigation">
    <ul class="thumbs noscript">
      <li style="opacity: 0.67">
        <a class="thumb"
           href="http://127.0.0.1/album/dolmen_logo/++thumbnail++image.preview"
           title="Logo">
           <img src="http://127.0.0.1/album/dolmen_logo/++thumbnail++image.square"
                title="Logo" alt="Logo" />
        </a>
        <div class="caption">Logo</div>
      </li>
      <li style="opacity: 0.67">
        <a class="thumb"
           href="http://127.0.0.1/album/dolmen_site_example/++thumbnail++image.preview"
           title="Example">
           <img src="http://127.0.0.1/album/dolmen_site_example/++thumbnail++image.square"
                title="Example" alt="Example" />
        </a>
        <div class="caption">Example</div>
      </li>
    </ul>
  </div>
  <div class="gallery">
    <div class="controls"></div>
    <div class="loader"></div>
    <div class="slideshow"></div>
    <div class="caption"></div>
  </div>
  <div class="gallery-footer" />
</div>
>>> fanstatic.get_needed().resources()
[<Resource 'gallery.css' in library 'photoalbum.resources'>,
 <Resource 'jquery.js' in library 'jquery'>,
 <Resource 'jquery.galleriffic.js' in library 'galleriffic'>,
 <Resource 'gallery.js' in library 'photoalbum.resources'>]

Changelog

0.4 (2011-02-14)
  • The schema now inherits from IDescriptiveSchema from dolmen.app.content and no longer from IBaseContent from dolmen.content. This adds a description attribute along with the already existing title.
0.3 (2011-02-02)
  • Fixed the animated gallery page for Galleriffic 2.0.1-1.
0.2 (2011-02-02)
  • Added missing resources entry point.
  • Updated for Grok 1.3.
0.1 (2011-01-19)
  • Initial release.

Subscribe to package updates

Last updated Feb 15th, 2011

Download Stats

Last month:3

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.