Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Joshua
wendelin.core
Commits
873b5e4b
Commit
873b5e4b
authored
Jul 19, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
22ac840f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
8 deletions
+24
-8
wcfs/zodb.go
wcfs/zodb.go
+6
-1
wcfs/zodbpy.go
wcfs/zodbpy.go
+18
-7
No files found.
wcfs/zodb.go
View file @
873b5e4b
...
...
@@ -79,6 +79,11 @@ type Object interface {
// application must care to make sure it does not access the
// object data simultaneously.
PInvalidate
()
// Object must be stateful for persistency to work
// XXX try to move out of Object?
Stateful
}
// ObjectState describes state of in-RAM object.
...
...
@@ -100,7 +105,7 @@ type object struct {
mu
sync
.
Mutex
state
ObjectState
refcnt
int32
instance
Stateful
instance
Object
loading
*
loadState
}
...
...
wcfs/zodbpy.go
View file @
873b5e4b
...
...
@@ -31,10 +31,11 @@ type PyObject interface {
PyClass
()
pickle
.
Class
// python class of this object
// PyState() interface{} // object state. python passes this to pyclass.__new__().__setstate__()
// XXX want to hide from PyObject. Rationale: we do not want e.g. PySetState to
// PyObject must be statefule 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.
//
PyStateful
PyStateful
}
// pyObject is common base implementation for in-RAM representation of ZODB Python objects.
...
...
@@ -62,6 +63,14 @@ type PyStateful interface {
// ---- pyObject <-> object state exchange ----
// pyinstance returns .instance upcasted to PyObject.
//
// this should be always safe because we always create pyObjects via
// newGhost which passes PyObject as instance to Object.
func
(
pyobj
*
pyObject
)
pyinstance
()
PyObject
{
return
pyobj
.
instance
.
(
PyObject
)
}
func
(
pyobj
*
pyObject
)
SetState
(
state
*
mem
.
Buf
)
error
{
pyclass
,
pystate
,
err
:=
zodb
.
PyData
(
state
.
Data
)
.
Decode
()
if
err
!=
nil
{
...
...
@@ -74,22 +83,24 @@ func (pyobj *pyObject) SetState(state *mem.Buf) error {
return
&
wrongClassError
{
want
:
pyobj
.
pyclass
,
have
:
pyclass
}
// XXX + err ctx
}
return
pyobj
.
instance
.
PySetState
(
pystate
)
// XXX err ctx = ok?
return
pyobj
.
pyinstance
()
.
PySetState
(
pystate
)
// XXX err ctx = ok?
}
// TODO pyObject.GetState
// ---- pyclass -> new ghost ----
type
pyClassNewFunc
func
(
base
*
pyObject
)
PyObject
// path(pyclass) -> new(pyobj)
var
classTab
=
make
(
map
[
string
]
func
(
base
*
pyObject
)
PyObject
)
var
pyClassTab
=
make
(
map
[
string
]
pyClassNewFunc
)
// registerPyClass registers python class to be transformed to Go instance
// created via classNew.
//
// must be called from global init().
func
registerPyClass
(
pyClassPath
string
,
classNew
func
(
base
*
pyObject
)
PyObject
)
{
c
lassTab
[
pyClassPath
]
=
classNew
func
registerPyClass
(
pyClassPath
string
,
classNew
pyClassNewFunc
)
{
pyC
lassTab
[
pyClassPath
]
=
classNew
}
// newGhost creates new ghost object corresponding to pyclass and oid.
...
...
@@ -100,7 +111,7 @@ func (conn *Connection) newGhost(pyclass pickle.Class, oid zodb.Oid) PyObject {
}
// switch on pyclass and transform e.g. "zodb.BTree.Bucket" -> *ZBucket
classNew
:=
c
lassTab
[
pyclass
.
Module
+
"."
+
pyclass
.
Name
]
classNew
:=
pyC
lassTab
[
pyclass
.
Module
+
"."
+
pyclass
.
Name
]
var
instance
PyObject
if
classNew
!=
nil
{
instance
=
classNew
(
pyobj
)
...
...
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