Changeset 2516 in products


Ignore:
Timestamp:
Jun 11, 2010 8:57:02 AM (14 years ago)
Author:
mylan
Message:

#192: Added uploadVerificationFile method to configlet view

File:
1 edited

Legend:

Unmodified
Added
Removed
  • quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/browser/configletview.py

    r2515 r2516  
    22from zope.interface import implements, Interface, Attribute 
    33 
     4from OFS.Image import cookId 
     5from OFS.ObjectManager import BadRequestException 
    46from Products.Five import BrowserView 
    57from Products.CMFCore.utils import getToolByName 
     
    4345        """ 
    4446 
     47    def uploadVerificationFile(vfile): 
     48        """ Upload passed site verification file to the site. 
     49            On success - update googlesitemaps verification files list.  
     50            Return tuple where : 
     51              1. boolean value - is verification file successfully created. 
     52              2. string value: 
     53                2.1. if successfull - id of created verification file 
     54                2.2. if failure - error descirption 
     55        """ 
    4556 
    4657class ConfigletSettingsView(BrowserView): 
     
    138149                props._updateProperty('verification_filenames', vfs) 
    139150        return vfs 
     151 
     152    def uploadVerificationFile(self, request): 
     153        vfilename = "" 
     154        portal = self.pps.portal() 
     155        try: 
     156            import pdb;pdb.set_trace() 
     157            vfile = request.get("verification_file") 
     158            vfilename, vftitle = cookId("", "", vfile) 
     159            portal.manage_addFile(id="", file=vfile) 
     160            portal[vfilename].manage_addProperty( 
     161                'CreatedBy', 'quintagroupt.plonegooglesitemaps','string') 
     162        except BadRequestException, e: 
     163            return False, str(e) 
     164        else: 
     165            props = self.tools.properties().googlesitemap_properties 
     166            vfilenames = list(props.getProperty('verification_filenames',[])) 
     167            vfilenames.append(vfilename) 
     168            props.manage_changeProperties(verification_filenames = vfilenames) 
     169        return True, vfilename 
Note: See TracChangeset for help on using the changeset viewer.