Thanks for sharing the solution, I did not know that quotes_file holds the
file content
On Friday, March 22, 2013 2:34:16 AM UTC-4, software.ted wrote:
>
> Ok great and thanks for all your help, the file is being saved and all
> works as expected!!! code that works below:
>
> 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 isinstance(request.vars.quotes_file, cgi.FieldStorage):
> test = "My File"
> if form.process().accepted:
> response.flash = "Data Saved"
> elif form.errors:
> response.flash = "Form has error"
> return locals()
>
>
> On Fri, Mar 22, 2013 at 1:21 AM, Anthony <[email protected]
> <javascript:>>wrote:
>
>> Recall that the suggestions to forego calling form.process() and instead
>> just check for and directly manipulate request.vars.quotes_file was
>> assuming you did not want to permanently store the file. If you do want to
>> keep the file, then you should call form.process() (or include code to
>> manually save the file). However, it's not clear that you do really need to
>> keep the file. Presumably whatever code you plan to use to process and
>> store the data would first open the file and then work with the open file
>> object -- instead, you should be able to work with the FieldStorage file
>> object directly (i.e., request.vars.quotes_file.file).
>>
>> Anthony
>>
>>
>> On Thursday, March 21, 2013 2:01:01 PM UTC-4, software.ted wrote:
>>
>>> But the question again is where is the file stored, its not appearing in
>>> the specified uploads directory for manipulation. What I want to do is
>>> upload an excel sheet with specific columns of data, then get the data and
>>> insert into db with similar columns
>>> On Mar 21, 2013 6:48 PM, "Anthony" <[email protected]> wrote:
>>>
>>>> if request.vars.quotes_file:
>>>>
>>>>
>>>> Sorry, I didn't realize this, but apparently if you do "if
>>>> [cgi.FieldStorage object]" you get False rather than True, so instead try:
>>>>
>>>> if hasattr(request.vars.quotes_**file, "file"):
>>>>
>>>> or
>>>>
>>>> import cgi
>>>> if isinstance(request.vars.quotes**_file, cgi.FieldStorage)
>>>>
>>>>
>>>>
>>>>> I have further noticed this error in the page source after making a
>>>>> submit:
>>>>>
>>>>>
>>>> var ajax_error_500 = 'An error occured, please <a
>>>>> href="/testapp/default/index?**f**irst_name=bggfbfg&quotes_**f**
>>>>> ile=FieldStorage%28%27quotes_**f**ile%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'
>>>>>
>>>>
>>>> That is not an error -- it is just a Javascript variable that is
>>>> automatically generated by web2py_ajax.html. It is there in case there is
>>>> an Ajax error on the page, in which case it will be used to generate an
>>>> error message. However, I notice there is an error in the code used to
>>>> generate that variable -- it should not be including post_vars in the link
>>>> URL, only get_vars (I have submitted a patch to correct that).
>>>>
>>>> Anthony
>>>>
>>>> --
>>>>
>>>> ---
>>>> 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>
>>>> .
>>>>
>>>>
>>>>
>>> --
>>
>> ---
>> 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 [email protected] <javascript:>.
>> 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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.