962d913eeba19f8eb1df8cc457aaadb13ebe65f1
1 # -*- coding: utf-8 -*-
2 ############################################################
3 # Copyright © 2005-2008 Benoît PIN <benoit.pin@ensmp.fr> #
4 # Plinn - http://plinn.org #
6 # This program is free software; you can redistribute it #
7 # and/or modify it under the terms of the Creative Commons #
8 # "Attribution-Noncommercial 2.0 Generic" #
9 # http://creativecommons.org/licenses/by-nc/2.0/ #
10 ############################################################
11 """ Lightboxes contains references to images.
12 References are made with CMFUid stuff.
13 $Id: lightbox.py 622 2008-11-16 23:38:18Z pin $
14 $URL: http://svn.luxia.fr/svn/labo/projects/zope/Portfolio/trunk/lightbox.py $
17 from Globals
import InitializeClass
18 from AccessControl
import ClassSecurityInfo
19 from Products
.CMFCore
.permissions
import View
, ModifyPortalContent
20 from Products
.CMFCore
.PortalContent
import PortalContent
21 from Products
.CMFDefault
.DublinCore
import DefaultDublinCoreImpl
22 from zope
.component
.factory
import Factory
24 class Lightbox( PortalContent
, DefaultDublinCoreImpl
):
25 "lightbox holds references to photos"
27 security
= ClassSecurityInfo()
29 def __init__( self
, id, title
='', uids
=[], description
=''):
30 DefaultDublinCoreImpl
.__init
__(self
)
32 self
.uids
= tuple(uids
)
33 self
._editMetadata
(title
=title
, description
=description
)
35 security
.declareProtected(View
, 'getUidList')
37 return list(self
.uids
)
39 security
.declareProtected(ModifyPortalContent
, 'append')
40 def append(self
, uid
):
41 if uid
not in self
.uids
:
42 self
.uids
= self
.uids
+ (uid
,)
44 self
.reindexObject(idxs
=['modified'])
49 security
.declareProtected(ModifyPortalContent
, 'extend')
50 def extend(self
, uids
):
54 if uid
not in self
.uids
:
58 self
.uids
= self
.uids
+ tuple(new
)
59 if len(already
< uids
) :
61 self
.reindexObject(idxs
=['modified'])
64 security
.declareProtected(ModifyPortalContent
, 'pop')
65 def pop(self
, index
=None):
70 self
.uids
= self
.uids
[:i
] + self
.uids
[i
+1:]
73 self
.reindexObject(idxs
=['modified'])
75 security
.declareProtected(ModifyPortalContent
, 'remove')
76 def remove(self
, value
):
77 for i
, v
in enumerate(self
.uids
) :
84 self
.reindexObject(idxs
=['modified'])
86 InitializeClass(Lightbox
)
88 LightboxFactory
= Factory(Lightbox
)