98adde2170c2d82d1005dcfe3c5b88fc9e9092fa
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.
15 from Globals
import InitializeClass
16 from AccessControl
import ClassSecurityInfo
17 from Products
.CMFCore
.permissions
import View
, ModifyPortalContent
18 from Products
.CMFCore
.PortalContent
import PortalContent
19 from Products
.CMFDefault
.DublinCore
import DefaultDublinCoreImpl
20 from zope
.component
.factory
import Factory
22 class Lightbox( PortalContent
, DefaultDublinCoreImpl
):
23 "lightbox holds references to photos"
25 security
= ClassSecurityInfo()
27 def __init__( self
, id, title
='', uids
=[], description
=''):
28 DefaultDublinCoreImpl
.__init
__(self
)
30 self
.uids
= tuple(uids
)
31 self
._editMetadata
(title
=title
, description
=description
)
33 security
.declareProtected(View
, 'getUidList')
35 return list(self
.uids
)
37 security
.declareProtected(ModifyPortalContent
, 'append')
38 def append(self
, uid
):
39 if uid
not in self
.uids
:
40 self
.uids
= self
.uids
+ (uid
,)
42 self
.reindexObject(idxs
=['modified'])
47 security
.declareProtected(ModifyPortalContent
, 'extend')
48 def extend(self
, uids
):
52 if uid
not in self
.uids
:
56 self
.uids
= self
.uids
+ tuple(new
)
57 if len(already
< uids
) :
59 self
.reindexObject(idxs
=['modified'])
62 security
.declareProtected(ModifyPortalContent
, 'pop')
63 def pop(self
, index
=None):
68 self
.uids
= self
.uids
[:i
] + self
.uids
[i
+1:]
71 self
.reindexObject(idxs
=['modified'])
73 security
.declareProtected(ModifyPortalContent
, 'remove')
74 def remove(self
, value
):
75 for i
, v
in enumerate(self
.uids
) :
82 self
.reindexObject(idxs
=['modified'])
84 InitializeClass(Lightbox
)
86 LightboxFactory
= Factory(Lightbox
)