Esempio n. 1
0
def page(_context, name, permission, for_,
         layer=IDefaultBrowserLayer, template=None, class_=None,
         allowed_interface=None, allowed_attributes=None,
         attribute='__call__', menu=None, title=None,
         facet=None):
    """Like the standard 'page' directive, but with an added 'facet' optional
    argument.

    If a facet is specified, then it will be available from the view class
    as __launchpad_facetname__.
    """
    facet = facet or getattr(_context, 'facet', None)
    if facet is None:
        new_class = class_
    else:
        cdict = {'__launchpad_facetname__': facet}
        if class_ is None:
            new_class = type('SimpleLaunchpadViewClass', (), cdict)
        else:
            new_class = type(class_.__name__, (class_, object), cdict)

    original_page(_context, name, permission, for_,
        layer=layer, template=template, class_=new_class,
        allowed_interface=allowed_interface,
        allowed_attributes=allowed_attributes,
        attribute=attribute, menu=menu, title=title)
Esempio n. 2
0
def feeds(_context, module, classes):
    """Handler for the `IFeedsDirective`."""
    if not inspect.ismodule(module):
        raise TypeError("module attribute must be a module: %s, %s" % module,
                        type(module))

    for feedclassname in classes:
        feedclass = getattr(module, feedclassname)

        for_ = feedclass.usedfor

        feedname = feedclass.feedname

        atom_name = '%s.atom' % feedname
        html_fragment_name = '%s.html' % feedname
        javascript_name = '%s.js' % feedname

        layer = FeedsLayer

        for name in atom_name, html_fragment_name, javascript_name:
            original_page(_context,
                          name,
                          PublicPermission,
                          for_,
                          layer=layer,
                          class_=feedclass)
Esempio n. 3
0
def favicon(_context, for_, file):
    class Favicon(FaviconRendererBase):
        path = file
        data = open(file, 'rb').read()

    name = "favicon.ico"
    permission = CheckerPublic
    original_page(_context, name, permission, for_, class_=Favicon)
Esempio n. 4
0
def favicon(_context, for_, file):
    class Favicon(FaviconRendererBase):
        path = file
        data = open(file, 'rb').read()

    name = "favicon.ico"
    permission = CheckerPublic
    original_page(_context, name, permission, for_, class_=Favicon)
Esempio n. 5
0
def page(_context,
         name,
         permission,
         for_,
         layer=IDefaultBrowserLayer,
         template=None,
         class_=None,
         allowed_interface=None,
         allowed_attributes=None,
         attribute='__call__',
         menu=None,
         title=None,
         facet=None):
    """Like the standard 'page' directive, but with an added 'facet' optional
    argument.

    If a facet is specified, then it will be available from the view class
    as __launchpad_facetname__.
    """
    facet = facet or getattr(_context, 'facet', None)
    if facet is None:
        new_class = class_
    else:
        cdict = {'__launchpad_facetname__': facet}
        if class_ is None:
            new_class = type('SimpleLaunchpadViewClass', (), cdict)
        else:
            new_class = type(class_.__name__, (class_, object), cdict)

    original_page(_context,
                  name,
                  permission,
                  for_,
                  layer=layer,
                  template=template,
                  class_=new_class,
                  allowed_interface=allowed_interface,
                  allowed_attributes=allowed_attributes,
                  attribute=attribute,
                  menu=menu,
                  title=title)
Esempio n. 6
0
def feeds(_context, module, classes):
    """Handler for the `IFeedsDirective`."""
    if not inspect.ismodule(module):
        raise TypeError("module attribute must be a module: %s, %s" %
                        module, type(module))

    for feedclassname in classes:
        feedclass = getattr(module, feedclassname)

        for_ = feedclass.usedfor

        feedname = feedclass.feedname

        atom_name = '%s.atom' % feedname
        html_fragment_name = '%s.html' % feedname
        javascript_name = '%s.js' % feedname

        layer = FeedsLayer

        for name in atom_name, html_fragment_name, javascript_name:
            original_page(_context, name, PublicPermission, for_,
                          layer=layer, class_=feedclass)