Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"""
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')
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)
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("""\
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():
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>
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("""\
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("""\
>>> view = getMultiAdapter((Exception(), TestRequest()), name='index')
>>> print(view())
<h1>Something went wrong!</h1>
<p>Exception()</p>
"""
import grok
class MockPrincipal(object):
id = 'mockprincipal'
exceptionview_template = grok.PageTemplate("""\
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)