Exemplo n.º 1
0
    def test_init_wsgi_app_exception(self):
        orig_exit = sys.exit
        orig_ptah_init = ptah.ptah_initialize

        data = [False]
        def exit(status):
            data[0] = True

        def ptah_initialize(config, packages=None, autoinclude=False):
            raise ptah.config.StopException('')

        sys.exit = exit
        ptah.ptah_initialize = ptah_initialize

        app = ptah.make_wsgi_app({})

        sys.exit = orig_exit
        ptah.ptah_initialize = orig_ptah_init

        self.assertIsNone(app)
        self.assertTrue(data[0])
Exemplo n.º 2
0
        
        form.context.title = data['title']
        form.context.description = data['description']
        form.message('Content has been updated.', 'info')
        raise HTTPFound(location='.')
        
    myform.buttons.add_action('Update', action=updateAction)
    myform.buttons.add_action('Cancel', action=cancelAction)

    # form default values
    myform.content = {'title': context.title,
                      'description': context.description}

    # prepare form
    myform.update()

    # render form
    res = myform.render()

    # optional, render form in layout
    layout = view.query_layout(request, context)
    return layout(res)


if __name__ == '__main__':
    """ ...
    
    """
    app = ptah.make_wsgi_app({'settings':r'./ptah.ini'})
    serve(app, host='0.0.0.0')
Exemplo n.º 3
0

@restaction('extra-info', ptah_cms.Content, permission=View)
def extraInfo(content, request):
    """ __doc__ is used for action description """

    return {
        'title': content.title,
        'email': '*****@*****.**',
        'message': 'Ptah rest api'
    }


@restaction('protected-info', ptah_cms.Content, permission=ModifyContent)
def protectedInfo(content, request):
    """ protected rest action """

    return {
        'title': content.title,
        'email': '*****@*****.**',
        'message': 'Ptah rest api'
    }


if __name__ == '__main__':
    """ ...

    """
    app = ptah.make_wsgi_app({'settings': r'./ptah.ini'})
    serve(app, host='0.0.0.0')
Exemplo n.º 4
0
import sys, ptah
from paste.httpserver import serve

if __name__ == '__main__':
    ini = sys.argv[1]
    app = ptah.make_wsgi_app({'settings': ini})
    serve(app, host='0.0.0.0')
Exemplo n.º 5
0
            {"view": self, "content": content, "context": self.context, "request": self.request, "format": format}
        )

        return self.template(**kwargs)


class WorkspaceLayout(view.Layout):
    view.layout(
        "workspace",
        cms.ApplicationRoot,
        parent="page",
        layer="test",
        template=view.template("templates/layoutworkspace.pt"),
    )

    """ same as PageLayout, it uses 'page' as parent layout """

    def update(self):
        self.user = ptah.authService.get_current_principal()
        self.isAnon = self.user is None


if __name__ == "__main__":
    """

    """
    import ptah

    app = ptah.make_wsgi_app({"settings": r"./ptah.ini"})
    serve(app, host="0.0.0.0")
Exemplo n.º 6
0
 def test_init_wsgi_app(self):
     app = ptah.make_wsgi_app({'sqla.url': 'sqlite://', 'ptah.excludes': ''})
     self.assertIsInstance(app, Router)