コード例 #1
0
def new_site(context, request):
    """Add a new site.
    """
    # Handle submission
    if 'form.submitted' in request.params:
        data = mvc.merge(request.POST.items())
        site = ctx.Site(parent=context)
        site.save(data, include_default=True)
        return HTTPFound(location=request.resource_url(context, site.__name__))
    new_site_url = request.resource_url(context, 'new-site')
    # Respond
    return dict(page_title="New Site", new_site_url=new_site_url)
コード例 #2
0
ファイル: sites.py プロジェクト: kjq/piano
def new_site(context, request):
    """Add a new site.
    """
    # Handle submission
    if 'form.submitted' in request.params:
        data = mvc.merge(request.POST.items())
        site = ctx.Site(parent=context)
        site.save(data, include_default=True)
        return HTTPFound(location=request.resource_url(context, site.__name__))
    new_site_url = request.resource_url(context, 'new-site')
    # Respond
    return dict(
        page_title="New Site",
        new_site_url=new_site_url)
コード例 #3
0
ファイル: pages.py プロジェクト: kjq/piano
def new_page(context, request):
    """Adds a new page.
    """
    # Handle submission
    if 'form.submitted' in request.params:
        data = mvc.merge(request.POST.items())
        page = ctx.Page(parent=context)
        page.create(data)
        return HTTPFound(location=request.resource_url(context, page.__name__))
    new_page_url = request.resource_url(context, 'new-page')
    # Respond
    return dict(page_title="New Page",
                page_slug=context.__name__,
                new_page_url=new_page_url)
コード例 #4
0
ファイル: pages.py プロジェクト: kjq/piano
def edit_page(context, request):
    """Renders a page using its associated template in EDIT mode.
    """
    template = template_name(context.source, c.EDIT_TEMPLATE)
    edit_page_url = request.resource_url(context, 'edit-page')
    # Handle submission
    if 'form.submitted' in request.params:
        data = mvc.merge(request.POST.items())
        context.update(data)
        return HTTPFound(location=request.resource_url(context))
    # Respond
    return render_to_response(
        template,
        mvc.PageModel(
            context,
            new_page_url=None,
            edit_page_url=edit_page_url,
            history_page_url=None),
        request=request)