Ignore:
Timestamp:
25 May 2009, 09:58:01 (15 years ago)
Author:
uli
Message:

Add ImportCSV view.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • waeup/branches/ulif-rewrite/src/waeup/viewlets.py

    r4070 r4168  
    6969        return
    7070       
    71            
    72    
     71class ImportCSV(grok.View):
     72    """A view for importing things.
     73
     74    """
     75    grok.require('waeup.manageUniversity')
     76    grok.template('master')
     77
     78    def update(self, csvfile=None, clear=None, overwrite=None,
     79               CANCEL=None, SUBMIT=None):
     80        if CANCEL is not None:
     81            self.redirect(self.url(self.context))
     82            return
     83        if not csvfile:
     84            return
     85        importer = IWAeUPXMLImporter(self.context)
     86        obj = importer.doImport(xmlfile)
     87        if type(obj) != type(self.context):
     88            return
     89        parent = self.context.__parent__
     90        name = self.context.__name__
     91        self.context = obj
     92        if hasattr(parent, name):
     93            setattr(parent, name, obj)
     94        else:
     95            del parent[name]
     96            parent[name] = obj
     97            pass
     98        return
     99
    73100class Head(grok.ViewletManager):
    74101    """additions to HTML head"""
Note: See TracChangeset for help on using the changeset viewer.