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
38482c68
Commit
38482c68
authored
Apr 21, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
9f0738e5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
11 deletions
+27
-11
t/neo/storage/fs1/url.go
t/neo/storage/fs1/url.go
+2
-2
t/neo/zodb/open.go
t/neo/zodb/open.go
+24
-8
t/neo/zodb/wks/wks.go
t/neo/zodb/wks/wks.go
+1
-1
No files found.
t/neo/storage/fs1/url.go
View file @
38482c68
...
@@ -28,9 +28,9 @@ import (
...
@@ -28,9 +28,9 @@ import (
func
openByURL
(
u
*
url
.
URL
)
(
zodb
.
IStorage
,
error
)
{
func
openByURL
(
u
*
url
.
URL
)
(
zodb
.
IStorage
,
error
)
{
// TODO handle query
// TODO handle query
// XXX u.Path is not always raw path - recheck and fix
// XXX u.Path is not always raw path - recheck and fix
return
Open
(
u
.
Path
)
return
Open
(
u
.
Host
+
u
.
Path
)
}
}
func
init
()
{
func
init
()
{
zodb
.
RegisterStorage
(
"file
://
"
,
openByURL
)
zodb
.
RegisterStorage
(
"file"
,
openByURL
)
}
}
t/neo/zodb/open.go
View file @
38482c68
...
@@ -19,10 +19,25 @@ package zodb
...
@@ -19,10 +19,25 @@ package zodb
// logic to open storages by URL
// logic to open storages by URL
import
(
import
(
"fmt"
"net/url"
"net/url"
"strings"
"strings"
)
)
// StorageOpener is a function to open a storage
type
StorageOpener
func
(
u
*
url
.
URL
)
(
IStorage
,
error
)
// {} scheme -> StorageOpener
var
storageRegistry
=
map
[
string
]
StorageOpener
{}
// RegisterStorage registers opener to be used for URLs with scheme
func
RegisterStorage
(
scheme
string
,
opener
StorageOpener
)
{
if
_
,
already
:=
storageRegistry
[
scheme
];
already
{
panic
(
fmt
.
Errorf
(
"ZODB URL scheme %q was already registered"
,
scheme
))
}
storageRegistry
[
scheme
]
=
opener
}
// OpenStorage opens ZODB storage by URL
// OpenStorage opens ZODB storage by URL
// Only URL schemes registered to zodb package are handled.
// Only URL schemes registered to zodb package are handled.
...
@@ -37,14 +52,15 @@ func OpenStorageURL(storageURL string) (IStorage, error) {
...
@@ -37,14 +52,15 @@ func OpenStorageURL(storageURL string) (IStorage, error) {
storageURL
=
"file://"
+
storageURL
storageURL
=
"file://"
+
storageURL
}
}
return
nil
,
nil
u
,
err
:=
url
.
Parse
(
storageURL
)
}
if
err
!=
nil
{
return
nil
,
err
}
// StorageOpener is a function to open a storage
opener
,
ok
:=
storageRegistry
[
u
.
Scheme
]
type
StorageOpener
func
(
u
*
url
.
URL
)
(
IStorage
,
error
)
if
!
ok
{
return
nil
,
fmt
.
Errorf
(
"zodb: URL scheme
\"
%s://
\"
not supported"
,
u
.
Scheme
)
}
// RegisterStorage registers handler to be used for URLs with scheme
return
opener
(
u
)
func
RegisterStorage
(
scheme
string
,
handler
StorageOpener
)
{
// TODO
}
}
t/neo/zodb/wks/wks.go
View file @
38482c68
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
// See COPYING file for full licensing terms.
// See COPYING file for full licensing terms.
// Package wks links-in well-known ZODB storages
// Package wks links-in well-known ZODB storages
// The only purpose of this package is so that users import it
// The only purpose of this package is so that users
could
import it
//
//
// import _ ".../zodb/wks" XXX fixme import path
// import _ ".../zodb/wks" XXX fixme import path
//
//
...
...
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