~ed.so/duplicity/lftp.ncftp.and.prefixes

« back to all changes in this revision

Viewing changes to duplicity/backends/README

  • Committer: Michael Terry
  • Date: 2014-04-21 19:21:45 UTC
  • mto: This revision was merged to the branch mainline in revision 981.
  • Revision ID: michael.terry@canonical.com-20140421192145-b1vlb0hppnn8jrtl
Checkpoint

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
= How to write a backend, in five easy steps! =
 
2
 
 
3
There are five main methods you want to implement:
 
4
 
 
5
__init__  - Initial setup
 
6
_get      - Get one file
 
7
_put      - Upload one file
 
8
_list     - List all files in the backend
 
9
_delete   - Delete one file
 
10
 
 
11
There are other methods you may optionally implement:
 
12
 
 
13
_delete_list
 
14
_query
 
15
_query_list
 
16
_retry_cleanup
 
17
_error_code
 
18
_move
 
19
_close
 
20
 
 
21
== Subclassing ==
 
22
 
 
23
Always subclass from duplicity.backend.Backend
 
24
 
 
25
== Registering ==
 
26
 
 
27
You can register your class as a single backend like so:
 
28
 
 
29
duplicity.backend.register_backend("foo", FooBackend)
 
30
 
 
31
This will allow a URL like so: foo://hostname/path
 
32
 
 
33
Or you can register your class as a meta backend like so:
 
34
duplicity.backend.register_prefix_backend("bar", BarBackend)
 
35
 
 
36
Which will allow a URL like so: bar+foo://hostname/path and your class will
 
37
be passed the inner URL to either interpret how you like or create a new
 
38
inner backend instance with duplicity.backend.get_backend(url).
 
39
 
 
40
== Naming ==
 
41
 
 
42
When writing helper methods for your class, please prefix them with two
 
43
underscores.  While you can define other no- or single-underscore prefixed
 
44
methods, we don't guarantee that that method name won't later be used
 
45
by the main Backend class.