Commit 6372c7a4 authored by Kirill Smelkov's avatar Kirill Smelkov

go/zodb: RegisterClass: Prevent double registration of a type

Currently RegisterClass was catching double registration of a ZODB class
(a string), but not a Go type.

We want to prevent double registration of a Go type, because when saving
in-RAM state to ZODB we have to translate Go type -> ZODB class.

Fix it.
parent 313d2d78
......@@ -324,7 +324,10 @@ func RegisterClass(class string, typ, stateType reflect.Type) {
badf("class must be not empty")
}
if zc, already := classTab[class]; already {
badf("class already registered for %q", zc.typ)
badf("class already registered for type %q", zc.typ)
}
if zc, already := typeTab[typ]; already {
badf("type already registered for class %q", zc.class)
}
// typ must embed Persistent
......
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