Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Levin Zimmermann
neoppod
Commits
498915ea
Commit
498915ea
authored
Jul 30, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
23cd85bd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
14 deletions
+39
-14
go/zodb/connection.go
go/zodb/connection.go
+16
-9
go/zodb/persistent.go
go/zodb/persistent.go
+23
-5
No files found.
go/zodb/connection.go
View file @
498915ea
...
...
@@ -24,7 +24,7 @@ import (
"lab.nexedi.com/kirr/neo/go/zodb/internal/weak"
)
// Connection represents a view of ZODB database. XXX + live application objects.
// Connection represents a
n isolated
view of ZODB database. XXX + live application objects.
//
// The view is representing state of ZODB objects as of `at` transaction.
//
...
...
@@ -38,7 +38,9 @@ import (
// inside transaction where Connection was opened.
type
Connection
struct
{
stor
IStorage
// underlying storage
at
Tid
// current view of database
// current view of database; stable inside a transaction.
at
Tid
// {} oid -> obj
//
...
...
@@ -140,6 +142,13 @@ var rPyStateful = reflect.TypeOf((*PyStateful)(nil)).Elem() // typeof(PyStatef
// RegisterClass registers ZODB class to correspond to Go type.
//
// Only registered classes can be saved to database, and are converted to
// corresponding application-level objects on load. When ZODB loads an object
// whose class is not know, it will represent it as Broken object.
//
// class is a full class path for registered class, e.g. "BTrees.LOBTree.LOBucket".
// typ is Go type corresponding to class.
//
// typ must embed Persistent; *typ must implement IPersistent.
//
// typ must be convertible to stateType; stateType must implement Ghostable and
...
...
@@ -213,9 +222,12 @@ func (conn *Connection) newGhost(class string, oid Oid) IPersistent {
return
base
.
instance
}
// Broken is used for classes that were not registered.
// Broken objects are used to represend ZODB objects with classes that were not
// registered to zodb Go package.
//
// See RegisterClass for details.
type
Broken
struct
{
*
Persistent
Persistent
class
string
state
*
mem
.
Buf
}
...
...
@@ -336,11 +348,6 @@ func (conn *Connection) Get(ctx context.Context, oid Oid) (IPersistent, error) {
// XXX Connection.{Get,get} without py dependency?
// but then how to create a ghost of correct class? -> reflect.Type?
// load loads object specified by oid.
//
// XXX must be called ... (XXX e.g. outside transaction boundary) so that there is no race on .at .
...
...
go/zodb/persistent.go
View file @
498915ea
...
...
@@ -114,9 +114,27 @@ const (
// Persistent is common base IPersistent implementation for in-RAM
// representation of database objects.
//
// XXX it requires it to embed and provide Ghostable + Stateful.
// To use - a class needs to embed Persistent and register itself additionally
// providing Ghostable and (Py)Stateful methods. For example:
//
// type MyObject struct {
// Persistent
// ...
// }
//
// type myObjectState MyObject
//
// func (o *myObjectState) DropState() { ... }
// func (o *myObjectState) PySetState(pystate interface{}) { ... }
//
// func init() {
// t := reflect.TypeOf
// zodb.RegisterClass("mymodule.MyObject", t(MyObject{}), t(myObjectState))
// }
type
Persistent
struct
{
zclass
*
zclass
// ZODB class of this object.
// ZODB class of this object.
// XXX it could be deduced via typeTab[reflect.TypeOf(.instance)]
zclass
*
zclass
jar
*
Connection
oid
Oid
...
...
@@ -126,9 +144,9 @@ type Persistent struct {
state
ObjectState
refcnt
int32
// Persistent
should be
the base for the instance.
// instance is additionally Ghostable and (Stateful | PyStateful).
instance
IPersistent
// XXX Ghostable also not good here
// Persistent
is
the base for the instance.
// instance
, via its state type,
is additionally Ghostable and (Stateful | PyStateful).
instance
IPersistent
loading
*
loadState
}
...
...
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