Commit 24b50aa6 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent af77ab5d
......@@ -383,7 +383,7 @@ func RegisterClass(class string, typ, stateType reflect.Type) {
//
// Class aliases are useful for backward compatibility - sometimes class name
// of an object changes, but to support loading previously-saved objects, the
// old class name have to be also supported.
// old class name has to be also supported.
func RegisterClassAlias(alias, class string) {
badf := func(format string, argv ...interface{}) {
msg := fmt.Sprintf(format, argv...)
......
......@@ -54,6 +54,7 @@ func (o *myObjectState) PySetState(pystate interface{}) error {
func init() {
t := reflect.TypeOf
RegisterClass("t.zodb.MyObject", t(MyObject{}), t(myObjectState{}))
RegisterClassAlias("t.zodb.MyOldObject", "t.zodb.MyObject")
}
func TestPersistent(t *testing.T) {
......@@ -115,11 +116,20 @@ func TestPersistent(t *testing.T) {
xobj = newGhost("t.zodb.MyObject", 11, nil)
obj, ok := xobj.(*MyObject)
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)
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")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment