Пример #1
0
""" Source code view """
import os.path
import pkg_resources
import ptah.renderer
from pyramid.view import view_config
from pyramid.httpexceptions import HTTPFound

import ptah
from ptah.manage.manage import PtahManageRoute


@view_config(
    name='source.html', context=PtahManageRoute,
    renderer=ptah.layout('ptah-manage:source.lt', 'ptah-manage'))

class SourceView(ptah.View):
    __doc__ = 'Source introspection page.'

    source = None
    format = None

    def update(self):
        name = self.request.params.get('pkg')
        if name is None:
            return HTTPFound(location='.')

        dist = None
        pkg_name = name
        while 1:
            try:
                dist = pkg_resources.get_distribution(pkg_name)
Пример #2
0
                    IRouteRequest, name=MANAGE_APP_ROUTE)
                request.app_factory = factory
                app = factory()
                app.__parent__ = self
                app.__root_path__ = '/ptah-manage/apps/%s/'%app.__name__
                return app

        raise KeyError(key)

    def available(self):
        return bool(ptahcms.get_app_factories())


@view_config(
    context=ApplicationsModule,
    renderer=ptah.layout('ptahcms-manage:apps.lt'))

class ApplicationsModuleView(ptah.View):
    """ Applications module default view """

    def update(self):
        factories = []
        for factory in ptahcms.get_app_factories().values():
            factories.append((factory.title, factory))

        self.factories = [f for _t, f in sorted(factories)]


@view_config(
    context=ptahcms.IApplicationRoot,
    route_name=MANAGE_APP_ROUTE,
Пример #3
0
from datetime import datetime
from pyramid.view import view_config
from pyramid.httpexceptions import HTTPFound, HTTPNotFound

import ptah
from ptah_ws import settings
from ptah_ws.root import SiteRoot


# access this view by going to http://localhost:8080/myview.html
# add ptah_ws.band=my band to .ini file, restart and render this view.

@view_config('myview.html',
             context=SiteRoot, wrapper=ptah.layout())
def my_view(request):
    data = {'context' : request.root,
            'happy' : settings.ptah_ws.happy,
            'favband' : settings.ptah_ws.band,
            'now' : datetime.now()}
    return str(data)


@view_config(
    context=ptah.cms.Content,
    permission=ptah.cms.View,
    wrapper=ptah.wrap_layout(),
    renderer="ptah_ws:templates/contentview.pt")

class DefaultContentView(ptah.form.DisplayForm):

    @property
Пример #4
0
import ptah
from pyramid.view import view_config
from pyramid.interfaces import IRouteRequest


@ptah.manage.module('rest')
class RestModule(ptah.manage.PtahModule):
    """
    REST Introspector
    """

    title = 'REST Introspector'

    def available(self):
        """ check if ptah rest api is enabled """
        return self.request.registry.queryUtility(
            IRouteRequest, 'ptah-rest') is not None


@view_config(
    context=RestModule,
    renderer=ptah.layout('ptahcms.manage:templates/rest.pt'))

class RestModuleView(ptah.View):

    def update(self):
        self.url = self.request.params.get(
            'url', '{0}/__rest__/cms/'.format(self.application_url))
Пример #5
0
""" Source code view """
import os.path
import pkg_resources
import ptah.renderer
from pyramid.view import view_config
from pyramid.httpexceptions import HTTPFound

import ptah
from ptah.manage.manage import PtahManageRoute


@view_config(name='source.html',
             context=PtahManageRoute,
             renderer=ptah.layout('ptah-manage:source.lt', 'ptah-manage'))
class SourceView(ptah.View):
    __doc__ = 'Source introspection page.'

    source = None
    format = None

    def update(self):
        name = self.request.params.get('pkg')
        if name is None:
            return HTTPFound(location='.')

        dist = None
        pkg_name = name
        while 1:
            try:
                dist = pkg_resources.get_distribution(pkg_name)
                if dist is not None:  # pragma: no cover
Пример #6
0
from datetime import datetime
from pyramid.view import view_config
from pyramid.httpexceptions import HTTPFound, HTTPNotFound

import ptah
import ptahcms
from ptah_minicms import settings
from ptah_minicms.root import SiteRoot

# access this view by going to http://localhost:8080/myview.html
# add ptah_minicms.band=my band to .ini file, restart and render this view.


@view_config('myview.html', context=SiteRoot, wrapper=ptah.layout())
def my_view(request):
    data = {
        'context': request.root,
        'happy': settings.ptah_minicms.happy,
        'favband': settings.ptah_minicms.band,
        'now': datetime.now()
    }
    return str(data)


@view_config(context=ptahcms.Content,
             permission=ptahcms.View,
             wrapper=ptah.wrap_layout(),
             renderer="ptah_minicms:templates/contentview.pt")
class DefaultContentView(ptah.form.DisplayForm):
    @property
    def fields(self):
Пример #7
0
                request.request_iface = request.registry.getUtility(
                    IRouteRequest, name=MANAGE_APP_ROUTE)
                request.app_factory = factory
                app = factory()
                app.__parent__ = self
                app.__root_path__ = '/ptah-manage/apps/%s/' % app.__name__
                return app

        raise KeyError(key)

    def available(self):
        return bool(ptahcms.get_app_factories())


@view_config(context=ApplicationsModule,
             renderer=ptah.layout('ptahcms-manage:apps.lt'))
class ApplicationsModuleView(ptah.View):
    """ Applications module default view """
    def update(self):
        factories = []
        for factory in ptahcms.get_app_factories().values():
            factories.append((factory.title, factory))

        self.factories = [f for _t, f in sorted(factories)]


@view_config(context=ptahcms.IApplicationRoot,
             route_name=MANAGE_APP_ROUTE,
             renderer=ptah.layout("ptahcms-manage:apps-contentview.lt"))
class ViewForm(form.Form):
Пример #8
0
        self.__name__ = str(pid)
        self.__parent__ = parent

        self.pid = pid
        self.tinfo = tinfo
        self.cls = tinfo.cls
        self.request = request

        self.record = ptah.get_session().query(tinfo.cls)\
            .filter(tinfo.cls.__id__ == pid).one()
        self.title = self.record.title


@view_config(
    context=ModelModule,
    renderer=ptah.layout('ptahcms-manage:models.lt'))

class ModelModuleView(ptah.View):

    rst_to_html = staticmethod(ptah.rst_to_html)

    def update(self):
        cfg = ptah.get_settings(ptah.CFG_ID_PTAH, self.request.registry)

        types = []
        for ti in ptah.get_types().values():
            if ti.__class__ is not TypeInformation:
                continue
            if ti.__uri__ in cfg['disable_models']:
                continue
            types.append((ti.title, ti))
Пример #9
0
import ptah
from pyramid.view import view_config
from pyramid.interfaces import IRouteRequest


@ptah.manage.module('rest')
class RestModule(ptah.manage.PtahModule):
    """
    REST Introspector
    """

    title = 'REST Introspector'

    def available(self):
        """ check if ptah rest api is enabled """
        return self.request.registry.queryUtility(IRouteRequest,
                                                  'ptah-rest') is not None


@view_config(context=RestModule,
             renderer=ptah.layout('ptahcms.manage:templates/rest.pt'))
class RestModuleView(ptah.View):
    def update(self):
        self.url = self.request.params.get(
            'url', '{0}/__rest__/cms/'.format(self.application_url))