-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 29 Jan 2010, at 21:41, Vladimir Dronnikov wrote:
How do I append gp.fileupload to an existing Shabti
(shabti_formalchemy) application? In particular, how to attach the
middleware?
Using the standard tempita substitution pattern, replace {{package}}
with your app's name:
development.ini
==========
[server:main]
use = egg:Paste#http
host = 127.0.0.1
port = 5000
request_queue_size = 200
[pipeline:main]
pipeline = fileupload {{package}}
[filter:fileupload]
use = egg:gp.fileupload
include_files = fileupload.css jquery.fileupload.*
tempdir = %(here)s/data/fileupload
max_size = 50
upload_to = %(here)s/data/filestorage
# The above specs for fileupload are based on the following:
## temporary directory to write streams to
# tempdir = %(here)s/data/fileupload
## file to inject in the html code
#include_files = fileupload.css jquery.*
## if you already have jquery in your application, use this line
#include_files = fileupload.css jquery.fileupload.*
## max upload size is 50Mo
#max_size = 50
## use this options to also wrap your application with a Storage
middleware
#upload_to = %(here)s/storage
#exclude_paths = /@@
[app:{{package}}]
use = egg:{{package}}
full_stack = true
static_files = true
lang = en
controllers/upload.py
============
import logging
from pylons import request
from {{package}}.lib.base import *
log = logging.getLogger(__name__)
class UploadController(BaseController):
def index(self):
return render('/upload.mako')
def save(self):
log.info('%s', request.POST)
log.info('%s', request.environ)
templates/upload.mako
==============
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Pylons Default Page</title>
<style>
body { background-color: #fff; color: #333; }
body, p {
font-family: verdana, arial, helvetica, sans-serif;
font-size: 12px;
line-height: 18px;
}
a { color: #000; }
a:visited { color: #666; }
a:hover { color: #fff; background-color:#000; }
</style>
<script src="/gp.fileupload.static/jquery.js" type="text/
javascript"></script>
<script type="text/javascript">
//<![CDATA[
jQuery(document).ready(function() {
jQuery("form[enctype^='multipart/form-data']").fileUpload();
jQuery("#sample").fileUpload({action: "/upload/save"});
});
//]]>
</script>
</head>
<body>
<h1>Welcome to your Pylons Web Application</h1>
<h3>Wrapping an existing form</h3>
<form action="/upload/save" enctype="multipart/form-data" method="POST">
<input type="file" name="file1" /><br/>
<input type="submit" />
</form>
<h3>A pure javascript form</h3>
<div id="sample"></div>
<div> </div>
<script type="text/javascript" src="/gp.fileupload.static/
jquery.fileupload.js"></script>
<script type="text/javascript" src="/gp.fileupload.static/
jquery.fileupload.auto.js"></script>
</body>
</html>
That's about it., I think.
Be warned though, it seems to prevent evalexception from working. And
although I successfully uploaded and stored files, they weren't big
enough to exercise the Ajax/progress bar issue.
Cheers,
Graham
http://www.linkedin.com/in/ghiggins
-----BEGIN PGP SIGNATURE-----
iEYEARECAAYFAktjX3AACgkQOsmLt1NhivwDJQCePbdBP26mTWh0AI8RBZkBjbmA
lFMAoJIpI3CF1J4UKzh20Y+ZSSfxDRI/iQCVAgUBS2NfcFnrWVZ7aXD1AQLAGgP+
NKBHBoEzRysAZX1V46n7wm64JVYlPb6bt54NM6NSxtqPwz1Kw69KZYyGC5l0ib0i
JOjQ/rlG8/jioHhxqDYQzJp2gqf9a1c9CA3AVxMB4z8UU7F3Nsk5t7YHdPAqZ1tw
MCK0C4HMuyFGJ24P+Rw8acHLTUri9cWZPtHVQKmzytw=
=8OCU
-----END PGP SIGNATURE-----
--
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en.