[z3-checkins] r25420 - in z3/sqlos/trunk/src/sqlos: . ftests testing
jinty at codespeak.net
jinty at codespeak.net
Wed Apr 5 23:26:57 CEST 2006
Author: jinty
Date: Wed Apr 5 23:26:55 2006
New Revision: 25420
Modified:
z3/sqlos/trunk/src/sqlos/container.py
z3/sqlos/trunk/src/sqlos/ftests/adding.txt
z3/sqlos/trunk/src/sqlos/testing/sampleperson.py
Log:
Proibit the sample people (almost like flower people) from being added to any container but a IPersonContainer. Also, unrelatedly, make an event subscriber that will create the testing tables.
Modified: z3/sqlos/trunk/src/sqlos/container.py
==============================================================================
--- z3/sqlos/trunk/src/sqlos/container.py (original)
+++ z3/sqlos/trunk/src/sqlos/container.py Wed Apr 5 23:26:55 2006
@@ -59,13 +59,14 @@
class SQLObjectNameChooser(NameChooser):
-
+ # XXX: This needs unit tests...
+
def chooseName(self, name, obj):
if ISQLObject.providedBy(obj):
# Look for the SQLObject class our object is from, so get all
# allowed factories
for name, factory in zapi.getFactoriesFor(ISQLObject):
- if checkFactory(self, None, factory):
+ if checkFactory(self.context, None, factory):
# get the sqlobject class
utility = zapi.queryUtility(IISQLObject, name)
if utility is None:
Modified: z3/sqlos/trunk/src/sqlos/ftests/adding.txt
==============================================================================
--- z3/sqlos/trunk/src/sqlos/ftests/adding.txt (original)
+++ z3/sqlos/trunk/src/sqlos/ftests/adding.txt Wed Apr 5 23:26:55 2006
@@ -19,6 +19,8 @@
Go to the main interface and add a SQLObject MultiContainer
>>> browser.open('http://localhost/manage')
+ >>> 'SamplePerson' not in str(browser.contents)
+ True
>>> browser.getLink('SQLObject Multi Container').click()
>>> browser.getControl(name='new_value').value = 'multicontainer1'
>>> browser.getControl('Apply').click()
Modified: z3/sqlos/trunk/src/sqlos/testing/sampleperson.py
==============================================================================
--- z3/sqlos/trunk/src/sqlos/testing/sampleperson.py (original)
+++ z3/sqlos/trunk/src/sqlos/testing/sampleperson.py Wed Apr 5 23:26:55 2006
@@ -1,6 +1,6 @@
from sqlobject import *
import transaction
-from zope.interface import implements, classProvides
+from zope.interface import implements, classProvides, Interface
from zope.schema import TextLine, Text, Datetime
from zope.app.container import constraints
@@ -9,6 +9,10 @@
from sqlos.interfaces.container import ISQLObjectContainer
from sqlos.container import SQLObjectContainer, SQLIsolatedContainer
+def createTestingTablesSubscriber(obj):
+ # An event subscriber that can be used to create the testing tables
+ createTestingTables()
+
def createTestingTables():
"""Creates the tables of the SQLObject calsses defined here."""
transaction.get().commit()
@@ -36,18 +40,14 @@
description=u"The user's password")
-class SamplePerson(SQLOS):
-
- implements(IPerson)
+class IPersonContainer(ISQLObjectContainer):
- fullname = StringCol(length=50, notNull=1)
- username = StringCol(length=20, notNull=1)
- password = StringCol(length=20, notNull=1)
+ constraints.contains(IPerson)
-class IPersonContainer(ISQLObjectContainer):
+class IPersonContained(Interface):
- constraints.contains(IPerson)
+ constraints.containers(IPersonContainer)
class SamplePersonContainer(SQLObjectContainer):
@@ -55,6 +55,15 @@
implements(IPersonContainer)
+class SamplePerson(SQLOS):
+
+ implements(IPerson, IPersonContained)
+
+ fullname = StringCol(length=50, notNull=1)
+ username = StringCol(length=20, notNull=1)
+ password = StringCol(length=20, notNull=1)
+
+
class SampleIsolatedPerson(SQLOS):
classProvides(IISQLObjectIsolated)
@@ -119,7 +128,7 @@
owner = StringCol(length=20, notNull=1)
-class IMultiContainer(ISQLObjectContainer):
+class IMultiContainer(IPersonContainer):
constraints.contains(IDog, IPerson)
More information about the z3-checkins
mailing list