コード例 #1
0
ファイル: baseControllers.py プロジェクト: palli/statmon
	def createContent(self):
		# prevent recursion, if createContent has not been overriden
		if isinstance(self.parent,BaseController): return

		self._pspPath = currentPath

		self.header = HeaderController(self.req,parent=self)
		self.footer = FooterController(self.req,parent=self)

		self.nav = NavController(self.req,parent=self)
		Content = self.overrideContent
		if not Content:
			Content = self.nav.getActiveController()

		try: self.content = Content(self.req,parent=self)
		except:
			self.content = ErrorController(self.req,parent=self)
		
		if self.findExportTable(self.getField('exportTable'),self.content):
			return

		self.nav.updateItem(self.content)

		if isinstance(self.content,InputController) and self.content.hasInputs():
			self.inputHidden = StringToBool(self.getField('filterhide',self.inputHidden))
			self.inputBox = InputController.getContent(self.content,filename=InputController._filename,pspPath=InputController._pspPath)
			self.inputHidden = min(self.inputHidden,self.content.inputHidden,not self.content.hasBadInput)
		if isinstance(self.content,BaseController):
			if self.content._filename == self._filename and self.content._pspPath == self._pspPath:
				# prevent unreadable errors if filename not overriden
				self.content._filename = None

			self._extraSheets += self.content._extraSheets

		#self.testpop = PopUpMenuController(self.req,'eisbock.basis.is',pop=PU.DOWN_RIGHT,items=['eisbock.basis.is','maibock.basis.is','doppelbock.basis.is'])

		self.header.title = self.getTitle()
		self.header.inputBox = self.inputBox
		self.header.inputHidden = self.inputHidden
コード例 #2
0
ファイル: baseControllers.py プロジェクト: palli/statmon
	def __init__(self, req,createContent=True,parent=None):
		self._alerts = []
		self._splitAlerts = 1
		self._extraSheets = []
		self._exportTable = None

		# used in psp
		self.injectedContent = ''
		self.content = None
		self.overrideContent = None
		self.inputHidden = True
		self.inputBox = None

		InputController.__init__(self,req,parent=parent)

		if isinstance(parent,BaseController):
			# safe time and increase consistency
			self.now = self.parent.now
			self.weekago = self.parent.weekago
			self.yesterday = self.parent.yesterday
			self.today = self.parent.today
			self.testAlerts = self.parent.testAlerts
			self.debugAlerts = self.parent.debugAlerts
		else:
			self.now = datetime.datetime.now()
			self.today = datetime.datetime( *self.now.timetuple()[0:3] )
			self.weekago = self.today-datetime.timedelta(days=7)
			self.yesterday = self.today-datetime.timedelta(days=1)
			self.today = self.today
			self.testAlerts = StringToBool(self.getField('testAlerts'))
			self.debugAlerts = StringToBool(self.getField('debugAlerts'))
			BytesToText.setFixed(StringToBool(self.getField('fixedUnit'),default=None,empty=None,none=None))
			BytesToText.setShowUnit(StringToBool(self.getField('showUnit',True),default=True,none=None))
			BytesToText.setBase(self.getField('baseUnit'))
			BytesToText.setPrecision(self.getField('precisionUnit'))
			try: self.testAlerts = int(self.testAlerts)
			except: pass
			homePrefix = self.getHomePrefix()
			baselayout = self.getBaseLayout()
			self.addStyleSheet(homePrefix+'css/outer-baselayout.css','outer','baselayout','screen',active=baselayout=='outer')
			self.addStyleSheet(homePrefix+'css/inner-baselayout.css','inner','baselayout','screen',active=baselayout=='inner')
			self.addStyleSheet(homePrefix+'css/print-baselayout.css','print','baselayout','print')

			self.addStyleSheet(homePrefix+'css/core.css','std','core')

			theme = self.getColorTheme()
			for name,file in _themes:
				self.addStyleSheet(homePrefix+file,name,'color-theme',active=theme==name)

			shadows = self.getShadows()
			if shadows:
				self.addStyleSheet(homePrefix+'css/half-shadows.css','half','shadows',active=shadows=='half')
				self.addStyleSheet(homePrefix+'css/full-shadows.css','full','shadows',active=shadows=='full')
				StandardController._noshadowdops = False
			else:
				StandardController._noshadowdops = True

		if not createContent: return

		self.preCreate()
		self.createContent()
		self.postCreate()
コード例 #3
0
ファイル: baseControllers.py プロジェクト: palli/statmon
	def getContent(self,filename=None,pspPath=None):
		if self._exportTable:
			self._exportTable.__class__ = CVSTableController
			return self._exportTable
		return InputController.getContent(self,filename,pspPath)
コード例 #4
0
ファイル: testControllers.py プロジェクト: palli/statmon
	def createContent(self):
		
		#begin Input
		simpleInput = InputController(self.req,'Simple Input')

		now = datetime.datetime.now()
		options = [('abc','abc..'),('def','def..')]

		seed = simpleInput.processInput(II('seed','Seed Number',II.NUMBER,default=random.randint(0,10000)))
		incr = simpleInput.processInput(II('incr','Seed Increment',II.NUMBER,default=1))
		texta = simpleInput.processInput(II('texta','Test Text A',II.TEXT,allowBlank=True,blankVal='%'))
		textb = simpleInput.processInput(II('textb','Test Text B',II.TEXT,default='foo'))
		datec = simpleInput.processInput(II('datec','Test Date C',II.DATE,allowBlank=True,blankVal=now))
		dated = simpleInput.processInput(II('dated','Test Date D',II.DATE,default=now))
		opte = simpleInput.processInput(II('opte','Test Drop Down E',II.DROPDOWN,options=options,allowBlank=True,blankVal='Blank'))
		optf = simpleInput.processInput(II('optf','Test Drop Down F',II.DROPDOWN,options=options,default='def'))

		seed = simpleInput.updateInput('seed',seed+incr)
		self.simpleInput = simpleInput.getContent()

		#begin prop table
		simpleProps = PropTableController(self.req,'Simple Stuff')
		simpleProps.addRow(TR('Seed Number',seed,TR.NUMBER))
		simpleProps.addRow(TR('Seed Increment',incr,TR.NUMBER))
		simpleProps.addRow(TR('Test Text A',texta,TR.TEXT))
		simpleProps.addRow(TR('Test Text B',textb,TR.TEXT))
		simpleProps.addRow(TR('Test Date C',datec,TR.DATETIME))
		simpleProps.addRow(TR('Test Date D',dated,TR.DATETIME))
		simpleProps.addRow(TR('Test Text B',type(dated),TR.TEXT))
		simpleProps.addRow(TR('Test Drop Down E',opte,TR.TEXT))
		simpleProps.addRow(TR('Test Drop Down F',optf,TR.TEXT))

		self.simpleProps = simpleProps.getContent()

		#begin simple table
		self.simpleTable = simpleTable = TableController(self.req,'simpleTable','Simple Table',dbOrder=False)
		simpleTable.addHeader(TH('text', 'Text',TH.TEXT,sorted=True))
		simpleTable.addHeader(TH('bytes', 'Bytes',TH.BYTES))
		simpleTable.addHeader(TH('number', 'Number',TH.NUMBER))
		simpleTable.addHeader(TH('time', 'Time',TH.TIME))
		simpleTable.addHeader(TH('date', 'Date',TH.DATE))
		simpleTable.addHeader(TH('datetime', 'Date Time',TH.DATETIME))
		simpleTable.addHeader(TH('float', 'Float',TH.FLOAT))
		#simpleTable.addHeader(TH('html', 'Raw HTML',TH.HTML))
		simpleTable.addHeader(TH('html2', 'Raw HTML',TH.HTML))

		random.seed(seed)
		for i in random.sample(xrange(1000),max(0,int(random.normalvariate(10,15)))):
			random.seed(i)
			li_type = random.choice(['error','info','warning'])
			image = 'img/li_%s.png' % li_type
			image2 = image.replace('li_','')
			row = {
				'text' : self.generateString(max(2,int(random.normalvariate(30,15)))),
				'bytes' : min(2**64,max(0,int(2**random.normalvariate(36,15)))),
				'number' : i,
				'time' : datetime.datetime.now()+datetime.timedelta((random.random()-.5)*2000),
				'date' : datetime.datetime.now()+datetime.timedelta((random.random()-.5)*2000),
				'datetime' : datetime.datetime.now()+datetime.timedelta((random.random()-.5)*2000),
				'float' : random.random()*1000,
				'html' : '<img src="%s" alt="%s"/>' % (self.homePrefixIt(image),li_type[0]),
				'html2' : '<img src="%s" alt="%s"/>' % (self.homePrefixIt(image2),li_type[0])
			}
			simpleTable.addRow(**row)

		self.simplePopUp = PopUpMenuController(self.req,'Up-Left',pop=PU.UP_LEFT)

		#self.addItems(self.simplePopUp,3)
		self.addItems(self.simplePopUp,2,all=False)

		# Create Alerts
		alerts=self.getAlerts(local=True)
		self.alertTable = AlertController(self.req,alerts)