How to use the grok.PageTemplate function in grok

To help you get started, we’ve selected a few grok examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zopefoundation / grok / src / grok / ftests / form / templateform.py View on Github external
"""
import grok
from zope import schema

class Mammoth(grok.Model):
    class fields:
        name = schema.TextLine(title=u"Name")
        size = schema.TextLine(title=u"Size", default=u"Quite normal")

class Edit(grok.EditForm):
    pass

class Edit2(grok.EditForm):
    pass

edit2 = grok.PageTemplate('<p>Test edit</p>')

class Edit3(grok.EditForm):
    grok.template('edit2')

class Display(grok.DisplayForm):
    pass

class Display2(grok.DisplayForm):
    pass

display2 = grok.PageTemplate('<p>Test display</p>')

class Display3(grok.DisplayForm):
    grok.template('display2')
github zopefoundation / grok / src / grok / ftests / view / skinclass.py View on Github external
grok.layer(IBasicSkin)

class MySkinLayer(grok.IBrowserRequest):
    pass

class SkinFromClass(grok.Skin):
    grok.layer(MySkinLayer)

class Mammoth(grok.Model):
    pass

class CaveDrawings(grok.View):
    pass

cavedrawings = grok.PageTemplate("""\


<h1>Hello, world!</h1>


""")

class MoreDrawings(grok.View):
    grok.layer(rotterdam)

    def render(self):
        return "Pretty"


class EvenMoreDrawings(grok.View):
    grok.layer(MySkinLayer)
github zopefoundation / grok / src / grok / ftests / traversal / traverser.py View on Github external
grok.context(Herd)

    def traverse(self, name):
        return Mammoth(name)

class Mammoth(grok.Model):

    def __init__(self, name):
        self.name = name

grok.context(Mammoth)

class Index(grok.View):
    pass

index = grok.PageTemplate("""\
github zopefoundation / grok / src / grok / ftests / view / argument.py View on Github external
class RenderWithArguments(grok.View):
    grok.name('render')

    def render(self, message, another):
        return "Message: %s\nAnother: %s" % (message, another)

class UpdateWithArguments(grok.View):
    grok.name('update')
    grok.template('update')

    def update(self, message, another):
        self.message = message
        self.another = another

update = grok.PageTemplate("""
Coming to us from update():
github zopefoundation / grok / src / grok / ftests / url / url.py View on Github external
class Another(grok.View):
    def render(self):
        return self.url()

class YetAnother(grok.View):
    pass

class Multiplier(grok.View):
    def update(self, age=0):
        self.age = age
    
    def render(self):
        return unicode(self.age * 2)

yetanother = grok.PageTemplate('<p>')
</p>
github zopefoundation / grok / src / grok / ftests / traversal / containertraverser.py View on Github external
class Special(grok.Model):
    pass

class SpecialIndex(grok.View):
    grok.context(Special)
    grok.name('index')

    def render(self):
        return "special view"

grok.context(Mammoth)

class Index(grok.View):
    pass

index = grok.PageTemplate("""\
github zopefoundation / grok / src / grok / ftests / view / macros.py View on Github external
dancing = grok.PageTemplate("""\


""")

class GrillDish(grok.View):
    pass

grilldish = grok.PageTemplate("""

""")

class Burnt(grok.View):
    pass

burnt = grok.PageTemplate("""\

""")

class Grilled(grok.View):
    pass

grilled = grok.PageTemplate("""\
github zopefoundation / grok / src / grok / ftests / errorviews / errorviews.py View on Github external
&gt;&gt;&gt; view = getMultiAdapter((Exception(), TestRequest()), name='index')
  &gt;&gt;&gt; print(view())
  
  
  <h1>Something went wrong!</h1>
  <p>Exception()</p>
  
  

"""
import grok

class MockPrincipal(object):
    id = 'mockprincipal'

exceptionview_template = grok.PageTemplate("""\
github zopefoundation / grok / ldapaddressbook / src / ldapaddressbook / addressbook.py View on Github external
def traverse(self, name):
        contact = Contact(name)
        contact.__parent__ = self
        contact.__name__ = name
        return contact

    def listContacts(self):
        return get_contact_list()


class AddressBookListing(grok.View):
    grok.context(AddressBook)
    grok.name("index")


addressbooklisting = grok.PageTemplate("""\


<ul>
    <li>
        <a>Peter Kummer</a></li>
</ul>

""")


class Contact(grok.Model):

    class fields:
        cn = schema.TextLine(title=u"LDAP CN", readonly=True)

        givenName = schema.TextLine(title=u"First name", required=False)