Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Levin Zimmermann
neoppod
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 (
func
openByURL
(
u
*
url
.
URL
)
(
zodb
.
IStorage
,
error
)
{
// TODO handle query
// XXX u.Path is not always raw path - recheck and fix
return
Open
(
u
.
Path
)
return
Open
(
u
.
Host
+
u
.
Path
)
}
func
init
()
{
zodb
.
RegisterStorage
(
"file
://
"
,
openByURL
)
zodb
.
RegisterStorage
(
"file"
,
openByURL
)
}
t/neo/zodb/open.go
View file @
38482c68
...
...
@@ -19,10 +19,25 @@ package zodb
// logic to open storages by URL
import
(
"fmt"
"net/url"
"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
// Only URL schemes registered to zodb package are handled.
...
...
@@ -37,14 +52,15 @@ func OpenStorageURL(storageURL string) (IStorage, error) {
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
type
StorageOpener
func
(
u
*
url
.
URL
)
(
IStorage
,
error
)
opener
,
ok
:=
storageRegistry
[
u
.
Scheme
]
if
!
ok
{
return
nil
,
fmt
.
Errorf
(
"zodb: URL scheme
\"
%s://
\"
not supported"
,
u
.
Scheme
)
}
// RegisterStorage registers handler to be used for URLs with scheme
func
RegisterStorage
(
scheme
string
,
handler
StorageOpener
)
{
// TODO
return
opener
(
u
)
}
t/neo/zodb/wks/wks.go
View file @
38482c68
...
...
@@ -16,7 +16,7 @@
// See COPYING file for full licensing terms.
// 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
//
...
...
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