[Checkins] SVN: grok/branches/grok1.1-new-grokcore/ Using for now mr.developper to include the dev version of grokcore.content.
Souheil CHELFOUH
souheil at chelfouh.com
Sun Jan 3 18:05:15 EST 2010
Log message for revision 107606:
Using for now mr.developper to include the dev version of grokcore.content.
The imports have been changed to use the new grokcore.content. All tests pass.
Changed:
U grok/branches/grok1.1-new-grokcore/buildout.cfg
U grok/branches/grok1.1-new-grokcore/setup.py
U grok/branches/grok1.1-new-grokcore/src/grok/__init__.py
U grok/branches/grok1.1-new-grokcore/src/grok/components.py
-=-
Modified: grok/branches/grok1.1-new-grokcore/buildout.cfg
===================================================================
--- grok/branches/grok1.1-new-grokcore/buildout.cfg 2010-01-03 23:03:38 UTC (rev 107605)
+++ grok/branches/grok1.1-new-grokcore/buildout.cfg 2010-01-03 23:05:14 UTC (rev 107606)
@@ -16,8 +16,19 @@
grokdocs
grokwiki
versions = versions
-extensions = buildout.dumppickedversions
+extensions = buildout.dumppickedversions mr.developer
+sources = sources
+auto-checkout = grokcore.content
+
+[sources]
+grokcore.content = svn svn://svn.zope.org/repos/main/grokcore.content/trunk
+
+
+[versions]
+grokcore.content = 1.0dev
+
+
[docs]
recipe = zc.recipe.egg
eggs = grokdocs
Modified: grok/branches/grok1.1-new-grokcore/setup.py
===================================================================
--- grok/branches/grok1.1-new-grokcore/setup.py 2010-01-03 23:03:38 UTC (rev 107605)
+++ grok/branches/grok1.1-new-grokcore/setup.py 2010-01-03 23:05:14 UTC (rev 107606)
@@ -48,6 +48,7 @@
'grokcore.formlib >= 1.4',
'grokcore.security >= 1.1',
'grokcore.site',
+ 'grokcore.content',
'grokcore.view >= 1.12',
'grokcore.viewlet >= 1.3',
'martian >= 0.10, < 0.12',
Modified: grok/branches/grok1.1-new-grokcore/src/grok/__init__.py
===================================================================
--- grok/branches/grok1.1-new-grokcore/src/grok/__init__.py 2010-01-03 23:03:38 UTC (rev 107605)
+++ grok/branches/grok1.1-new-grokcore/src/grok/__init__.py 2010-01-03 23:05:14 UTC (rev 107606)
@@ -25,6 +25,8 @@
from grokcore.component.directive import (
context, name, title, description, provides, global_utility, direct)
+from grokcore.content import Model, Container, OrderedContainer
+
from grokcore.security import Permission
from grokcore.security import Public
from grokcore.security import require
@@ -79,11 +81,10 @@
ContainerModifiedEvent)
from grok.events import ApplicationInitializedEvent
-from grok.components import Model, View
+from grok.components import Application
+from grok.components import View, Form, AddForm, EditForm, DisplayForm
from grok.components import XMLRPC, REST, JSON
from grok.components import Traverser
-from grok.components import Container, OrderedContainer
-from grok.components import Application, Form, AddForm, EditForm, DisplayForm
from grok.components import Indexes
from grok.components import Role
from grok.interfaces import IRESTSkinType, IRESTLayer
Modified: grok/branches/grok1.1-new-grokcore/src/grok/components.py
===================================================================
--- grok/branches/grok1.1-new-grokcore/src/grok/components.py 2010-01-03 23:03:38 UTC (rev 107605)
+++ grok/branches/grok1.1-new-grokcore/src/grok/components.py 2010-01-03 23:05:14 UTC (rev 107606)
@@ -18,7 +18,6 @@
provided here.
"""
-import persistent
import simplejson
import zope.location
@@ -36,9 +35,6 @@
from zope.container.btree import BTreeContainer
from zope.container.contained import Contained
from zope.container.interfaces import IReadContainer
-from zope.container.interfaces import IOrderedContainer
-from zope.container.contained import notifyContainerModified
-from persistent.list import PersistentList
import grok
import z3c.flashmessage.interfaces
@@ -47,108 +43,9 @@
import grokcore.view
import grokcore.site
from grok import interfaces, util
+from grokcore.content import Model, Container, OrderedContainer
-class Model(Contained, persistent.Persistent):
- # XXX Inheritance order is important here. If we reverse this,
- # then containers can't be models anymore because no unambigous MRO
- # can be established.
- """The base class for models in Grok applications.
-
- When an application class inherits from `grok.Model`, it gains the
- ability to persist itself in the Zope object database along with all
- of its attributes, and to remember the container in which it has
- been placed (its "parent") so that its URL can be computed. It also
- inherits the `IContext` marker interface, which can make it the
- default context for views in its module; the rule is that if a
- module contains `grok.View` classes or other adapters that do not
- define a `grok.context()`, but the module also defines exactly one
- class that provides the `IContext` interface, then that class will
- automatically be made the `grok.context()` of each of the views.
-
- """
- interface.implements(IAttributeAnnotatable, interfaces.IContext)
-
-
-class Container(BTreeContainer):
- """The base class for containers in Grok applications.
-
- When an application class inherits from `grok.Container`, it not
- only has the features of a `grok.Model` (persistance, location, and
- the ability to serve as a default context for other classes), but it
- also behaves like a persistent dictionary. To store items inside a
- container, simply use the standard Python getitem/setitem protocol::
-
- mycontainer['counter'] = 72
- mycontainer['address'] = mymodel
- mycontainer['subfolder'] = another_container
-
- By default, the URL of each item inside a container is the
- container's own URL followed by a slash and the key (like 'counter'
- or 'address') under which that item has been stored.
-
- """
- interface.implements(IAttributeAnnotatable, interfaces.IContainer)
-
-
-class OrderedContainer(Container):
- """A Grok container that remembers the order of its items.
-
- This straightforward extension of the basic `grok.Container`
- remembers the order in which items have been inserted, so that
- `keys()`, `values()`, `items()`, and iteration across the container
- can all return the items in the order they were inserted. The only
- way of changing the order is to call the `updateOrder()` method.
-
- """
- interface.implements(IOrderedContainer)
-
- def __init__(self):
- super(OrderedContainer, self).__init__()
- self._order = PersistentList()
-
- def keys(self):
- # Return a copy of the list to prevent accidental modifications.
- return self._order[:]
-
- def __iter__(self):
- return iter(self.keys())
-
- def values(self):
- return (self[key] for key in self._order)
-
- def items(self):
- return ((key, self[key]) for key in self._order)
-
- def __setitem__(self, key, object):
- foo = self.has_key(key)
- # Then do whatever containers normally do.
- super(OrderedContainer, self).__setitem__(key, object)
- if not foo:
- self._order.append(key)
-
- def __delitem__(self, key):
- # First do whatever containers normally do.
- super(OrderedContainer, self).__delitem__(key)
- self._order.remove(key)
-
- def updateOrder(self, order):
- """Impose a new order on the items in this container.
-
- Items in this container are, by default, returned in the order
- in which they were inserted. To change the order, provide an
- argument to this method that is a sequence containing every key
- already in the container, but in a new order.
-
- """
- if set(order) != set(self._order):
- raise ValueError("Incompatible key set.")
-
- self._order = PersistentList()
- self._order.extend(order)
- notifyContainerModified(self)
-
-
class Application(grokcore.site.Site):
"""Mixin for creating Grok application objects.
More information about the checkins
mailing list