Changeset 4679 for waeup


Ignore:
Timestamp:
5 Jan 2010, 11:30:24 (15 years ago)
Author:
uli
Message:
  • Add datacenter settings page.
  • Fix imports.
  • Fix handling of datacenter uploads.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • waeup/branches/ulif-layout/src/waeup/browser/pages.py

    r4677 r4679  
    33"""
    44import grok
     5import os
     6import sys
    57from hurry.query import Eq
    68from hurry.query.query import Query, Text
     
    240242    title = u'Data Center Upload'
    241243    pnav = 0
     244   
     245    def update(self, uploadfile=None, CANCEL=None, SUBMIT=None):
     246        if CANCEL is not None:
     247            self.redirect(self.url(self.context))
     248            return
     249        if not uploadfile:
     250            return
     251        try:
     252            filename = uploadfile.filename
     253            target = os.path.join(self.context.storage, filename)
     254            open(target, 'wb').write(uploadfile.read())
     255        except IOError:
     256            self.flash('Error while uploading file. Please retry.')
     257            self.flash('I/O error: %s' % sys.exc_info()[1])
     258            return
     259        self.redirect(self.url(self.context))
     260
    242261
    243262class DataCenterImportCSVPage(WAeUPPage):
     
    278297        self.flash('Successfully imported: %s' % os.path.basename(csvfile))
    279298        self.redirect(self.url(self.context))
     299        return
     300
     301class DatacenterSettings(WAeUPPage):
     302    grok.context(IDataCenter)
     303    grok.name('manage')
     304    grok.template('datacentermanagepage')
     305    grok.require('waeup.manageUniversity')
     306    title = u'Data Center Settings'
     307    pnav = 0
     308    #grok.template('master')
     309
     310    def update(self, newpath=None, move=False, overwrite=False,
     311               save=None, cancel=None):
     312        if move:
     313            move = True
     314        if overwrite:
     315            overwrite = True
     316        if newpath is None:
     317            return
     318        if cancel is not None:
     319            self.redirect(self.url(self.context))
     320            return
     321        try:
     322            not_copied = self.context.setStoragePath(newpath, move=move)
     323            for name in not_copied:
     324                self.flash('File already existed (not copied): %s' % name)
     325        except ValueError:
     326            self.flash('Given storage path cannot be used.')
     327            self.flash('Error: %s' %sys.exc_info()[1])
     328            return
     329        if newpath:
     330            self.flash('New storage path succefully set.')
     331            self.redirect(self.url(self.context))
    280332        return
    281333
Note: See TracChangeset for help on using the changeset viewer.