Commit 2e4a4546 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 4a5c217e
......@@ -20,6 +20,7 @@
package zodb_test
import (
"lab.nexedi.com/kirr/go123/mem"
"lab.nexedi.com/kirr/neo/go/zodb"
"lab.nexedi.com/kirr/neo/go/internal/xtesting"
......@@ -41,12 +42,21 @@ func init() {
// The commit is performed via zodb/py.
func ZPyCommit(zurl string, at zodb.Tid, objv ...zodb.IPersistent) (zodb.Tid, error) {
var rawobjv []xtesting.ZRawObject // raw zodb objects data to commit
var bufv []*mem.Buf // buffers to release
defer func() {
for _, buf := range bufv {
buf.Release()
}
}()
for _, obj := range objv {
buf := zodb.PSerialize(obj)
rawobj := xtesting.ZRawObject{
Oid: obj.POid(),
Data: zodb.PSerialize(obj).XData(), // not releasing buf, but its ok
Data: buf.Data,
}
rawobjv = append(rawobjv, rawobj)
bufv = append(bufv, buf)
}
return xtesting.ZPyCommitRaw(zurl, at, rawobjv...)
......
......@@ -108,21 +108,22 @@ type Ghostable interface {
type Stateful interface {
// GetState should return state of the in-RAM object as raw data.
//
// GetState is called only by persistent machinery and only when object
// has its state - in other words only on non-ghost objects.
// It is called by persistency machinery only on non-ghost objects,
// i.e. when the object has its in-RAM state.
//
// XXX buf ownership?
GetState() *mem.Buf
// SetState should set state of the in-RAM object from raw data.
//
// It is called by persistency machinery only on ghost objects, i.e.
// when the objects does not yet have its in-RAM state.
//
// state ownership is not passed to SetState, so if state needs to be
// retained after SetState returns it needs to be incref'ed.
//
// The error returned does not need to have object/setstate prefix -
// persistent machinery is adding such prefix automatically.
//
// XXX SetState is called only on ghost.
SetState(state *mem.Buf) error
}
......
......@@ -30,22 +30,22 @@ import (
// exchanged as Python data.
type PyStateful interface {
// PyGetState should return state of the in-RAM object as Python data.
// Analog of __getstate__() in Python.
//
// PyGetState is called only by persistent machinery and only when
// object has its state - in other words only on non-ghost objects.
// It is analog of __getstate__() in Python.
//
// XXX state ownership?
// It is called by persistency machinery only on non-ghost objects,
// i.e. when the object has its in-RAM state.
PyGetState() interface{}
// PySetState should set state of the in-RAM object from Python data.
//
// It is analog of __setstate__() in Python.
//
// The error returned does not need to have object/setstate prefix -
// persistent machinery is adding such prefix automatically.
// It is called by persistency machinery only on ghost objects, i.e.
// when the objects does not yet have its in-RAM state.
//
// XXX PySetState is called only on ghost.
// The error returned does not need to have object/setstate prefix -
// persistency machinery is adding such prefix automatically.
PySetState(pystate interface{}) error
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment