FiveSQLOS --------- FiveSQLOS is a Zope2 product intended to bring the world of sqlos and SQLObject to Zope2. It is based heavily on the Five Zope2 product. It is currently at the prototype stage. Installation Instructions (_very_ incomplete) --------------------------------------------- * Place sqlos on the python path. * Copy FiveSQLOS to the Products directory. A word on Acquisition and SQLObject ----------------------------------- SQLObject is a metaclass, as is Acquisition. You cannot sub-class from both of them. But objects in Zope 2 that do not support acquisition are quite useless. The current solution to this problem is the ItemWrapper from Products.FiveSQLOS.wrapper that supports Acquisition and is an Item. This is wrapped around any SQLObject leaving a container. This wrapper is _not_ perfect, so if you have any ideas, let us know. Example ------- First we set up the test by loading up some zcml and manager account: >>> uf = self.folder.acl_users >>> uf._doAddUser('mgr', 'mgrpw', ['Manager'], []) >>> from Products.Five import zcml >>> import sqlos >>> import Products.FiveSQLOS >>> import zope.rdb >>> zcml.load_config('configure.zcml', package=Products.Five) >>> zcml.load_config('meta.zcml', package=Products.FiveSQLOS) >>> zcml.load_config('meta.zcml', package=zope.rdb) >>> zcml.load_config('meta.zcml', package=sqlos) >>> zcml.load_config('configure.zcml', package=Products.FiveSQLOS) >>> zcml.load_config('configure.zcml', package=sqlos) >>> zcml.load_config('ftesting.zcml', package=sqlos) >>> zcml.load_config('ftesting.zcml', package=Products.FiveSQLOS) Create some tables: >>> from sqlos.testing.sampleperson import createTestingTables >>> createTestingTables() Then we add one of the testing containers to the testing folder. >>> from Products.FiveSQLOS.testing import FiveSamplePersonContainer >>> container = FiveSamplePersonContainer('persons', 'Person Container') >>> self.folder._setObject('persons', container) 'persons' Now we can add a sample person to the container: >>> print http(""" ... POST /test_folder_1_/persons/+/AddPerson.html HTTP/1.1 ... Authorization: Basic mgr:mgrpw ... Content-Type: multipart/form-data; boundary=---------------------------968064918930967154199105236 ... -----------------------------968064918930967154199105236 ... Content-Disposition: form-data; name="field.username" ... ... joeuser ... -----------------------------968064918930967154199105236 ... Content-Disposition: form-data; name="field.password" ... ... joepass ... -----------------------------968064918930967154199105236 ... Content-Disposition: form-data; name="field.fullname" ... ... Joe ... -----------------------------968064918930967154199105236 ... Content-Disposition: form-data; name="UPDATE_SUBMIT" ... ... Add ... """, handle_errors=False) HTTP/1.1 302 Moved Temporarily ... Let's find the id assigned to the person: >>> len(container) # If this fails, there is a dirty test somewhere 1 >>> person_id = list(container.items())[0][0].encode('ascii') Check we can see the person: >>> print http(""" ... GET /test_folder_1_/persons/%s HTTP/1.1 ... Authorization: Basic mgr:mgrpw ... """ % person_id, handle_errors=False) HTTP/1.1 200 OK ... And then edit them: >>> print http(""" ... POST /test_folder_1_/persons/%s/edit.html HTTP/1.1 ... Authorization: Basic mgr:mgrpw ... Content-Type: multipart/form-data; boundary=---------------------------968064918930967154199105236 ... -----------------------------968064918930967154199105236 ... Content-Disposition: form-data; name="field.username" ... ... janeuser ... -----------------------------968064918930967154199105236 ... Content-Disposition: form-data; name="field.password" ... ... janepass ... -----------------------------968064918930967154199105236 ... Content-Disposition: form-data; name="field.fullname" ... ... Jane ... -----------------------------968064918930967154199105236 ... Content-Disposition: form-data; name="UPDATE_SUBMIT" ... ... Change ... """ % person_id, handle_errors=False) HTTP/1.1 200 OK ... And check if the editing worked: >>> print http(""" ... GET /test_folder_1_/persons/%s HTTP/1.1 ... Authorization: Basic mgr:mgrpw ... """ % person_id) HTTP/1.1 200 OK ... ...janeuser... ... cleaning up: >>> from sqlos.testing.sampleperson import dropTestingTables >>> dropTestingTables() >>> from zope.app.testing.placelesssetup import tearDown >>> tearDown()