def manage_afterAdd(self, item, container): # TODO: when we're done with 2.1.x, implement this via event subscription ATCTContent.manage_afterAdd(self, item, container) id = self.getId() if self.fgField.__name__ != id: self.fgField.__name__ = id
def manage_afterAdd(self, item, container): # manage_afterAdd is deprecated in Zope 2.11+ ### copy PDF file if bibreference has been copied ### ### BEWARE: to debug this code go into ### portal_skins/plone_scripts/folder_paste ### and comment out the ### fallback exception or use PloneTestCase ### reference_catalog = getToolByName(self, 'reference_catalog') bib_tool = getToolByName(self, 'portal_bibliography') bibfolder = container # grab the PDF file and its back references before the reference is removed by # BaseContent.manage_afterAdd pdf_file = self.getPdf_file() or None pdf_file_uid = '' if pdf_file: pdf_file_uid = pdf_file.UID() pdf_file_brefs = [ bref.UID() for bref in pdf_file.getBRefs('printable_version_of') if bref is not None ] if not pdf_file_uid and shasattr(self, '_temp_pdffile_UID') and self._temp_pdffile_UID: pdf_file_uid = self._temp_pdffile_UID pdf_file_brefs = [ bref.UID() for bref in reference_catalog.lookupObject(pdf_file_uid).getBRefs('printable_version_of') if bref is not None ] delattr(self, '_temp_pdffile_UID') # first do all necessary ATCT, Archetypes, etc. things... BaseContent.manage_afterAdd(self, item, container) # we have to set another transaction savepoint here, # before we can cut or copy the associated PDF file bib_tool.transaction_savepoint(optimistic=True) # then check PDF file association pdf_file = pdf_file_uid and reference_catalog.lookupObject(pdf_file_uid) if pdf_file and pdf_file_brefs and (self.UID() not in pdf_file_brefs): # bibref item has been copied and UID of bibref item has changed # => copy PDF file new_pdf_file = self.relocatePdfFile(pdf_file=pdf_file, op=0) self.setPdf_file(value=new_pdf_file.UID()) elif pdf_file and (pdf_file.aq_inner.aq_parent.aq_inner.aq_parent.getPhysicalPath() != self.aq_inner.aq_parent.getPhysicalPath()): # PDF file and bibref item are not in the same bibfolder # => move PDF file!!! moved_pdf_file = self.relocatePdfFile(pdf_file=reference_catalog.lookupObject(pdf_file_uid), op=1)
def manage_afterAdd(self, item, container): # Fix text when created through webdav. # Guess the right mimetype from the id/data. ATCTContent.manage_afterAdd(self, item, container) field = self.getField("text") # hook for mxTidy / isTidyHtmlWithCleanup validator tidyOutput = self.getTidyOutput(field) if tidyOutput: if hasattr(self, "_v_renamed"): mimetype = field.getContentType(self) del self._v_renamed else: mimetype = self.guessMimetypeOfText() if mimetype: field.set(self, tidyOutput, mimetype=mimetype) # set is ok elif tidyOutput: field.set(self, tidyOutput) # set is ok
def manage_afterAdd(self, item, container): # Fix text when created through webdav. # Guess the right mimetype from the id/data. ATCTContent.manage_afterAdd(self, item, container) field = self.getField('text') # hook for mxTidy / isTidyHtmlWithCleanup validator tidyOutput = self.getTidyOutput(field) if tidyOutput: if hasattr(self, '_v_renamed'): mimetype = field.getContentType(self) del self._v_renamed else: mimetype = self.guessMimetypeOfText() if mimetype: field.set(self, tidyOutput, mimetype=mimetype) # set is ok elif tidyOutput: field.set(self, tidyOutput) # set is ok
def manage_afterAdd(self, item, container): # manage_afterAdd is deprecated in Zope 2.11+ ### copy PDF file if bibreference has been copied ### ### BEWARE: to debug this code go into ### portal_skins/plone_scripts/folder_paste ### and comment out the ### fallback exception or use PloneTestCase ### reference_catalog = getToolByName(self, 'reference_catalog') bib_tool = getToolByName(self, 'portal_bibliography') bibfolder = container # grab the PDF file and its back references before the reference is removed by # BaseContent.manage_afterAdd pdf_file = self.getPdf_file() or None pdf_file_uid = '' if pdf_file: pdf_file_uid = pdf_file.UID() pdf_file_brefs = [ bref.UID() for bref in pdf_file.getBRefs('printable_version_of') if bref is not None ] if not pdf_file_uid and shasattr( self, '_temp_pdffile_UID') and self._temp_pdffile_UID: pdf_file_uid = self._temp_pdffile_UID pdf_file_brefs = [ bref.UID() for bref in reference_catalog.lookupObject( pdf_file_uid).getBRefs('printable_version_of') if bref is not None ] delattr(self, '_temp_pdffile_UID') # first do all necessary ATCT, Archetypes, etc. things... BaseContent.manage_afterAdd(self, item, container) # we have to set another transaction savepoint here, # before we can cut or copy the associated PDF file bib_tool.transaction_savepoint(optimistic=True) # then check PDF file association pdf_file = pdf_file_uid and reference_catalog.lookupObject( pdf_file_uid) if pdf_file and pdf_file_brefs and (self.UID() not in pdf_file_brefs): # bibref item has been copied and UID of bibref item has changed # => copy PDF file new_pdf_file = self.relocatePdfFile(pdf_file=pdf_file, op=0) self.setPdf_file(value=new_pdf_file.UID()) elif pdf_file and (pdf_file.aq_inner.aq_parent.aq_inner.aq_parent. getPhysicalPath() != self.aq_inner.aq_parent.getPhysicalPath()): # PDF file and bibref item are not in the same bibfolder # => move PDF file!!! moved_pdf_file = self.relocatePdfFile( pdf_file=reference_catalog.lookupObject(pdf_file_uid), op=1)