summaryrefslogtreecommitdiff
path: root/doc/examples
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2010-01-28 17:16:11 -0500
committerScott Moser <smoser@ubuntu.com>2010-01-28 17:16:11 -0500
commite6e30d8c8f72b904b34e93d2b9c4aef39b965b59 (patch)
treea419a39f1654574f27f778f4947931adf2e2b048 /doc/examples
parent124d9e1dfe34e5f71e45f49dac1b1435f4a51114 (diff)
downloadvyos-cloud-init-e6e30d8c8f72b904b34e93d2b9c4aef39b965b59.tar.gz
vyos-cloud-init-e6e30d8c8f72b904b34e93d2b9c4aef39b965b59.zip
add the part-handler plugin
If a part of a multipart file is 'text/part-handler' then it is expected to be python code that implements 2 methods - list_types() list the types that this part-handler supports, return a list. ie: return(['text/plain']) - handle_parts(data,ctype,filename,payload) this method will be called: once, when loaded, with ctype == '__begin__' once per part once, at the end, with ctype == '__end__' - ctype is the content type ('text/plain') - filename is the filename portion of the mime data - payload is the content of the part - data is currently the cloud object, but this could change
Diffstat (limited to 'doc/examples')
-rw-r--r--doc/examples/part-handler.txt12
1 files changed, 12 insertions, 0 deletions
diff --git a/doc/examples/part-handler.txt b/doc/examples/part-handler.txt
new file mode 100644
index 00000000..1fe37f3a
--- /dev/null
+++ b/doc/examples/part-handler.txt
@@ -0,0 +1,12 @@
+#part-handler
+# vi: syntax=python ts=4
+
+def list_types():
+ return(["text/plain", "text/go-cubs-go"])
+
+def handle_part(data,ctype,filename,payload):
+ if ctype == "__end__" or ctype == "__begin__": return
+
+ print "==== received ctype=%s filename=%s ====" % (ctype,filename)
+ print payload
+ print "==== end ctype=%s filename=%s" % (ctype, filename)