Ignore:
Timestamp:
15 Jan 2010, 23:38:09 (15 years ago)
Author:
uli
Message:

Add pages for browsing logfiles.

File:
1 edited

Legend:

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

    r4802 r4823  
    328328    pnav = 0
    329329
     330    def getFiles(self):
     331        files = self.context.getFiles()
     332        for file in files:
     333            name = file.name
     334            if not name.endswith('.csv') and not name.endswith('.pending'):
     335                continue
     336            yield file
     337   
    330338    def update(self, filename=None, select=None, cancel=None):
    331339        if cancel is not None:
     
    535543        self.importer = getUtility(IImporter, name=self.importername)
    536544        (linenum, warnings) = self.importer.doImport(
    537             self.fullpath, self.headerfields, self.mode)
     545            self.fullpath, self.headerfields, self.mode,
     546            self.request.principal.id)
    538547        self.warn_num = len(warnings)
    539548        if self.warn_num:
     
    542551                linenum - (self.warn_num)))
    543552
    544        
     553class DatacenterLogsOverview(WAeUPPage):
     554    grok.context(IDataCenter)
     555    grok.name('logs')
     556    grok.template('datacenterlogspage')
     557    grok.require('waeup.manageUniversity')
     558    title = u'Data Center Logs'
     559    pnav = 0
     560
     561    def update(self, show=None, remove=None, logname=None, back=None):
     562        session = ISession(self.request)['waeup.sirp']
     563        if back is not None:
     564            self.redirect(self.url(self.context))
     565            return
     566        if logname is not None:
     567            session['logname'] = logname
     568            if remove is not None:
     569                fullpath = os.path.join(self.context.storage, logname)
     570                try:
     571                    os.unlink(fullpath)
     572                    self.flash('File %s deleted.' % logname)
     573                except:
     574                    self.flash("Could not delete %s: " % logname)
     575                    self.flash("Problem: %s" % sys.exc_info()[1])
     576
     577        if show is not None:
     578            self.redirect(self.url(self.context, '@@show'))
     579            return
     580        self.files = self.context.getLogFiles()
     581
     582class DatacenterLogsFileview(WAeUPPage):
     583    grok.context(IDataCenter)
     584    grok.name('show')
     585    grok.template('datacenterlogsshowfilepage')
     586    grok.require('waeup.manageUniversity')
     587    title = u'Show file'
     588    pnav = 0
     589
     590    def update(self, show=None, remove=None, back=None):
     591        session = ISession(self.request)['waeup.sirp']
     592        logname = session.get('logname', None)
     593        if back is not None or logname is None:
     594            self.redirect(self.url(self.context, '@@logs'))
     595            return
     596        self.filename = logname
     597        self.files = self.context.getLogFiles()
     598        fullpath = os.path.join(self.context.storage, logname)
     599        self.filecontents = open(fullpath, 'rb').read()
     600
    545601class DatacenterSettings(WAeUPPage):
    546602    grok.context(IDataCenter)
Note: See TracChangeset for help on using the changeset viewer.