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

.

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