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
6450154d
Commit
6450154d
authored
Jul 31, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
b95933e0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
65 additions
and
3 deletions
+65
-3
go/zodb/btree/testdata/.gitignore
go/zodb/btree/testdata/.gitignore
+3
-0
go/zodb/persistent.go
go/zodb/persistent.go
+4
-2
go/zodb/persistent_test.go
go/zodb/persistent_test.go
+58
-1
No files found.
go/zodb/btree/testdata/.gitignore
0 → 100644
View file @
6450154d
/*.lock
/*.tmp
/*.tr[0-9]
go/zodb/persistent.go
View file @
6450154d
...
@@ -31,7 +31,9 @@ import (
...
@@ -31,7 +31,9 @@ import (
//
//
// but is not exactly equal to it.
// but is not exactly equal to it.
//
//
// XXX safe to access from multiple goroutines simultaneously.
// It is safe to access IPersistent from multiple goroutines simultaneously.
//
// Use Persistent as the base for application-level types that need to provide persistency.
type
IPersistent
interface
{
type
IPersistent
interface
{
PJar
()
*
Connection
// Connection this in-RAM object is part of.
PJar
()
*
Connection
// Connection this in-RAM object is part of.
POid
()
Oid
// object ID in the database.
POid
()
Oid
// object ID in the database.
...
@@ -126,7 +128,7 @@ const (
...
@@ -126,7 +128,7 @@ const (
// type myObjectState MyObject
// type myObjectState MyObject
//
//
// func (o *myObjectState) DropState() { ... }
// func (o *myObjectState) DropState() { ... }
// func (o *myObjectState) PySetState(pystate interface{}) { ... }
// func (o *myObjectState) PySetState(pystate interface{})
error
{ ... }
//
//
// func init() {
// func init() {
// t := reflect.TypeOf
// t := reflect.TypeOf
...
...
go/zodb/persistent_test.go
View file @
6450154d
// Copyright (C) 2018 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
//
// This program is free software: you can Use, Study, Modify and Redistribute
// it under the terms of the GNU General Public License version 3, or (at your
// option) any later version, as published by the Free Software Foundation.
//
// You can also Link and Combine this program with other software covered by
// the terms of any of the Free Software licenses or any of the Open Source
// Initiative approved licenses and Convey the resulting work. Corresponding
// source of such a combination shall include the source code for all other
// software used.
//
// This program is distributed WITHOUT ANY WARRANTY; without even the implied
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//
// See COPYING file for full licensing terms.
// See https://www.nexedi.com/licensing for rationale and options.
package
zodb
package
zodb
// TODO
import
(
"fmt"
"reflect"
"testing"
)
type
MyObject
struct
{
Persistent
value
string
}
type
myObjectState
MyObject
func
(
o
*
myObjectState
)
DropState
()
{
o
.
value
=
""
}
func
(
o
*
myObjectState
)
PySetState
(
pystate
interface
{})
error
{
s
,
ok
:=
pystate
.
(
string
)
if
!
ok
{
return
fmt
.
Errorf
(
"myobject: setstate: want str; got %T"
,
pystate
)
}
o
.
value
=
s
return
nil
}
func
init
()
{
t
:=
reflect
.
TypeOf
RegisterClass
(
"t.zodb.MyObject"
,
t
(
MyObject
{}),
t
(
myObjectState
{}))
}
func
TestPersistent
(
t
*
testing
.
T
)
{
// XXX
}
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