def getContent(self):
     an = IAnnotationManager(self.context)
     try:
         content = an.read()
     except:
         content={'cpheaderbar':'False','cpautohide':'False','cpwidth':"100%",'cpheight':"300px",'cpcss':'++theme++collective.carousselplace/twelve/galleria.twelve.css','cpcsscustom':'','cpjavascript':"Galleria.loadTheme('++theme++collective.carousselplace/twelve/galleria.twelve.min.js');\nGalleria.run('.galleria');\nGalleria.configure({\nautoplay: false,\ntransitionSpeed: 0,\n imageCrop: true,\n imagePan: true,\n_showFullscreen: false,\n _showProgress: false\n});"}
     return content
 def save(self,action):
     data , errors = self.extractData()
     if errors:
         return
     an = IAnnotationManager(self.context)
     try:
         an.write(data)
     except ValueError:
         IStatusMessage(self.context).add('Error in data')
    def update(self):
        carousselFolderId = self.context.id+'-caroussel'
        try:
            carousselFolder = self.context[carousselFolderId]
        except:
            self.activate=False
        else:
            self.activate=True
            self.title = carousselFolder.title
            self.description = carousselFolder.Description
            self.imagesObj=carousselFolder.listFolderContents(contentFilter={"portal_type" : "Image"})
            # Defaults values
            self.cpautohide = False
            self.cpheaderbar = False
            self.carousselDivStyle='width:100%; height: 300px'
            self.cpjavascript="Galleria.loadTheme('++theme++collective.carousselplace/twelve/galleria.twelve.min.js');\nGalleria.run('.galleria');\nGalleria.configure({\nautoplay: false,\ntransitionSpeed: 30,\n imageCrop: true,\n imagePan: true,\n_showFullscreen: false,\n _showProgress: false\n});"
            self.cpcss='++theme++collective.carousselplace/twelve/galleria.twelve.css'
            self.cpcsscustom=''

            #Get caroussel custom values in annotation to overlap defaults values
            self.annotationOk=True
            try:
                an = IAnnotationManager(self.context)
            except:
                self.annotationOk=False
            else:
                try:
                    content=an.read()
                except:
                    self.annotationOk=False
                else:
                    self.cpheaderbar = content['cpheaderbar']
                    if content['cpwidth']:
                        self.carousselDivStyle='width:'+content['cpwidth']+'; '
                    if content['cpheight']:
                        self.carousselDivStyle=self.carousselDivStyle+'height:'+content['cpheight']+';'
                    if content['cpcss']:
                        self.cpcss=content['cpcss']
                    if content['cpcsscustom']:
                        self.cpcsscustom=content['cpcsscustom']
                    if content['cpjavascript']:
                        if  len(content['cpjavascript'].decode('ascii','ignore')) > 4:
                            self.cpjavascript = content['cpjavascript']