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
24b50aa6
Commit
24b50aa6
authored
Oct 08, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
af77ab5d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
2 deletions
+12
-2
go/zodb/persistent.go
go/zodb/persistent.go
+1
-1
go/zodb/persistent_test.go
go/zodb/persistent_test.go
+11
-1
No files found.
go/zodb/persistent.go
View file @
24b50aa6
...
@@ -383,7 +383,7 @@ func RegisterClass(class string, typ, stateType reflect.Type) {
...
@@ -383,7 +383,7 @@ func RegisterClass(class string, typ, stateType reflect.Type) {
//
//
// Class aliases are useful for backward compatibility - sometimes class name
// Class aliases are useful for backward compatibility - sometimes class name
// of an object changes, but to support loading previously-saved objects, the
// of an object changes, but to support loading previously-saved objects, the
// old class name ha
ve
to be also supported.
// old class name ha
s
to be also supported.
func
RegisterClassAlias
(
alias
,
class
string
)
{
func
RegisterClassAlias
(
alias
,
class
string
)
{
badf
:=
func
(
format
string
,
argv
...
interface
{})
{
badf
:=
func
(
format
string
,
argv
...
interface
{})
{
msg
:=
fmt
.
Sprintf
(
format
,
argv
...
)
msg
:=
fmt
.
Sprintf
(
format
,
argv
...
)
...
...
go/zodb/persistent_test.go
View file @
24b50aa6
...
@@ -54,6 +54,7 @@ func (o *myObjectState) PySetState(pystate interface{}) error {
...
@@ -54,6 +54,7 @@ func (o *myObjectState) PySetState(pystate interface{}) error {
func
init
()
{
func
init
()
{
t
:=
reflect
.
TypeOf
t
:=
reflect
.
TypeOf
RegisterClass
(
"t.zodb.MyObject"
,
t
(
MyObject
{}),
t
(
myObjectState
{}))
RegisterClass
(
"t.zodb.MyObject"
,
t
(
MyObject
{}),
t
(
myObjectState
{}))
RegisterClassAlias
(
"t.zodb.MyOldObject"
,
"t.zodb.MyObject"
)
}
}
func
TestPersistent
(
t
*
testing
.
T
)
{
func
TestPersistent
(
t
*
testing
.
T
)
{
...
@@ -115,11 +116,20 @@ func TestPersistent(t *testing.T) {
...
@@ -115,11 +116,20 @@ func TestPersistent(t *testing.T) {
xobj
=
newGhost
(
"t.zodb.MyObject"
,
11
,
nil
)
xobj
=
newGhost
(
"t.zodb.MyObject"
,
11
,
nil
)
obj
,
ok
:=
xobj
.
(
*
MyObject
)
obj
,
ok
:=
xobj
.
(
*
MyObject
)
if
!
ok
{
if
!
ok
{
t
.
Fatalf
(
"
unknown -> %T; want Broken
"
,
xobj
)
t
.
Fatalf
(
"
t.zodb.MyObject -> %T; want MyObject
"
,
xobj
)
}
}
checkObj
(
obj
,
nil
,
11
,
InvalidTid
,
GHOST
,
0
,
nil
)
checkObj
(
obj
,
nil
,
11
,
InvalidTid
,
GHOST
,
0
,
nil
)
assert
.
Equal
(
ClassOf
(
obj
),
"t.zodb.MyObject"
)
// t.zodb.MyOldObject -> *MyObject
xobj
=
newGhost
(
"t.zodb.MyOldObject"
,
12
,
nil
)
obj
,
ok
=
xobj
.
(
*
MyObject
)
if
!
ok
{
t
.
Fatalf
(
"t.zodb.MyOldObject -> %T; want MyObject"
,
xobj
)
}
checkObj
(
obj
,
nil
,
12
,
InvalidTid
,
GHOST
,
0
,
nil
)
assert
.
Equal
(
ClassOf
(
obj
),
"t.zodb.MyObject"
)
assert
.
Equal
(
ClassOf
(
obj
),
"t.zodb.MyObject"
)
...
...
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