Commit 6450154d authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent b95933e0
/*.lock
/*.tmp
/*.tr[0-9]
......@@ -31,7 +31,9 @@ import (
//
// 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 {
PJar() *Connection // Connection this in-RAM object is part of.
POid() Oid // object ID in the database.
......@@ -126,7 +128,7 @@ const (
// type myObjectState MyObject
//
// func (o *myObjectState) DropState() { ... }
// func (o *myObjectState) PySetState(pystate interface{}) { ... }
// func (o *myObjectState) PySetState(pystate interface{}) error { ... }
//
// func init() {
// t := reflect.TypeOf
......
// 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
// 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
}
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