class GoldViewlet(grok.Viewlet):
    grok.order(1)
    grok.viewletmanager(CaveManager)
    grok.name('Gold')

    def render(self):
        return u"Gold"
class WilmaViewlet(grok.Viewlet):
    grok.order(50)
    grok.viewletmanager(CaveManager)
    grok.name('Wilma')

    def render(self):
        return u"Wilma"
class FredViewlet(grok.Viewlet):
    grok.order(20)
    grok.viewletmanager(CaveManager)
    grok.name('Fred')

    def render(self):
        return u"Fred"
class BoneViewlet(grok.Viewlet):
    grok.order(10)
    grok.viewletmanager(CaveManager)
    grok.name('Bone')

    def render(self):
        return u"Bone"
class NamedViewlet(grok.Viewlet):
    grok.context(Interface)
    grok.name('viewletwithname')
    grok.viewletmanager(NamedViewletManager)

    def render(self):
        return u"NamedViewlet"
class CaveViewlet(grok.Viewlet):
    grok.order(30)
    grok.viewletmanager(CaveManager)
    grok.name('Cave')

    def render(self):
        return u"Cave"
class LadyViewlet(grok.Viewlet):
    grok.context(Interface)
    grok.viewletmanager(Pot)
    grok.view(FireView)

    def render(self):
        return u"Lady Viewlet"
class LayeredBone(grok.Viewlet):
    grok.context(Interface)
    grok.viewletmanager(Pot)
    grok.layer(IBoneLayer)

    def render(self):
        return u"Layered Bone"
class GoldBone(grok.Viewlet):
    grok.context(Interface)
    grok.viewletmanager(Pot)
    grok.require('bone.gold')

    def render(self):
        return u"Gold Bone"
class ElephantBone(grok.Viewlet):
    grok.context(Interface)
    grok.viewletmanager(Bones)

    def available(self):
        # This type of bone has not evolved just yet.
        return False

    def render(self):
        return u"Elephant Bone"
class SabreToothBone(grok.Viewlet):
    grok.context(Interface)
    grok.viewletmanager(Bones)

    _available = False

    def available(self):
        return self._available

    def render(self):
        return u"Sabre Tooth Bone"
Beispiel #12
0
class NoExplicitOrderBarneyViewlet(grok.Viewlet):
    grok.name('barney')
    grok.viewletmanager(CaveManager2)

    def render(self):
        return u"Barney"
Beispiel #13
0
class NoExplicitOrderCaveViewlet(grok.Viewlet):
    grok.name('cave')
    grok.viewletmanager(CaveManager2)

    def render(self):
        return u"Cave"
class MirandaViewlet(grok.Viewlet):
    grok.template('mirandaviewlet')
    grok.view(Index)
    grok.viewletmanager(CavewomenViewletManager)
Beispiel #15
0
class FredViewlet(grok.Viewlet):
    grok.viewletmanager(CavemenViewletManager)
class TRexBone(grok.Viewlet):
    grok.context(Interface)
    grok.viewletmanager(Bones)

    def render(self):
        return u"T-Rex Bone"
class BrackerBone(grok.Viewlet):
    grok.context(Interface)
    grok.viewletmanager(Bones)

    def render(self):
        return u"Brack Bone"
Beispiel #18
0
class Viewlet(grok.Viewlet):
    grok.viewletmanager(ViewletManager)
    grok.context(Interface)

    def render(self):
        return u"Render method but also a template!"
Beispiel #19
0
class FredViewlet(grok.Viewlet):
    grok.viewletmanager(CavemenViewletManager)

    def render(self):
        return u"Me Fred"
class BarneyViewlet(grok.Viewlet):
    grok.order(60)
    grok.viewletmanager(CaveManager)
    grok.name('Barney')
class ManBone(grok.Viewlet):
    grok.viewletmanager(Pot)
    grok.context(CaveMan)

    def render(self):
        return u"Man Bone"
Beispiel #22
0
class BarneyViewlet(grok.Viewlet):
    grok.order(60)
    grok.viewletmanager(CaveManager)

    def render(self):
        return u"Barney"
registered for the default layer, with the anybody permission::

  >>> from zope.app.wsgi.testlayer import Browser
  >>> browser = Browser()
  >>> browser.handleErrors = False
  >>> browser.open("http://localhost/fred/@@boneview")
  >>> print browser.contents
  Fred viewlet

"""

import grokcore.viewlet as grok

class Fred(grok.Context):
    pass

class BoneView(grok.View):
    pass

class BoneManager(grok.ViewletManager):
    grok.name('bone')

class CaveManager(grok.ViewletManager):
    grok.name('cave')

grok.viewletmanager(CaveManager)

class FredViewlet(grok.Viewlet):
    def render(self):
        return u"Fred viewlet"
  >>> print(browser.contents)
  Fred viewlet

"""

import grokcore.viewlet as grok


class Fred(grok.Context):
    pass


class BoneView(grok.View):
    pass


class BoneManager(grok.ViewletManager):
    grok.name('bone')


class CaveManager(grok.ViewletManager):
    grok.name('cave')


grok.viewletmanager(CaveManager)


class FredViewlet(grok.Viewlet):
    def render(self):
        return u"Fred viewlet"