1 """
2 Renderers supporting upload cores.
3 """
4
5
6
7
8
9
10
11 from nevow import inevow
12 from nevow import loaders
13 from nevow import tags as T
14
15 from gavo import base
16 from gavo.web import formrender
17
18
20 """A renderer allowing for updates to individual records using file upload.
21
22 This renderer exposes a form with a file widget. It is likely that
23 the interface will change.
24 """
25
26 name = "upload"
27
35
36 docFactory = loaders.stan(T.html[
37 T.head[
38 T.title["Upload"],
39 T.invisible(render=T.directive("commonhead")),
40 ],
41 T.body(render=T.directive("withsidebar"))[
42 T.h1(render=T.directive("meta"))["title"],
43 T.p(class_="procMessage", data=T.directive("result"),
44 render=T.directive("uploadInfo"))[
45 T.slot(name="nAffected"),
46 " record(s) modified."
47 ],
48 T.invisible(render=T.directive("form genForm"))
49 ]
50 ])
51
52
54 """A renderer allowing for updates to individual records using file
55 uploads.
56
57 The difference to Uploader is that no form-redisplay will be done.
58 All errors are reported through HTTP response codes and text strings.
59 It is likely that this renderer will change and/or go away.
60 """
61
62 name = "mupload"
63
71
73 request = inevow.IRequest(ctx)
74 request.setResponseCode(400)
75 request.setHeader("content-type", "text/plain;charset=utf-8")
76 request.write(("Uploading %s did not change data database.\nThis"
77 " usually happens when the file already existed for an insert"
78 " or did not exist for an update.\n"%(
79 data.inputTable.getParamDict()["File"][0],
80 )).encode("utf-8"))
81 return ""
82
94