from google.appengine.ext import webapp

from orangescape.model.server.BaseDataViewer import BaseDataViewer
from orangescape.log.logging import default_logger as logging

class EDataViewer(webapp.RequestHandler, BaseDataViewer):

    def __init__(self):
        BaseDataViewer.__init__(self)

    def getDetails(self,metadatatype,applicationid):
        if self.initUser():
            sheetList = self.session.getApplication().getSheetMetadataList()
            sheetNameList = sheetList.values()
            sheetNameList.sort()
            templateDict = {'sheetNameList':sheetNameList, 'applicationId':self.session.getApplication().getSheetId()}
            self.response.out.write(self.renderSheetDetailsPage(templateDict))

    def getData(self,metadatatype,applicationid,url):
        self.response.out.write('<html>Data Viewer not available in enterprise. Please use a database explorer to view your datastore!</html>')