Anthony,

I have noticed an error in the code. I have created a very simple form to
test the upload without using components. The code is as follows:

Controller:
=============
def index():
    form = SQLFORM.factory(Field("first_name"),Field("quotes_file",
"upload", uploadfolder=os.path.join(request.folder, 'uploads')))
    test = ''
    first_name = ''
    if request.vars.first_name:
        first_name = "My test"
    if request.vars.quotes_file:
        test = "My File"
    return locals()

View:
==============
{{extend 'layout.html'}}<br>
File: {{=test}}<br>

First name: {{=first_name}}
{{=form}}
{{=BEAUTIFY(request.vars)}}

When i submit the form with a file attached the beautify displays the file
content and the value for first_name.

But, the value for "test" = "My File" is not being displayed in the view,
while the "first_name" = "My test" is being displayed without any problem.

I have further noticed this error in the page source after making a submit:

<script type="text/javascript"><!-- // These variables are used by the
web2py_ajax_init function in web2py_ajax.js (which is loaded below). var
w2p_ajax_confirm_message = "Are you sure you want to delete this
object?";var w2p_ajax_date_format = "%Y-%m-%d";var
w2p_ajax_datetime_format = "%Y-%m-%d %H:%M:%S";var ajax_error_500 =
'An error occured, please <a
href="/testapp/default/index?first_name=bggfbfg&amp;quotes_file=FieldStorage%28%27quotes_file%27%2C+%27rows+%282%29.csv%27%2C+%27circular.circular_no%2Ccircular.recipients%2Ccircular.circular_title%2Ccircular.circular_date%5Cr%5CnNAZ%2F1%2F2013%2CALL+MEMBERS+OF+STAFF%2CLunch+to+be+served+at+the+Motel%2C2013-03-01%5Cr%5Cn%27%29">reload</a>
the page' //--></script>

any idea on whats going on here?


On Wed, Mar 20, 2013 at 9:01 PM, Teddy Nyambe <software....@gmail.com>wrote:

> Actually this this is how am loading it, please advise:
>
> {{=A('Quotes', component=URL('quotes','quotes.loadp ),
> target='quote-content')}}
>
> <div id='quote-content'></div>
>
> One funny thing is when I add a simple text field to the SQLFORM.factory
> and submit sample content...its displayed...only for upload is not showing.
> On Mar 20, 2013 4:23 PM, "Anthony" <abasta...@gmail.com> wrote:
>
>> Did you set ajax=True or ajax_trap=True in your LOAD() call? If not, the
>> form will get posted to the action of the containing page, not the
>> component action.
>>
>> Anthony
>>
>> On Wednesday, March 20, 2013 10:06:28 AM UTC-4, software.ted wrote:
>>>
>>> Anthony,
>>>
>>> Am having a very funny behavior. I am loading a form in a component
>>> quotes.load in another page of a <div>.
>>> When i access the component directly through the URL address the
>>> {{=BEAUTIFY(request.vars)}} am able to see the uploaded file, but accessing
>>> it through the component its sending empty quotes upload file note the code:
>>>
>>> controller
>>>
>>> def quotes():
>>>     form = SQLFORM.factory(Field("first_**name"), Field("quotes",
>>> "upload", uploadfolder=os.path.join(**request.folder,'uploads')))
>>>
>>>     file_name=""
>>>
>>>     first_name = ""
>>>
>>>     if request.vars.quotes:
>>>           file_name="test"
>>>
>>>     if request.vars.first_name:
>>>         first_name = "Testing"
>>>
>>>     return dict(form=form, file_name = file_name, first_name =
>>> first_name)
>>>
>>>
>>>
>>>
>>>
>>> view::-------->>>>>>>
>>>
>>> First name is: {{=file_name}}<br>
>>>
>>>         {{=form}}<br>
>>>
>>>         First name is:{{=first_name}}
>>>
>>> filename is returning empty all the time.
>>>
>>>
>>> On Wed, Mar 20, 2013 at 3:21 PM, Anthony <abas...@gmail.com> wrote:
>>>
>>>> As is, your code should generate an error because you haven't specified
>>>> an upload folder, which is required when passing new Field objects to
>>>> SQLFORM.factory. Try:
>>>>
>>>>     import os
>>>>     SQLFORM.factory(Field("quotes"**, "upload", uploadfolder=os.path.
>>>> join(requ**est.folder, 'uploads')))
>>>>
>>>> If you don't want to save the file at all, though, then don't call
>>>> form.process(). Instead, just check for the uploaded file:
>>>>
>>>>     if request.vars.quotes:
>>>>         manage_quotes(request.vars.quo**tes.file)
>>>>
>>>> Anthony
>>>>
>>>> On Wednesday, March 20, 2013 8:30:29 AM UTC-4, software.ted wrote:
>>>>>
>>>>> I want to upload a file to web2py and then manipulate it. I dont want
>>>>> to save it into the database...after manipulating it i want to delete it.
>>>>> How do i do that. I have been trying like this but all fails:
>>>>>
>>>>> Controller:
>>>>>
>>>>> def quotes():
>>>>>     form = SQLFORM.factory(Field("quotes"****, "upload")
>>>>>     if form.process().accepted:
>>>>>         manage_quotes(form.vars.**quotes**)
>>>>>     elif form.errors:
>>>>>         response.flash = "form has error"
>>>>>
>>>>> After upload I cannot see the uploaded in the upload folder!
>>>>>
>>>>> regards
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> ..............................****..............................****
>>>>> ...........................
>>>>> Teddy Lubasi Nyambe
>>>>> Opensource Zambia
>>>>> Lusaka, ZAMBIA
>>>>>
>>>>> Cell: +260 97 7760473
>>>>> website: http://www.opensource.org.zm
>>>>>
>>>>> ~/
>>>>> Human Knowledge belongs to the world! - AntiTrust
>>>>>
>>>>> Man is a tool-using animal. Without tools he is nothing, with tools he
>>>>> is all - Thomas Carlyle 1795-1881
>>>>>
>>>>> /~
>>>>>
>>>>  --
>>>>
>>>> ---
>>>> You received this message because you are subscribed to the Google
>>>> Groups "web2py-users" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to web2py+un...@**googlegroups.com.
>>>> For more options, visit 
>>>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
>>>> .
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>> --
>>> ..............................**..............................**
>>> ...........................
>>> Teddy Lubasi Nyambe
>>> Opensource Zambia
>>> Lusaka, ZAMBIA
>>>
>>> Cell: +260 97 7760473
>>> website: http://www.opensource.org.zm
>>>
>>> ~/
>>> Human Knowledge belongs to the world! - AntiTrust
>>>
>>> Man is a tool-using animal. Without tools he is nothing, with tools he
>>> is all - Thomas Carlyle 1795-1881
>>>
>>> /~
>>>
>>  --
>>
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "web2py-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to web2py+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>


-- 
.......................................................................................
Teddy Lubasi Nyambe
Opensource Zambia
Lusaka, ZAMBIA

Cell: +260 97 7760473
website: http://www.opensource.org.zm

~/
Human Knowledge belongs to the world! - AntiTrust

Man is a tool-using animal. Without tools he is nothing, with tools he is
all - Thomas Carlyle 1795-1881

/~

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to