def list_folder(tserver, match, fact): name = match['Folder1'] user = match['Person1'] q = '(is-placed Content1, in %s)?' % name resp = ask_kb(tserver.config, q) resp = json.loads(resp) data = get_data(name) template = get_template('templates/list-folder.html') return template.render(contents=resp, data=data, user=user, name=name)
def edit_profile(tserver, match, fact): assertion = '(save-profile %(Person1)s, of %(Person2)s)' % match name = match['Person2'] btn = Button(name='assertion', title='Save', value=assertion) data = get_data(name) schema = get_schema('person', form=True) if data.password: schema.get('password').widget = HiddenWidget() appstruct = schema.dictify(data) form = Form(schema, buttons=(btn,)) template = get_template('templates/edit.html') return template.render(form=form.render(appstruct))
def authenticate(self, environ, identity): try: login = identity['login'] password = identity['password'] except KeyError: return None data = get_data(login) hashed = data.password if bcrypt.hashpw(password, hashed) == hashed: environ['REMOTE_USER'] = login return login environ['REMOTE_USER'] = '' return None
def view_profile(tserver, match, fact): name = match['Person2'] data = get_data(name) template = get_template('templates/profile_view.html') return template.render(data=data)
def view(tserver, match, fact): user = match['Person1'] name = match['Content1'] data = get_data(name) template = get_template('templates/%s_view.html' % data.ntype) return template.render(data=data, name=name, user=user, ask_kb=ask_kb, config=tserver.config, json=json)