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
41db5fd6
Commit
41db5fd6
authored
Jul 19, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
7a8cebf5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
25 deletions
+23
-25
wcfs/btree.go
wcfs/btree.go
+2
-2
wcfs/zblk.go
wcfs/zblk.go
+4
-4
wcfs/zodbpy.go
wcfs/zodbpy.go
+17
-19
No files found.
wcfs/btree.go
View file @
41db5fd6
...
...
@@ -249,8 +249,8 @@ func (b *ZBucket) PySetState(pystate interface{}) error {
// ---- register classes to ZODB ----
func
bucketNew
(
pyobj
*
pyObject
)
PyObjec
t
{
return
&
ZBucket
{
pyObject
:
pyobj
}
}
func
btreeNew
(
pyobj
*
pyObject
)
PyObject
{
return
&
ZBTree
{
pyObject
:
pyobj
}
}
func
bucketNew
(
pyobj
*
pyObject
)
IPyPersisten
t
{
return
&
ZBucket
{
pyObject
:
pyobj
}
}
func
btreeNew
(
pyobj
*
pyObject
)
IPyPersistent
{
return
&
ZBTree
{
pyObject
:
pyobj
}
}
func
init
()
{
registerPyClass
(
"zodb.BTree.LOBucket"
,
bucketNew
)
...
...
wcfs/zblk.go
View file @
41db5fd6
...
...
@@ -147,10 +147,10 @@ func (bf *ZBigFile) PySetState(pystate interface{}) (err error) {
// ----------------------------------------
func
zblk0New
(
base
*
pyObject
)
PyObject
{
return
&
ZBlk0
{
pyObject
:
base
}
}
func
zblk1New
(
base
*
pyObject
)
PyObject
{
return
&
ZBlk1
{
pyObject
:
base
}
}
func
zdataNew
(
base
*
pyObject
)
PyObject
{
return
&
ZData
{
pyObject
:
base
}
}
func
zbigfileNew
(
pyobj
*
pyObject
)
PyObjec
t
{
return
&
ZBigFile
{
pyObject
:
pyobj
}
}
func
zblk0New
(
base
*
pyObject
)
IPyPersistent
{
return
&
ZBlk0
{
pyObject
:
base
}
}
func
zblk1New
(
base
*
pyObject
)
IPyPersistent
{
return
&
ZBlk1
{
pyObject
:
base
}
}
func
zdataNew
(
base
*
pyObject
)
IPyPersistent
{
return
&
ZData
{
pyObject
:
base
}
}
func
zbigfileNew
(
pyobj
*
pyObject
)
IPyPersisten
t
{
return
&
ZBigFile
{
pyObject
:
pyobj
}
}
func
init
()
{
registerPyClass
(
zwendelin
+
".ZBlk"
,
zblk0New
)
...
...
wcfs/zodbpy.go
View file @
41db5fd6
...
...
@@ -24,18 +24,16 @@ import (
pickle
"github.com/kisielk/og-rek"
)
// PyObject is the interface that every in-RAM object representing Python ZODB object implements.
//
// XXX rename -> PyPersistent?
type
PyObject
interface
{
// IPyPersistent is the interface that every in-RAM object representing Python ZODB object implements.
type
IPyPersistent
interface
{
IPersistent
PyClass
()
pickle
.
Class
// python class of this object
// PyState() interface{} // object state. python passes this to pyclass.__new__().__setstate__()
//
PyObjec
t must be stateful for persistency to work
// XXX try to move out of
PyObjec
t? Rationale: we do not want e.g. PySetState to
// be available to user who holds
PyObjec
t interface: it is confusing to have
//
IPyPersisten
t must be stateful for persistency to work
// XXX try to move out of
IPyPersisten
t? Rationale: we do not want e.g. PySetState to
// be available to user who holds
IPyPersisten
t interface: it is confusing to have
// both PActivate and PySetState at the same time.
PyStateful
}
...
...
@@ -63,12 +61,12 @@ type PyStateful interface {
// ---- pyObject <-> object state exchange ----
// pyinstance returns .instance upcasted to
PyObjec
t.
// pyinstance returns .instance upcasted to
IPyPersisten
t.
//
// this should be always safe because we always create pyObjects via
// newGhost which passes
PyObjec
t as instance to IPersistent.
func
(
pyobj
*
pyObject
)
pyinstance
()
PyObjec
t
{
return
pyobj
.
instance
.
(
PyObjec
t
)
// newGhost which passes
IPyPersisten
t as instance to IPersistent.
func
(
pyobj
*
pyObject
)
pyinstance
()
IPyPersisten
t
{
return
pyobj
.
instance
.
(
IPyPersisten
t
)
}
func
(
pyobj
*
pyObject
)
SetState
(
state
*
mem
.
Buf
)
error
{
...
...
@@ -91,7 +89,7 @@ func (pyobj *pyObject) SetState(state *mem.Buf) error {
// ---- pyclass -> new ghost ----
// function representing new of a class.
type
pyClassNewFunc
func
(
base
*
pyObject
)
PyObjec
t
type
pyClassNewFunc
func
(
base
*
pyObject
)
IPyPersisten
t
// path(pyclass) -> new(pyobj)
var
pyClassTab
=
make
(
map
[
string
]
pyClassNewFunc
)
...
...
@@ -106,7 +104,7 @@ func registerPyClass(pyClassPath string, classNew pyClassNewFunc) {
}
// newGhost creates new ghost object corresponding to pyclass and oid.
func
(
conn
*
Connection
)
newGhost
(
pyclass
pickle
.
Class
,
oid
zodb
.
Oid
)
PyObjec
t
{
func
(
conn
*
Connection
)
newGhost
(
pyclass
pickle
.
Class
,
oid
zodb
.
Oid
)
IPyPersisten
t
{
pyobj
:=
&
pyObject
{
object
:
object
{
jar
:
conn
,
oid
:
oid
,
serial
:
0
,
state
:
GHOST
},
pyclass
:
pyclass
,
...
...
@@ -114,7 +112,7 @@ func (conn *Connection) newGhost(pyclass pickle.Class, oid zodb.Oid) PyObject {
// switch on pyclass and transform e.g. "zodb.BTree.Bucket" -> *ZBucket
classNew
:=
pyClassTab
[
pyclass
.
Module
+
"."
+
pyclass
.
Name
]
var
instance
PyObjec
t
var
instance
IPyPersisten
t
if
classNew
!=
nil
{
instance
=
classNew
(
pyobj
)
}
else
{
...
...
@@ -153,7 +151,7 @@ func (d *dummyPyInstance) PySetState(pystate interface{}) error {
//
// The object's data is not neccessarily loaded after Get returns. Use
// PActivate to make sure the object ifs fully loaded.
func
(
conn
*
Connection
)
Get
(
ctx
context
.
Context
,
oid
zodb
.
Oid
)
(
PyObjec
t
,
error
)
{
func
(
conn
*
Connection
)
Get
(
ctx
context
.
Context
,
oid
zodb
.
Oid
)
(
IPyPersisten
t
,
error
)
{
conn
.
objmu
.
Lock
()
// XXX -> rlock
wobj
:=
conn
.
objtab
[
oid
]
var
xobj
interface
{}
...
...
@@ -164,7 +162,7 @@ func (conn *Connection) Get(ctx context.Context, oid zodb.Oid) (PyObject, error)
// object was already there in objtab.
if
xobj
!=
nil
{
return
xobj
.
(
PyObjec
t
),
nil
return
xobj
.
(
IPyPersisten
t
),
nil
}
// object is not there in objtab - raw load it, get its class -> get(pyclass, oid)
...
...
@@ -207,14 +205,14 @@ func (e *wrongClassError) Error() string {
//
// Use-case: in ZODB references are (pyclass, oid), so new ghost is created
// without further loading anything.
func
(
conn
*
Connection
)
get
(
pyclass
pickle
.
Class
,
oid
zodb
.
Oid
)
(
PyObjec
t
,
error
)
{
func
(
conn
*
Connection
)
get
(
pyclass
pickle
.
Class
,
oid
zodb
.
Oid
)
(
IPyPersisten
t
,
error
)
{
conn
.
objmu
.
Lock
()
// XXX -> rlock
wobj
:=
conn
.
objtab
[
oid
]
var
pyobj
PyObjec
t
var
pyobj
IPyPersisten
t
checkClass
:=
false
if
wobj
!=
nil
{
if
xobj
:=
wobj
.
Get
();
xobj
!=
nil
{
pyobj
=
xobj
.
(
PyObjec
t
)
pyobj
=
xobj
.
(
IPyPersisten
t
)
}
}
if
pyobj
==
nil
{
...
...
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