Commit 90821a24 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 1d8b1e10
......@@ -30,5 +30,5 @@ var ZPyCommit func(string, Tid, ...IPersistent) (Tid, error)
// exported for zodb_test package:
func PSerialize(obj IPersistent) *mem.Buf {
return obj.pSerialize()
return obj.persistent().pSerialize()
}
......@@ -76,6 +76,8 @@ type Persistent struct {
loading *loadState
}
func (obj *Persistent) persistent() *Persistent { return obj }
func (obj *Persistent) PJar() *Connection { return obj.jar }
func (obj *Persistent) POid() Oid { return obj.oid }
......@@ -130,9 +132,12 @@ type Stateful interface {
SetState(state *mem.Buf) error
}
// ---- serialize ----
// ---- RAM -> DB: serialize ----
// pSerialize implements IPersistent.
// pSerialize returns object in serialized form to be saved in the database.
//
// pSerialize is non-public method that is exposed and used only by ZODB internally.
// pSerialize is called only on non-ghost objects.
func (obj *Persistent) pSerialize() *mem.Buf {
obj.mu.Lock()
defer obj.mu.Unlock()
......@@ -152,7 +157,7 @@ func (obj *Persistent) pSerialize() *mem.Buf {
}
}
// ---- activate/deactivate/invalidate ----
// ---- RAM <- DB: activate/deactivate/invalidate ----
// PActivate implements IPersistent.
func (obj *Persistent) PActivate(ctx context.Context) (err error) {
......
......@@ -16,8 +16,6 @@ package zodb
import (
"context"
"lab.nexedi.com/kirr/go123/mem"
)
// IPersistent is the interface that every in-RAM object representing any database object implements.
......@@ -100,16 +98,9 @@ type IPersistent interface {
// XXX probably don't need this.
//PState() ObjectState // in-RAM object state.
// XXX move vvv -> iPersistent? (-> into persistent.go)
// XXX do we need to put vvv into IPersistent at all?
// pSerialize returns object in serialized form to be saved in the database.
//
// pSerialize is non-public method that is exposed and used only by ZODB internally.
// pSerialize is called only on non-ghost objects.
//
// XXX more text.
pSerialize() *mem.Buf
// IPersistent can be implemented only by objects that embed Persistent.
persistent() *Persistent
}
// ObjectState describes state of in-RAM object.
......
......@@ -61,9 +61,8 @@ func (d PyData) ClassName() string {
}
// encodePyData encodes Python class and state into raw ZODB python data.
//
// XXX -> pySerialize?
func encodePyData(pyclass pickle.Class, pystate interface{}) PyData {
// XXX better return mem.Buf instead of PyData?
buf := &bytes.Buffer{}
p := pickle.NewEncoderWithConfig(buf, &pickle.EncoderConfig{
......
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