def onModuleLoad(self): try: setCookie(COOKIE_NAME, "setme", 100000) except: pass self.status = Label() self.text_area = TextArea() self.text_area.setText(r"Me eat cookie!") self.text_area.setCharacterWidth(80) self.text_area.setVisibleLines(8) self.button_py_set = Button("Set Cookie", self) self.button_py_read = Button("Read Cookie ", self) buttons = HorizontalPanel() buttons.add(self.button_py_set) buttons.add(self.button_py_read) buttons.setSpacing(8) info = r"This demonstrates setting and reading information using cookies." panel = VerticalPanel() panel.add(HTML(info)) panel.add(self.text_area) panel.add(buttons) panel.add(self.status) RootPanel().add(panel)
def onSave(self, sender): try: setCookie("fileLocation", self.fileLocationInput.getText(), 1000000000) except: pass self.hide()
def onModuleLoad(self): try: setCookie(COOKIE_NAME, "setme", 100000) except: pass self.status = Label() self.text_area = TextArea() self.text_area.setText(r"Me eat cookie!") self.text_area.setCharacterWidth(80) self.text_area.setVisibleLines(8) self.button_py_set = Button("Set Cookie", self) self.button_py_read = Button("Read Cookie ", self) buttons = HorizontalPanel() buttons.add(self.button_py_set) buttons.add(self.button_py_read) buttons.setSpacing(8) info = r'This demonstrates setting and reading information using cookies.' panel = VerticalPanel() panel.add(HTML(info)) panel.add(self.text_area) panel.add(buttons) panel.add(self.status) RootPanel().add(panel)
def onFileLoaded(self, filename, data): def invalid(lineno, line): alert("Invalid line at %s:\n%s" % (lineno, line)) return False date = self.timeProxy.importData(data, invalid) if date: setCookie("fileLocation", filename, 1000000000) self.sendNotification(Notification.DATE_SELECTED, date)
def onRemoteResponse(self, response, requestInfo): self.errorInfoLabel.setText('') d = datetime.date.today() + datetime.timedelta(days=1) setCookie("LoggedInUser", response, d, path='/') loggedInUser = json.loads(response) if loggedInUser["is_superuser"] == True: Window.setLocation("/admin.html") else: Window.setLocation("/home.html")
def onRemoteResponse(self, response, request_info): if response == "invalid_cookie": self.show() elif response == None or len(response) < 3: self.table.setHTML(3,0,"<b>Invalid username or password</b>") else: self.app.cookie = response[0] setCookie('cookie',response[0],1000*60*60*24) self.hide() self.app.logininit(response[1],response[2])
def onFileLoaded(self, filename, data): def invalid(lineno, line): alert("Invalid line at %s:\n%s" % (lineno, line)) return False date = self.timeProxy.importData(data, invalid) if date: try: setCookie("fileLocation", filename, 1000000000) except: pass self.sendNotification(Notification.DATE_SELECTED, date)
def onClick(self, sender): """ Run when any button is clicked """ if sender.getText() == "Set Cookie": # clicked the set cookie button text = self.text_area.getText() # print goes to console.log print "setting cookie to:", text # Note: this sets the cookie on the top level setCookie(COOKIE_NAME, text, 10000, path="/") else: cookie_text = getCookie(COOKIE_NAME) if cookie_text is None: print "No Cookie" else: print "myCookie", cookie_text self.status.setText(cookie_text)
def onClick(self, sender): """ Run when any button is clicked """ if sender.getText() == "Set Cookie": #clicked the set cookie button text = self.text_area.getText() #print goes to console.log print "setting cookie to:", text #Note: this sets the cookie on the top level setCookie(COOKIE_NAME, text, 10000, path='/') else: cookie_text = getCookie(COOKIE_NAME) if cookie_text is None: print "No Cookie" else: print "myCookie", cookie_text self.status.setText(cookie_text)
def onCellClicked(self, sender, row, col): setCookie("SelectedBlog", self.blogs[row], 10000, path='/') value = self.selectedItem.getUserObject() if value == 0: setCookie("ShowPublishButton", 'True', 10000, path='/') elif value == 1: setCookie("ShowPublishButton", 'False', 10000, path='/')
def onSave(self, sender): setCookie("fileLocation", self.fileLocationInput.getText(), 1000000000) self.hide()
def onOk(self, env): global gw setCookie('handle',self.handle.getText(),24*60*60*1000) x = self.pwd.getText() x = pwhash(x) gw.login(self.handle.getText(), x, self)
def logout(self, _): global gw gw.logout(self.cookie) self.cookie = None setCookie('cookie','',24*60*60) Window.getLocation().reload()
def onCellClicked(self, sender, row, col): setCookie("SelectedBlog", self.blogs[row], 10000, path='/') setCookie("ShowPublishButton", 'False', 10000, path='/')