Massimo,
Sorry for the delay. Work had me unplugged for a while. Hilights --
* trigger() just there to pop the form.
* dwnld() I just took right out of your 'Rolling with...' document.
* The jQuery set is on the input field and is bound to a double
click.
* The call to dwnld() is hardcoded for simplicity sake.
* No validation applied and the file in question is assumed to be
available in the upload directory.
Technically its not a redirect, but does achieve what Fran was
discussing. On my Linux clients, with Adobe 9/10 loaded, if the file
is a PDF adobe comes up in the window with the file in view.
Application(test):
--------------
Controller(filedwn.py):
--------------
# try something like
def index(): return dict(message="hello from filedwn.py")
def dwnld():
import gluon.contenttype
filename=request.args[0]
response.headers['Content-Type']=\
gluon.contenttype.contenttype(filename)
return open('applications/%s/uploads/%s' %
(request.application,filename),'rb').read()
def trigger(): return dict()
View(filedwn/trigger.html):
-------------
{{extend 'layout.html'}}
<!-- Scripts to manage display -->
<script type="text/javascript">
//Set events for form
$(document).ready(function() {
//Bind getfile() to double click event
$('form').find('#file_dwnld').css('color','blue').bind
('dblclick',function(){getfile();});
});
function getfile(){
var text = $('#file_dwnld').val();
var link = "/test/filedwn/dwnld/" + text;
window.open
(link,"mywindow","scrollbars=1,resizeable=1,width=600,heigth=450");
};
</script>
<h1>This is the filedwn example</h1>
<div id='divone'>
<div id = 'divtwo'>
<form>
<input id="file_dwnld"type="text" value="" />
</form>
</div>
</div>
<!--- {{=BEAUTIFY(response._vars)}} --->
On Jun 9, 9:49 pm, mdipierro <[email protected]> wrote:
> could you post an example
>
> On Jun 9, 8:07 pm, JohnMc <[email protected]> wrote:
>
> > Fran,
>
> > I do something very similar in jQuery. Bind a object to an event and
> > use a anonymous function that calls Windows.Open(). The new window
> > could call a download function. But I guess at that point its not a
> > redirect.
>
> > JohnMc
>
> > On Jun 9, 1:56 pm, Fran <[email protected]> wrote:
>
> > > On Jun 9, 7:19 pm, mdipierro <[email protected]> wrote:
>
> > > > If your intention is to return the PDF to the
> > > > user (http 200 ok) you cannot redirect (http 303 redirect). The two
> > > > statements are not compatible.
>
> > > Whilst at first sight I'd say that's true, what could be done is to
> > > return the PDF in another Window/Tab (A target="_blank") & then do the
> > > redirect.
> > > I would do this by calling the PDF controller function from a wrapper
> > > function which has that page.
>
> > > F
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py Web Framework" 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/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---