Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
a0db1dd4
Commit
a0db1dd4
authored
Aug 03, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
6368ccd4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
10 deletions
+17
-10
go/zodb/btree/btree.go
go/zodb/btree/btree.go
+0
-4
go/zodb/persistent.go
go/zodb/persistent.go
+9
-2
go/zodb/zodbpy.go
go/zodb/zodbpy.go
+8
-4
No files found.
go/zodb/btree/btree.go
View file @
a0db1dd4
...
...
@@ -177,8 +177,6 @@ func (b *bucketState) DropState() {
// PySetState implements PyStateful to set bucket data from pystate.
func
(
b
*
bucketState
)
PySetState
(
pystate
interface
{})
(
err
error
)
{
defer
xerr
.
Contextf
(
&
err
,
"bucket(%s): setstate"
,
b
.
POid
())
t
,
ok
:=
pystate
.
(
pickle
.
Tuple
)
if
!
ok
{
return
fmt
.
Errorf
(
"top: expect (...); got %T"
,
pystate
)
...
...
@@ -264,8 +262,6 @@ func (t *btreeState) DropState() {
// PySetState implements zodb.PyStateful to set btree data from pystate.
func
(
bt
*
btreeState
)
PySetState
(
pystate
interface
{})
(
err
error
)
{
defer
xerr
.
Contextf
(
&
err
,
"btree(%s): setstate"
,
bt
.
POid
())
// empty btree
if
_
,
ok
:=
pystate
.
(
pickle
.
None
);
ok
{
bt
.
firstbucket
=
nil
...
...
go/zodb/persistent.go
View file @
a0db1dd4
...
...
@@ -21,6 +21,7 @@ import (
"sync"
"lab.nexedi.com/kirr/go123/mem"
"lab.nexedi.com/kirr/go123/xerr"
)
// IPersistent is the interface that every in-RAM object representing any database object implements.
...
...
@@ -187,6 +188,9 @@ type Stateful interface {
//
// 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.
SetState
(
state
*
mem
.
Buf
)
error
// GetState should return state of the in-RAM object as raw data.
...
...
@@ -240,10 +244,13 @@ func (obj *Persistent) PActivate(ctx context.Context) (err error) {
if
err
==
nil
{
switch
istate
:=
obj
.
istate
()
.
(
type
)
{
case
Stateful
:
err
=
istate
.
SetState
(
state
)
// XXX err ctx
err
=
istate
.
SetState
(
state
)
xerr
.
Contextf
(
&
err
,
"%s(%s): setstate"
,
obj
.
zclass
.
class
,
obj
.
oid
)
case
PyStateful
:
err
=
pySetState
(
istate
,
obj
.
zclass
.
class
,
state
,
obj
.
jar
)
// XXX err ctx
err
=
pySetState
(
istate
,
obj
.
zclass
.
class
,
state
,
obj
.
jar
)
xerr
.
Contextf
(
&
err
,
"%s(%s): pysetstate"
,
obj
.
zclass
.
class
,
obj
.
oid
)
default
:
panic
(
"!stateful instance"
)
...
...
go/zodb/zodbpy.go
View file @
a0db1dd4
...
...
@@ -28,7 +28,11 @@ import (
// exchanged as Python data.
type
PyStateful
interface
{
// PySetState should set state of the in-RAM object from Python data.
// Analog of __setstate__() in Python.
//
// 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.
PySetState
(
pystate
interface
{})
error
// PyGetState should return state of the in-RAM object as Python data.
...
...
@@ -44,7 +48,7 @@ type PyStateful interface {
func
pySetState
(
obj
PyStateful
,
objClass
string
,
state
*
mem
.
Buf
,
jar
*
Connection
)
error
{
pyclass
,
pystate
,
err
:=
PyData
(
state
.
Data
)
.
decode
(
jar
)
if
err
!=
nil
{
return
err
// XXX err ctx
return
err
}
class
:=
pyclassPath
(
pyclass
)
...
...
@@ -52,10 +56,10 @@ func pySetState(obj PyStateful, objClass string, state *mem.Buf, jar *Connection
if
class
!=
objClass
{
// complain that pyclass changed
// (both ref and object data use pyclass so it indeed can be different)
return
&
wrongClassError
{
want
:
objClass
,
have
:
class
}
// XXX + err ctx
return
&
wrongClassError
{
want
:
objClass
,
have
:
class
}
}
return
obj
.
PySetState
(
pystate
)
// XXX err ctx = ok?
return
obj
.
PySetState
(
pystate
)
}
// TODO pyGetState
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment