durusmail: quixote-users: Grouch and ZODB
Introducing myself, a small bug and RPMs for Quixote
2001-11-12
2001-11-12
2001-11-13
Seeking a Small Example of Forms/Widget Usage
2001-11-13
2001-11-13
2001-11-22
2001-11-22
2001-11-22
2001-11-23
Re: Seeking a Small Example of Forms/Widget Usage
2001-11-26
2001-11-26
2001-11-27
Mystery re ZODB Technique in vfab
2001-11-28
2001-11-28
An Example of Quixote/ZODB/Grouch Usage
2001-11-29
2001-11-13
Grouch and ZODB
2001-11-20
2001-11-21
2001-11-21
2001-11-21
2001-11-21
Grouch and ZODB
Jeff Rush
2001-11-20
Greg Ward wrote:
>
> 
> Of course, Python's free-form way is not without its dangers and large,
> long-term projects.  When you start thinking about type-checking your
> database, look into Grouch:
>   http://www.mems-exhange.org/software/grouch/
> 

Thanks, I've packaged up Grouch as an RPM as well and am playing with
it.  It works fine with the pickle example but seems to have a bit of
'magic' when using it with ZODB.

When generating the schema using:

  /usr/bin/gen_schema -p windmill/windmill.proj -o
windmill/windmill_schema.pkl -t windmill_schema.txt -d .

I get a lot of errors, although it proceeds to generate the schema
pickle:

error: windmill.transaction.TransactionDict: invalid base class
'Persistence.Persistent' (no such class or alias)
error: windmill.bankstatement.BankStatementDict: invalid base class
'Persistence.Persistent' (no such class or alias)
error: windmill.journal.JournalDict: invalid base class
'Persistence.Persistent' (no such class or alias)
error: windmill.venture.VentureDict: invalid base class
'Persistence.Persistent' (no such class or alias)
error: windmill.ledger.LedgerDict: invalid base class
'Persistence.Persistent' (no such class or alias)
error: windmill.employee.EmployeeDict: invalid base class
'Persistence.Persistent' (no such class or alias)
error: windmill.accthash.AcctHashDict: invalid base class
'Persistence.Persistent' (no such class or alias)
error: windmill.owner.OwnerDict: invalid base class
'Persistence.Persistent' (no such class or alias)
error: windmill.ledgeradjust.LedgerAdjustDict: invalid base class
'Persistence.Persistent' (no such class or alias)

The exclude_classes[] in .proj doesn't seem to affect these error
messages.

And when I check the schema against a basic ZODB:

  /usr/bin/check_data --format zodb --storage client --root-name root
--root-type PersistentMapping windmill/windmill_schema.pkl
localhost:6333

I always get the following:

Checking object graph...
found 0 error(s)

even when I introduce errors into the ZODB.  Grouch doesn't seem to have
a switch to have it
report details while it traverses the object graph and the Grouch source
is not trivial to
understand - cool but not obvious.

My root ZODB object is (I tried both figuring Grouch might auto-traverse
only one of the two):

root['ventures'] = Venture()
root.ventures = Venture()

where Venture() is a known class to Grouch, with a schema docstring.

My project file looks like:

import sys
sys.path.append('/usr/share/zope')
sys.path.append('/usr/share/zope/lib/python')

import os, ZEO.ClientStorage, ZServer
from ZODB import DB

import Persistence
from Persistence import Persistent, PersistentMapping

atomic_types = [
  (PersistentMapping(), "PersistentMapping"),
]

dirs = ["windmill"]
exclude_classes = ["Persistence.Persistent"]

Any good examples of a .proj file suitable for use with ZODB?

-Jeff