Skip to content

Commit

Permalink
Update grokwiki example.
Browse files Browse the repository at this point in the history
  • Loading branch information
thefunny42 committed Jan 13, 2016
1 parent b4c95e1 commit 5f6a96a
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 26 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ eggs
.mr.developer.cfg
parts
src/*.egg-info
var/
2 changes: 1 addition & 1 deletion etc/site.zcml.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<include package="grokwiki" />

<configure i18n_domain="grokwiki">

<unauthenticatedPrincipal id="zope.anybody"
title="Unauthenticated User" />
<unauthenticatedGroup id="zope.Anybody"
Expand Down
4 changes: 2 additions & 2 deletions etc/zope.conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ site-definition ${site_zcml:output}

# This sets up logging to to standard output.
# The "path" setting can be the tokens STDOUT or STDERR

# <logfile>
# path STDOUT
# formatter zope.exceptions.log.Formatter
Expand All @@ -39,4 +39,4 @@ site-definition ${site_zcml:output}

# Comment this line to disable developer mode. This should be done in
# production
devmode on
devmode on
11 changes: 3 additions & 8 deletions grokwiki.cfg
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
[buildout]
extends = http://svn.zope.org/repos/main/groktoolkit/trunk/grok.cfg
parts = grokwiki
develop =
.
grokwiki
versions = versions
extensions = buildout.dumppickedversions
extends = buildout.cfg
parts += grokwiki

[versions]
grok =

[grokwiki]
recipe = z3c.recipe.scripts
recipe = zc.recipe.egg
eggs =
grokwiki
Paste
Expand Down
18 changes: 8 additions & 10 deletions grokwiki/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
version='0.1',
author='Grok Team',
author_email='grok-dev@zope.org',
url='http://svn.zope.org/grok/trunk',
url='https://github.com/zopefoundation/grok',
description="""\
Grok: Now even cavemen can use wikis!
""",
packages=find_packages('src'),
package_dir = {'': 'src'},
include_package_data = True,
package_dir={'': 'src'},
include_package_data=True,
zip_safe=False,
license='ZPL',

Expand All @@ -21,11 +21,9 @@
'grokcore.startup',
'grokcore.message',
],
entry_points = """
[console_scripts]
grokwiki-debug = grokcore.startup:interactive_debug_prompt
grokwiki-ctl = grokcore.startup:zdaemon_controller
[paste.app_factory]
main = grokcore.startup:application_factory
""",
entry_points="""
[console_scripts]
interactive_debug_prompt = grokcore.startup.startup:interactive_debug_prompt
[paste.app_factory]
main = grokcore.startup:application_factory""",
)
12 changes: 8 additions & 4 deletions grokwiki/src/grokwiki/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,33 +45,37 @@ class Index(grok.View):
def update(self):
wiki_url = self.url(self.context.__parent__)
self.rendered_text, replacements = (
LINK_PATTERN.subn(r'<a href="%s/\1">\1</a>' % wiki_url,
self.context.text))
LINK_PATTERN.subn(
r'<a href="%s/\1">\1</a>' % wiki_url, self.context.text))


class Edit(grok.View):

def update(self):
text = self.request.form.get('wikidata')
if not text:
return # Just render the template
return # Just render the template

# Update the text and redirect
self.context.update(text)
self.flash('Saved.')
self.redirect(self.url(self.context))


class Messages(grok.View):
@property
def messages(self):
receiver = component.getUtility(IMessageReceiver)
return receiver.receive()


class WikiLayer(grok.IRESTLayer):
# This skin will be visible as http://localhost:8080/++rest++wiki/...
grok.restskin('wiki')


class PageRest(grok.REST):
grok.layer(WikiLayer)

def GET(self):
return "Hello world"
8 changes: 7 additions & 1 deletion grokwiki/src/grokwiki/wiki.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,33 @@
import grok
import grokwiki.page


class Wiki(grok.Application, grok.Container):
"""This is Grok's sample wiki application."""


class Index(grok.View):
def render(self):
self.redirect(self.url('home'))


class Hello(grok.View):
grok.baseclass()

def render(self):
return "Hello"


class Hoi(Hello):
def render(self):
return "Hoi"


class Bonjour(Hello):
def render(self):
return "Bonjour"


@grok.subscribe(Wiki, grok.IObjectAddedEvent)
def setupHomepage(wiki, event):
"""Creates a home page for every wiki."""
Expand Down

0 comments on commit 5f6a96a

Please sign in to comment.