| 1 | diff -rc allmydata.orig/client.py allmydata/client.py |
|---|
| 2 | *** allmydata.orig/client.py 2009-01-14 23:41:48.000000000 +0000 |
|---|
| 3 | --- allmydata/client.py 2009-01-17 01:42:59.000000000 +0000 |
|---|
| 4 | *************** |
|---|
| 5 | *** 267,273 **** |
|---|
| 6 | nodeurl_path = os.path.join(self.basedir, "node.url") |
|---|
| 7 | staticdir = self.get_config("node", "web.static", "public_html") |
|---|
| 8 | staticdir = os.path.expanduser(staticdir) |
|---|
| 9 | ! ws = WebishServer(webport, nodeurl_path, staticdir) |
|---|
| 10 | self.add_service(ws) |
|---|
| 11 | |
|---|
| 12 | def init_ftp_server(self): |
|---|
| 13 | --- 267,275 ---- |
|---|
| 14 | nodeurl_path = os.path.join(self.basedir, "node.url") |
|---|
| 15 | staticdir = self.get_config("node", "web.static", "public_html") |
|---|
| 16 | staticdir = os.path.expanduser(staticdir) |
|---|
| 17 | ! # should we provide ambient upload authority? |
|---|
| 18 | ! ambientUploadAuthority = self.get_config("node", "web.ambient_upload_authority", True, boolean=True) |
|---|
| 19 | ! ws = WebishServer(webport, nodeurl_path, staticdir, ambientUploadAuthority) |
|---|
| 20 | self.add_service(ws) |
|---|
| 21 | |
|---|
| 22 | def init_ftp_server(self): |
|---|
| 23 | diff -rc allmydata.orig/test/common.py allmydata/test/common.py |
|---|
| 24 | *** allmydata.orig/test/common.py 2009-01-12 17:16:19.000000000 +0000 |
|---|
| 25 | --- allmydata/test/common.py 2009-01-16 16:15:52.000000000 +0000 |
|---|
| 26 | *************** |
|---|
| 27 | *** 437,445 **** |
|---|
| 28 | helper_furl = f.read() |
|---|
| 29 | f.close() |
|---|
| 30 | self.helper_furl = helper_furl |
|---|
| 31 | ! f = open(os.path.join(basedirs[3],"helper.furl"), "w") |
|---|
| 32 | ! f.write(helper_furl) |
|---|
| 33 | ! f.close() |
|---|
| 34 | |
|---|
| 35 | # this starts the rest of the clients |
|---|
| 36 | for i in range(1, self.numclients): |
|---|
| 37 | --- 437,446 ---- |
|---|
| 38 | helper_furl = f.read() |
|---|
| 39 | f.close() |
|---|
| 40 | self.helper_furl = helper_furl |
|---|
| 41 | ! if self.numclients >= 4: |
|---|
| 42 | ! f = open(os.path.join(basedirs[3],"helper.furl"), "w") |
|---|
| 43 | ! f.write(helper_furl) |
|---|
| 44 | ! f.close() |
|---|
| 45 | |
|---|
| 46 | # this starts the rest of the clients |
|---|
| 47 | for i in range(1, self.numclients): |
|---|
| 48 | *************** |
|---|
| 49 | *** 454,463 **** |
|---|
| 50 | l = self.clients[0].getServiceNamed("webish").listener |
|---|
| 51 | port = l._port.getHost().port |
|---|
| 52 | self.webish_url = "http://localhost:%d/" % port |
|---|
| 53 | ! # and the helper-using webport |
|---|
| 54 | ! l = self.clients[3].getServiceNamed("webish").listener |
|---|
| 55 | ! port = l._port.getHost().port |
|---|
| 56 | ! self.helper_webish_url = "http://localhost:%d/" % port |
|---|
| 57 | d.addCallback(_connected) |
|---|
| 58 | return d |
|---|
| 59 | |
|---|
| 60 | --- 455,465 ---- |
|---|
| 61 | l = self.clients[0].getServiceNamed("webish").listener |
|---|
| 62 | port = l._port.getHost().port |
|---|
| 63 | self.webish_url = "http://localhost:%d/" % port |
|---|
| 64 | ! if self.numclients >=4: |
|---|
| 65 | ! # and the helper-using webport |
|---|
| 66 | ! l = self.clients[3].getServiceNamed("webish").listener |
|---|
| 67 | ! port = l._port.getHost().port |
|---|
| 68 | ! self.helper_webish_url = "http://localhost:%d/" % port |
|---|
| 69 | d.addCallback(_connected) |
|---|
| 70 | return d |
|---|
| 71 | |
|---|
| 72 | Only in allmydata/test: test_ambient_upload_authority.py |
|---|
| 73 | diff -rc allmydata.orig/web/root.py allmydata/web/root.py |
|---|
| 74 | *** allmydata.orig/web/root.py 2008-12-01 23:27:15.000000000 +0000 |
|---|
| 75 | --- allmydata/web/root.py 2009-01-17 01:43:48.000000000 +0000 |
|---|
| 76 | *************** |
|---|
| 77 | *** 22,27 **** |
|---|
| 78 | --- 22,30 ---- |
|---|
| 79 | class URIHandler(RenderMixin, rend.Page): |
|---|
| 80 | # I live at /uri . There are several operations defined on /uri itself, |
|---|
| 81 | # mostly involved with creation of unlinked files and directories. |
|---|
| 82 | + |
|---|
| 83 | + def setAmbientUploadAuthority(self, ambientUploadAuthority): |
|---|
| 84 | + self.ambientUploadAuthority = ambientUploadAuthority |
|---|
| 85 | |
|---|
| 86 | def render_GET(self, ctx): |
|---|
| 87 | req = IRequest(ctx) |
|---|
| 88 | *************** |
|---|
| 89 | *** 36,41 **** |
|---|
| 90 | --- 39,47 ---- |
|---|
| 91 | return there |
|---|
| 92 | |
|---|
| 93 | def render_PUT(self, ctx): |
|---|
| 94 | + if not self.ambientUploadAuthority: |
|---|
| 95 | + raise WebError("/uri handling of PUT not enabled on this node") |
|---|
| 96 | + |
|---|
| 97 | req = IRequest(ctx) |
|---|
| 98 | # either "PUT /uri" to create an unlinked file, or |
|---|
| 99 | # "PUT /uri?t=mkdir" to create an unlinked directory |
|---|
| 100 | *************** |
|---|
| 101 | *** 53,58 **** |
|---|
| 102 | --- 59,67 ---- |
|---|
| 103 | raise WebError(errmsg, http.BAD_REQUEST) |
|---|
| 104 | |
|---|
| 105 | def render_POST(self, ctx): |
|---|
| 106 | + if not self.ambientUploadAuthority: |
|---|
| 107 | + raise WebError("/uri handling of POST not enabled on this node") |
|---|
| 108 | + |
|---|
| 109 | # "POST /uri?t=upload&file=newfile" to upload an |
|---|
| 110 | # unlinked file or "POST /uri?t=mkdir" to create a |
|---|
| 111 | # new directory |
|---|
| 112 | *************** |
|---|
| 113 | *** 122,127 **** |
|---|
| 114 | --- 131,139 ---- |
|---|
| 115 | rend.Page.__init__(self, original) |
|---|
| 116 | self.child_operations = operations.OphandleTable() |
|---|
| 117 | |
|---|
| 118 | + def setAmbientUploadAuthority(self, ambientUploadAuthority): |
|---|
| 119 | + self.child_uri.setAmbientUploadAuthority(ambientUploadAuthority) |
|---|
| 120 | + |
|---|
| 121 | child_uri = URIHandler() |
|---|
| 122 | child_cap = URIHandler() |
|---|
| 123 | child_file = FileHandler() |
|---|
| 124 | diff -rc allmydata.orig/webish.py allmydata/webish.py |
|---|
| 125 | *** allmydata.orig/webish.py 2008-10-29 22:36:20.000000000 +0000 |
|---|
| 126 | --- allmydata/webish.py 2009-01-17 01:45:00.000000000 +0000 |
|---|
| 127 | *************** |
|---|
| 128 | *** 123,132 **** |
|---|
| 129 | name = "webish" |
|---|
| 130 | root_class = root.Root |
|---|
| 131 | |
|---|
| 132 | ! def __init__(self, webport, nodeurl_path=None, staticdir=None): |
|---|
| 133 | service.MultiService.__init__(self) |
|---|
| 134 | self.webport = webport |
|---|
| 135 | self.root = self.root_class() |
|---|
| 136 | self.site = site = appserver.NevowSite(self.root) |
|---|
| 137 | self.site.requestFactory = MyRequest |
|---|
| 138 | if self.root.child_operations: |
|---|
| 139 | --- 123,135 ---- |
|---|
| 140 | name = "webish" |
|---|
| 141 | root_class = root.Root |
|---|
| 142 | |
|---|
| 143 | ! def __init__(self, webport, nodeurl_path=None, staticdir=None, |
|---|
| 144 | ! ambientUploadAuthority=False): |
|---|
| 145 | service.MultiService.__init__(self) |
|---|
| 146 | self.webport = webport |
|---|
| 147 | self.root = self.root_class() |
|---|
| 148 | + if self.root_class == root.Root: |
|---|
| 149 | + self.root.setAmbientUploadAuthority(ambientUploadAuthority) |
|---|
| 150 | self.site = site = appserver.NevowSite(self.root) |
|---|
| 151 | self.site.requestFactory = MyRequest |
|---|
| 152 | if self.root.child_operations: |
|---|