Dolmen contenttype extension:photoalbum

menhir.contenttype.photoalbum的Python项目详细描述


menhir.contenttype.photoalbum提供单个内容类型 可将图像显示为集合。内容类型有两个 不同的渲染视图,允许将图像渲染为静态 缩略图或作为动画库。

接口

menhir.contenttype.photoalbumiphotoalbum接口扩展 idescriptiveschemafromdolmen.app.contenticontainerfrom 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

此接口作为相册的模式应用

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

iphotoalbum接口定义了一个containership约束, 只允许从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>,))

一个photoalbum对象提供了iphotoalbum的接口 iviewselector接口,定义用于 渲染对象:

>>> IPhotoAlbum.providedBy(album)
True

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

工厂

工厂受公共dolmen.app.security权限保护:

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

图标

由于^{tt3},内容注册了一个图标$ 套餐:

>>> 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 ...>

人口

>>> 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

视图

缩略图视图

>>> 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'>]

动画视图

>>> 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'>]

更改日志

0.4(2011-02-14)

  • 模式现在继承自 dolmen.app.content,不再来自 dolmen.content。这将添加一个描述属性以及 已经存在的<引用>标题>引用。

0.3(2011-02-02)

  • 修正了galleriffic 2.0.1-1的动画库页面。

0.2(2011-02-02)

  • 添加了缺少的资源入口点。
  • 为Grok1.3更新。

0.1(2011-01-19)

  • 初次发布。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
Java例外。Lang.Stringindexoutofboundsexception索引超出范围(0)   java Spring引导Freemarker从2.2.0升级失败   重构Java反模式名称?包含对象的对象包含。。。等   用java处理JDBC可能出现的死锁的最佳方法   java无法访问主线程上的数据库,因为它可能会在很长一段时间内锁定UI   java如何将固定大小的画布包装在边框窗格中的滚动窗格居中?   java解析xsd文件后得到空结果   在html页面中表示XML文件的java   socketjava对象流   sql Java越界异常数据库   JavaJBoss7.1.1不会在Mavericks上启动   Twincat ADS事件驱动读取在一段时间后停止工作(Java)   java MyBatis使用生成的ID插入所有   Mojave上缺少MacOS Java控制面板   JavaGuice:如果多次注入相同的依赖项,是否注入了该依赖项的相同实例?