Exemplo n.º 1
0
def edit_do(request, id_, **kwargs):
    content = request.form.get("content", "")
    action = request.form.get("action", "")
    action = action.lower()

    if action == "delete":
        deldata = document.delete(notedb(), xapdb, id_)
        if deldata is None:
            return notfound()
    else:
        updatedata = document.update(notedb(), xapdb, id_, content)
        if updatedata is None:
            return notfound()

    return redirect("document.index")
Exemplo n.º 2
0
def edit(id_, **kwargs):
    doc = document.get(notedb(), id_)
    if doc is None:
        return notfound()
    
    return templateresponse("/page/editor.mako", 
        id_=id_,
        content=doc[1])
Exemplo n.º 3
0
Arquivo: user.py Projeto: bjornua/dna
def edit_form(uid):
    if not authcheck():
        return
    try:
        doc = user.get(uid)
    except user.UserDoesntExist:
        notfound()
        return
    
    args = local.request.args
    errors = set(filter(len, args.get(u"errors", "").split(u",")))
    username = args.get(u"username", doc["username"])
    email = args.get(u"email", doc["email"])
    macaddrs_max = args.get(u"macaddrs_max", doc["macaddrs_max"])
    

    template_response("/page/user/edit.mako", 
        uid=uid,
        username=username,
        email=email,
        macaddrs_max=macaddrs_max,
        errors=errors
    )
Exemplo n.º 4
0
    def dispatch(request):
        import app.controllers.document
        from app.controllers.error import notfound, error
        from app.mapping import url_map, endpts
        from app.utils.session import Session
        from app.db import sessiondb

        try:
            url_adapter = url_map.bind_to_environ(request.environ)

            session_id = request.cookies.get("session_id")
            if session_id is not None:
                try:
                    session_id = int(session_id)
                except ValueError:
                    session_id = None

            session_token = request.cookies.get("session_token")
            session = Session(sessiondb, session_id, session_token, ttl=60)

            try:
                endpt, params = url_adapter.match()
                response = endpts[endpt](request=request, url_adapter=url_adapter, session=session, **params)
            except NotFound:
                response = notfound(request=request, url_adapter=url_adapter)
            
            if session.token is None or session.id is None:
                return response

            response.set_cookie("session_id", unicode(session.id), max_age=99999999)
            response.set_cookie("session_token", session.token, max_age=99999999)
            return response
        except:
            # Let werkzeug handle the exception
            if debug:
                raise
            
            # Log error and return error page
            log.exception("Exception in %s with params %s", endpt, repr(params))
            return error(request = request)