Commit 785acadf authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 873b5e4b
......@@ -105,7 +105,7 @@ type object struct {
mu sync.Mutex
state ObjectState
refcnt int32
instance Object
instance Object // object should be the base for the instance
loading *loadState
}
......@@ -138,7 +138,7 @@ type Stateful interface {
SetState(state *mem.Buf) error
// GetState should return state of the in-RAM object as raw data.
//GetState() *mem.Buf
//GetState() *mem.Buf TODO
}
......@@ -206,7 +206,6 @@ type Connection struct {
objmu sync.Mutex
objtab map[zodb.Oid]*WeakRef // oid -> WeakRef(Object)
// hooks for application to influence live caching decisions.
cacheControl LiveCacheControl
}
......@@ -267,12 +266,13 @@ func (obj *object) PActivate(ctx context.Context) (err error) {
obj.serial = serial
// try to pass loaded state to object
if err == nil {
err = obj.instance.SetState(state) // XXX err ctx
state.Release()
}
if err == nil {
obj.state = UPTODATE
if err == nil {
obj.state = UPTODATE
}
}
loading.err = err
......
......@@ -31,7 +31,7 @@ type PyObject interface {
PyClass() pickle.Class // python class of this object
// PyState() interface{} // object state. python passes this to pyclass.__new__().__setstate__()
// PyObject must be statefule for persistency to work
// PyObject must be stateful for persistency to work
// XXX try to move out of PyObject? Rationale: we do not want e.g. PySetState to
// be available to user who holds PyObject interface: it is confusing to have
// both PActivate and PySetState at the same time.
......@@ -50,15 +50,13 @@ func (pyobj *pyObject) PyClass() pickle.Class { return pyobj.pyclass }
// PyStateful is the interface describing in-RAM object whose data state can be
// exchanged as Python data.
type PyStateful interface {
//Stateful XXX no need here?
// PySetState should set state of the in-RAM object from Python data.
// Analog of __setstate__() in Python.
PySetState(pystate interface{}) error
// PyGetState should return state of the in-RAM object as Python data.
// Analog of __getstate__() in Python.
//PyGetState() interface{} XXX
//PyGetState() interface{} TODO
}
// ---- pyObject <-> object state exchange ----
......@@ -78,7 +76,7 @@ func (pyobj *pyObject) SetState(state *mem.Buf) error {
}
if pyclass != pyobj.pyclass {
// complain pyclass changed
// complain that pyclass changed
// (both ref and object data use pyclass so it indeed can be different)
return &wrongClassError{want: pyobj.pyclass, have: pyclass} // XXX + err ctx
}
......@@ -90,6 +88,7 @@ func (pyobj *pyObject) SetState(state *mem.Buf) error {
// ---- pyclass -> new ghost ----
// function representing new of a class.
type pyClassNewFunc func(base *pyObject) PyObject
// path(pyclass) -> new(pyobj)
......
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