Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to grok 5.0. #23

Merged
merged 4 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions buildout.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,4 @@ exclude =
# that are defined in zc.catalog, including a hoist of (deprecated)
# zope.app.* dependencies.
zc.catalog
# Fanstatic use py.test for testing and compattest cannot deal with that.
fanstatic
runner-defaults = ['--auto-color', '-v', '--auto-progress']
7 changes: 1 addition & 6 deletions dependabot/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
Chameleon==4.5.1
fanstatic==1.4
grok==4.0
grok==5.0
grokcore.annotation==4.0
grokcore.catalog==4.0
grokcore.chameleon==4.0
grokcore.component==4.1
grokcore.content==4.1
grokcore.error==4.0
grokcore.formlib==4.0
grokcore.json==4.1
grokcore.layout==4.0
grokcore.message==4.0
grokcore.security==4.0
Expand All @@ -17,7 +15,6 @@ grokcore.startup==4.0
grokcore.traverser==4.0
grokcore.view==4.0
grokcore.viewlet==4.0
grokcore.xmlrpc==4.1
grokui.admin==1.0
grokui.base==0.8.2
ipython==8.20.0
Expand All @@ -32,7 +29,6 @@ zope.app.debug==4.0.0
zope.app.publication==5.0
zope.app.wsgi==5.0
zope.errorview==2.0
zope.fanstatic==3.0.0
zope.generations==5.1.0
zope.testbrowser==6.0
appnope==0.1.3
Expand All @@ -41,7 +37,6 @@ collective.recipe.omelette==1.1.0
collective.recipe.template==2.2
decorator==5.1.1
gnureadline==8.1.2
grokcore.rest==4.1
ipython-genutils==0.2.0
Paste==3.7.1
pexpect==4.9.0
Expand Down
18 changes: 18 additions & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@

.. note:: The buildout versions file for all current versions can be found at https://zopefoundation.github.io/groktoolkit/

4.0 (unreleased)
----------------

- Update to ``grok 5.0``. This requires us to drop support for:
icemac marked this conversation as resolved.
Show resolved Hide resolved

- ``grokcore.xmlrpc``

- ``grokcore.rest``

- ``grokcore.json``

- Drop support ``zope.fanstatic``, as this repository has been archived and
does not support Python 3.12.

- Remove ``fanstatic`` from the list of version pins as it was only needed by
``zope.fanstatic``.


3.0 (2023-12-20)
----------------

Expand Down
11 changes: 0 additions & 11 deletions docs/design/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,3 @@ def whatever(self, **data):
XXX render actions
</form>
""")


class CalculatorXMLRPC(grok.XMLRPC):

@grok.require('zope.Public') # this is actually the default
def sum(self, operand, operator, operand2):
return ...

@grok.require('something.else')
def whatever(self):
return ...
202 changes: 0 additions & 202 deletions docs/reference/components.rst
Original file line number Diff line number Diff line change
Expand Up @@ -987,208 +987,6 @@ main content area and a footer.

This method renders the content provided by this Viewlet.


:class:`grok.JSON`
==================

Specialized View that returns data in JSON format.

Python data returned is automatically converted into JSON format using
the simplejson library. Every method name in a grok.JSON component is
registered as the name of a JSON View. The exceptions are names that
begin with an _ or special names such as __call__. The grok.require
decorator can be used to protect methods with a permission.

.. autoclass:: grok.JSON

.. attribute:: context

Object that the JSON handler presents.

.. attribute:: request

Request that JSON handler was looked up with.

.. autoattribute:: response

The response sent back to the client.

.. attribute:: body

The text of the request body.

.. automethod:: redirect

Redirect to `url`.

The headers of the :attr:`response` are modified so that the
calling browser gets a redirect status code. Please note, that
this method returns before actually sending the response to
the browser.

`url` is a string that can contain anything that makes sense
to a browser. Also relative URIs are allowed.

`status` is a number representing the HTTP status code sent
back. If not given or ``None``, ``302`` or ``303`` will be
sent, depending on the HTTP protocol version in use (HTTP/1.0
or HTTP/1.1).

`trusted` is a boolean telling whether we're allowed to
redirect to 'external' hosts. Normally redirects to other
hosts than the one the request was sent to are forbidden and
will raise a :exc:`ValueError`.

.. automethod:: url

.. automethod:: publishTraverse

Lookup a name and return an object with `self.context` as its parent.
The method can use the request to determine the correct object.

The `request` argument is the publisher request object. The
`name` argument is the name that is to be looked up. It must
be an ASCII string or Unicode object.

If a lookup is not possible, raise a :exc:`NotFound` error.

.. automethod:: browserDefault

Returns an object and a sequence of names.

The publisher calls this method at the end of each traversal path.
If the sequence of names is not empty, then a traversal step is made
for each name. After the publisher gets to the end of the sequence,
it will call browserDefault on the last traversed object.

The default behaviour in Grok is to return `self.context` for
the object and ``'index'`` for the default view name.

Note that if additional traversal steps are indicated (via a
nonempty sequence of names), then the publisher will try to adjust
the base href.


**Example 1: Create a public and a protected JSON view.**

.. code-block:: python

class MammothJSON(grok.JSON):
"""
Returns JSON from URLs in the form of:

http://localhost/stomp
http://localhost/dance
"""

grok.context(zope.interface.Interface)

def stomp(self):
return {'Manfred stomped.': ''}

@grok.require('zope.ManageContent')
def dance(self):
return {'Manfred does not like to dance.': ''}


:class:`grok.REST`
==================

Specialized View for making web services that conform to the REST style.
These Views can define methods named GET, PUT, POST and DELETE, which will
be invoked based on the Request type.

.. autoclass:: grok.REST

.. attribute:: context

Object that the REST handler presents.

.. attribute:: request

Request that REST handler was looked up with.

.. autoattribute:: response

The response sent back to the client.

.. autoattribute:: body

The text of the request body.

.. automethod:: url

.. automethod:: redirect

Redirect to `url`.

The headers of the :attr:`response` are modified so that the
calling browser gets a redirect status code. Please note, that
this method returns before actually sending the response to
the browser.

`url` is a string that can contain anything that makes sense
to a browser. Also relative URIs are allowed.

`status` is a number representing the HTTP status code sent
back. If not given or ``None``, ``302`` or ``303`` will be
sent, depending on the HTTP protocol version in use (HTTP/1.0
or HTTP/1.1).

`trusted` is a boolean telling whether we're allowed to
redirect to 'external' hosts. Normally redirects to other
hosts than the one the request was sent to are forbidden and
will raise a :exc:`ValueError`.


:class:`grok.XMLRPC`
====================

Specialized View that responds to XML-RPC.

.. autoclass:: grok.XMLRPC

.. attribute:: context

Object that the REST handler presents.

.. attribute:: request

Request that REST handler was looked up with.

.. autoattribute:: grok.XMLRPC.response

The response sent back to the client.

.. autoattribute:: grok.XMLRPC.body

The text of the request body.

.. automethod:: grok.XMLRPC.url

.. automethod:: grok.XMLRPC.redirect


**Example 1: Create a public and a protected XML-RPC view.**

The grok.require decorator can be used to protect methods with a permission.

.. code-block:: python

import grok
import zope.interface

class MammothRPC(grok.XMLRPC):
grok.context(zope.interface.Interface)

def stomp(self):
return 'Manfred stomped.'

@grok.require('zope.ManageContent')
def dance(self):
return 'Manfred doesn\'t like to dance.'


:class:`grok.Traverser`
=======================

Expand Down
7 changes: 3 additions & 4 deletions docs/reference/decorators.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,20 @@ functionality.

.. function:: require(name_or_class)

The decorated method will be protected by the permission. Used in
web service views such as REST or XML-RPC.
The decorated method will be protected by the permission.


:func:`grok.adapter/grok.implementer` -- declare an adapter factory
====================================================================

These decorators are always used in tandem to declare an adapter factory.

.. function:: grok.adapter(*classes_or_interfaces)
.. function:: grok.adapter(*classes_or_interfaces)

Describes that a function adapts an object or a combination
of objects.

.. function:: grok.implementer(interface)
.. function:: grok.implementer(interface)

Describes that a function that's used as an adapter
implements an interface or a number of interfaces.
Expand Down
15 changes: 5 additions & 10 deletions docs/tutorial_outline.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,22 @@ Models
Once we know how to show things, we need to go into what we're
actually showing: the model. This involves view/model separation,
dealing with the ZODB and persistence, and constructing applications
from models and containers.
from models and containers.

Note that we also include some more advanced view use cases which only
tend to become relevant with more complicated applications (such as
redirection).

* A view for a model

* Storing data

* Redirection

* Showing the value in the form

* The rules of persistence

* Containers

Some notes:
Expand Down Expand Up @@ -134,7 +134,7 @@ widget some dynamic behavior.

XXX we need to make it easy to make widgets in Grok.

XXX this needs work on the Grok end to at least expose JSON, and perhaps
XXX this needs work on the Grok end, and perhaps
we need to ship with a 'recommended' Javascript library.

Security
Expand Down Expand Up @@ -196,11 +196,6 @@ and functional test with doctests.

XXX We probably need to do some development work on a test grokker.

XMLRPC
------

Show how to do XMLRPC with Grok.

Extending grok
--------------

Expand Down
2 changes: 0 additions & 2 deletions documentation.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@ eggs =
grokcore.component
grokcore.content
grokcore.formlib
grokcore.json
grokcore.message
grokcore.security
grokcore.site
grokcore.traverser
grokcore.view
grokcore.viewlet
grokcore.xmlrpc
martian
py
sphinx
Expand Down
Loading