[web2py] Upload error with 2.23.0? ('Field' object has no attribute '__dir__')

2022-12-29 Thread Stephan
Hi,
uploads with sqlite doesn't work anymore in my apps. I recognized this 
after installing ver. 2.23.0. Maybe it's just a coincidence. Here is the 
code:

127.0.0.1.2022-12-29.16-19-26.abbdc90d-cd14-467e-bd96-12f360bf1d4d

 'Field' object has no attribute '__dir__'

Version
web2py™Version 2.23.0-stable+timestamp.2022.12.27.07.14.15
PythonPython 2.7.16: 
/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
 
(prefix: /System/Library/Frameworks/Python.framework/Versions/2.7)
Nachverfolgung

Traceback (most recent call last):
  File "/Users/user/Sites/web2py/gluon/restricted.py", line 219, in 
restricted
exec(ccode, environment)
  File "/Users/user/Sites/web2py/applications/init/controllers/default.py", 
line 426, in 
  File "/Users/user/Sites/web2py/gluon/globals.py", line 430, in 
self._caller = lambda f: f()
  File "/Users/user/Sites/web2py/gluon/tools.py", line 3927, in f
return action(*a, **b)
  File "/Users/user/Sites/web2py/applications/init/controllers/default.py", 
line 301, in manage
grid = SQLFORM.smartgrid(db.contents, 
orderby=dict(contents=~db.contents.id, einfuegen=db.einfuegen.projekt), 
onvalidation=check_unique, paginate=30)
  File "/Users/user/Sites/web2py/gluon/sqlhtml.py", line 3356, in smartgrid
user_signature=user_signature, **kwargs)
  File "/Users/user/Sites/web2py/gluon/sqlhtml.py", line 2566, in grid
onsuccess=oncreate)
  File "/Users/user/Sites/web2py/gluon/html.py", line 2343, in process
self.validate(**kwargs)
  File "/Users/user/Sites/web2py/gluon/html.py", line 2281, in validate
if self.accepts(**kwargs):
  File "/Users/user/Sites/web2py/gluon/sqlhtml.py", line 1923, in accepts
field.uploadfolder)
  File "/Users/user/Sites/web2py/gluon/packages/dal/pydal/objects.py", line 
2075, in store
self._tablename if '_tablename' in self.__dir__() and self._tablename 
else 'no_table',
AttributeError: 'Field' object has no attribute '__dir__'
Fehler-Schnappschuss  help
('Field' object has no attribute 
'__dir__')

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/574f8456-478b-4da5-ac65-1f2d1f108bf0n%40googlegroups.com.


[web2py] Upload images to folder outside web2py

2020-11-02 Thread 'Annet' via web2py-users

To upload images to separate folders outside web2py I set the upload folder 
with the model definition:

UPLOADSDIR = '/home/me/apps/static/'

db.define_table('mytable',
Field('image', 'upload', autodelete=True, uploadfolder=os.path.join(
UPLOADSDIR, 'vertexID%s' % session.vertexID),
...)


I use the standard download function:

def download():
return response.download(request, db)


The form:

form = SQLFORM(table, row, deletable=True, upload=URL('default', 
'download'), showid=False, buttons=buttons)
if hasattr(request.vars.image, 'filename'):
form.vars.imagefilename = request.vars.image.filename


and to process the form:

if form.process().accepted:
if row and form.vars.image__delete:
file = row.image
os.remove(os.path.join(UPLOADSDIR, 'vertex%s' % 
session.back_end_vertexid, file))


In web2py 2.17.2 this all worked without problem, however, after upgrading 
to
web2py 2.20 it no longer works. The image doesn't show in the form, it's 
marked
with a broken link icon, and when I click the file link I get a page not 
found error.
Also when I upload a new image, the old one isn't being deleted, so the 
images pile
up in the folder.

I hope someone knows how to solve this issue.


Kind regards,

Annet

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/21d8da30-28f0-4a10-9550-ad8cd84d5f3dn%40googlegroups.com.


[web2py] upload - can I get the path to original file

2019-10-04 Thread 'jim kaubisch' via web2py-users
Hi

In a file upload, I want to store both the original filename AND the path 
to the original file (to cover the case of files with the same name but 
from different folders)
I'm successfully getting the filename from "request.vars.the_file.filename" 
as documented, but is there somewhere I can retrieve the path?

Thanks

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/d1c61d6f-2e89-47c8-913b-843e28a8d182%40googlegroups.com.


[web2py] Upload field causing a temp file issue

2019-08-21 Thread Paul Ellis
I have 2 similar controller functions using SQLFORM() with an upload field. 
One works and one is giving an error online (not when testing locally). I 
suspect a file system permission problem but I am not sure.
The error only occurs if an image is uploaded. 
The extra processing after the form is submitted is not the cause. I 
removed it as a test and the error remains.

The error:
Traceback

1.
2.
3.
4.
5.
6.
7.

Traceback (most recent call last):
  File "/home/act/web2py/gluon/main.py", line 505, in wsgibase
request.body.close()
  File "/usr/local/lib/python2.7/tempfile.py", line 431, in close
self.unlink(self.name)
OSError: [Errno 2] No such file or directory: '/tmp/tmp2PXnS0'

The Function:
@auth.requires_login()
def add_custom():

try:
offerId = request.args[0]
except IndexError:
offerId = 0
offerDetails = offer.authorise(offerId)
status = roo.status(offerDetails)

pagetitle = H4(T('Custom Product'))
buttongroup = [btn.back()]

try:
record = db.custom_product[request.args[1]] or None
except [IndexError, KeyError, TypeError]:
record = None

if session.custom_copy:
db.custom_product.productname.default = session.custom_copy.
productname
db.custom_product.description.default = session.custom_copy.
description
db.custom_product.purchasecost.default = session.custom_copy.
purchasecost
db.custom_product.monthlycost.default = session.custom_copy.
monthlycost
#db.custom_product.smallimage.default = 
session.custom_copy.smallimage
session.custom_copy = None

db.custom_product.created_on.readable = False
db.custom_product.updated_on.readable = False

form = SQLFORM(db.custom_product, record, showid = False)

if form.process().accepted:
#do this for insert but not update
if not record:
# need to get the max priorites from the offer table
pp = mp = None
# offerDetails = db.offer[session.quote.number]

# increment whichever needs to be used and save it to the offer 
table
if form.vars.purchasecost:
if offerDetails.offer.maxpurchasepriority:
offerDetails.offer.maxpurchasepriority += 1
else:
offerDetails.offer.maxpurchasepriority = 1
pp = offerDetails.offer.maxpurchasepriority
if form.vars.monthlycost or (not form.vars.purchasecost and not 
form.vars.monthlycost):
if offerDetails.offer.maxmonthlypriority:
offerDetails.offer.maxmonthlypriority += 1
else:
offerDetails.offer.maxmonthlypriority = 1
mp = offerDetails.offer.maxmonthlypriority
offerDetails.offer.update_record()

# insert record into product_offer_item
db.product_offer_item.insert(
offer_id = offerDetails.offer.id,
custom_pid = form.vars.id,
quantity = 1,
purchasepriority = pp,
monthlypriority = mp,
)
else:
# only do this for updates
# check if a price change also needs a priority change
poiRecord = record.product_offer_item.select().first()
pp = copy.copy(poiRecord.purchasepriority)
mp = copy.copy(poiRecord.monthlypriority)
#poi_set = db(db.product_offer_item.custom_pid == poiRecord.id)
if pp and (not form.vars.purchasecost > 0):
poiRecord.update_record(purchasepriority = 0)
if not pp and (form.vars.purchasecost > 0):
poiRecord.update_record(purchasepriority = 99.5)
if mp and (form.vars.purchasecost > 0 and not form.vars.monthlycost 
> 0):
poiRecord.update_record(monthlypriority = 0)
if not mp and\
((not form.vars.purchasecost > 0 and not 
form.vars.monthlycost 
> 0) or\
not form.vars.purchasecost > 0 and form.vars.monthlycost 
> 0):
poiRecord.update_record(monthlypriority = 99.5)
offer.position_check(offerDetails.offer.id)
session.flash = T('Success')
redirect(btn.EditOffer(offerDetails.offer.id, 
dict(custId = offerDetails.customer.id)).url)

elif form.errors:
response.flash = T('Errors in form')
else:
pass
response.view = 'core.html'
return dict(
pagetitle = pagetitle,
pagecontent = form,
buttongroup = buttongroup,
status = status,
)

The Table definition:
db.define_table(
'custom_product',
Field('productname', label=T('Product Name')),
Field('description', 'text', label=T('Description')),
Field('purchasecost', 'double', default = 0, label = T('Purchase Cost'
)),
Field('monthlycost', 'double', default = 0, label = T('Monthly Cost')),
Field('created_on', 

[web2py] Upload - need help

2019-01-05 Thread wswiecho
Hello,

I have an upload field in my form. It works fine when I run it on the same 
machine as the web2py service. The issue comes when I run the service on 
the server and the UI on a different machine. The issue is the fact that 
existence of the file path I enter is checked on the server as opposed to 
the machine from where I try to upload the file. How do you fix it? This is 
the definition of the form I have:


list_dictionary_names = os.listdir(os.getcwd() + 
*'/applications/mcarriage_console/uploads/dictionaries'*)
list_dictionary_types = list(set((i[:i.find(*'_'*)] if i[:i.find(*'_'*)]
 == *'ITCR'* else i[:i.find(*'_D'*)].replace(*'_'*, *' '*))  for i in
 list_dictionary_names if i[0].isupper()))
obj_admin = AdminClass(auth, db, session)


alert_message = *'Process of uploading may take a few minutes. The file 
content is first inserted into MARS database. '*
alert_message += *'Then content of the previously active file is 
checked for any updates. '*
alert_message += *'If no changes were made the content of the 
previously file is removed '*
alert_message +=  *'and the previously active data dictionary is set 
inactive.'*
session.message = alert_message
#obj_message = MessageDisplay(session.message)
button_list = [INPUT(_type=*'submit'*, _value=*'Submit'*)]


form = SQLFORM.factory(
   Field(*'file_type'*,
 label = *'Dictionary Type'*,
 requires=IS_IN_SET([ i[*'DICTIONARY_TYPE'*]
 for i in db(db.DATA_DICTIONARIES.ACTIVE_ID == *'A'*).select(
db.DATA_DICTIONARIES.DICTIONARY_TYPE)] if len(db(
db.DATA_DICTIONARIES.ACTIVE_ID == *'A'*).select(
db.DATA_DICTIONARIES.DICTIONARY_TYPE)) > 4 else list_dictionary_types  )),
   Field(*'file_version'*,
 label = *'Dictionary Version'*,
 requires=IS_NOT_EMPTY()),
   Field(*'file_directory'*,
 label = *'File Path'*,
 _type = *'string'*,
 requires=IS_NOT_EMPTY()
 #uploadfield=False,
 #uploadfolder
=os.path.join(request.folder,'uploads/')
 ),
   #Field('file', 'upload', requires = IS_LENGTH(
minsize=0, maxsize=1048576, error_message='File is too huge.')),
  buttons = button_list
  )

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


[web2py] Upload CSV file though app admin getting an error in 2.17.2

2018-12-31 Thread sandeep patel
Hello All,
I am getting an error while uploading a CSV  file to table though app admin.

[image: error.PNG]


I am using python3.6 and web2py 2.17.2.

Thanks
SP

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


[web2py] upload a photo to your site by >

2018-12-06 Thread Morteza Tabibi
Hello everyone
I just started designing web2py I have a problem I can not upload a photo 
to your site with the command >
  And my operating system is Linux, thanks for giving me an example guide

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


Re: [web2py] Upload an image from front-end

2018-02-05 Thread Marco Mansilla
I'm looking for a similar solution, but the front-end is written in VueJs,
and Axios for POST and GET requests, since I couldn'd find a way to send
the actual file to the server I'm going with a solution close to your
second option, has some extra steps but it's clean and somehow more verbose
for multiple uploads, loading notifications and progress tracker.

2018-02-05 18:48 GMT-03:00 Πέτρος Χατζηλάμπρος :

> Dear all,
> in my last project I am using the following architecture:
>
>-  Web2py is used only at the back-end.
>- The front-end is developed using React by an other developer.
>- The front end sends GET and POST requests to web2py and web2py
>responds with json.
>
> Using this architecture what is the best way to send and store an image
> from the browser to the web2py ? I am thinking to use one of the three
> following methods:
>
>- use a web2py controller to create a form with an upload field, sent
>the hidden form inputs(_formkey and _formname) to front-end and then the
>front-end will use javascript to imitate the behavior of the browser
>- The front-end will use javascript to convert the file to base64
>format and it will send it with a POST request to web2py. Then web2py will
>convert the base64 string into a file and it will save it  to folder
>/uploads using a controller
>
> Which method you think that fits better to web2py ?
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> 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/d/optout.
>



-- 
-BEGIN GEEK CODE BLOCK-
version 3.1
GCS/GTW/| d? s+:+>+++ a-- C+++(+) UL>$ P++>+++ L+++>+$ E->+ W++>+
N>+++ o K- w---()
O(--) M>-- V-- PS++ PE++>+ Y-->+ PGP+>+++ t-(?) 5? X++ R+ !tv b+++>
DI+++ D--- G+++>+
e+++> h* r++>+++ y++
--END GEEK CODE BLOCK--

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


[web2py] Upload an image from front-end

2018-02-05 Thread Πέτρος Χατζηλάμπρος
Dear all,
in my last project I am using the following architecture:

   -  Web2py is used only at the back-end. 
   - The front-end is developed using React by an other developer. 
   - The front end sends GET and POST requests to web2py and web2py 
   responds with json. 
   
Using this architecture what is the best way to send and store an image 
from the browser to the web2py ? I am thinking to use one of the three 
following methods:

   - use a web2py controller to create a form with an upload field, sent 
   the hidden form inputs(_formkey and _formname) to front-end and then the 
   front-end will use javascript to imitate the behavior of the browser
   - The front-end will use javascript to convert the file to base64 format 
   and it will send it with a POST request to web2py. Then web2py will convert 
   the base64 string into a file and it will save it  to folder /uploads using 
   a controller

Which method you think that fits better to web2py ?

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


[web2py] Upload to auth_user

2017-09-01 Thread Tiago Barrionuevo
Hi,

I'm trying to upload images to auth_user without success. I already did it 
with other database tables with no problem.

My code:

model:

auth.settings.extra_fields['auth_user'] = [
Field('picture', 'upload', autodelete=True, label=T('Picture')),
]


I'm using the appadmin interface (myapp//appadmin/manage/users).

When I submit the Edit form with a chosen image the form processing stops 
with submit button showing "Working...".

With auth_user I didn't even need to setup SQLFORM() call or download 
function. I don't know if I'm missing something!

Running Web2py version 2.15.3.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


[web2py] upload and download, in order to manage attached files

2017-05-17 Thread J-Michel Angers
Hi,
I'm building an app to fill "PurchaseRequest", to valid it by the staff, 
and then type a "PurchaseOrder". Exactly like with a paper form that we 
fill, and get signatures to valid it.
Now the main boby of the app works (fill the form, set/choose the route, 
send emails to the concerned persons (by request to the Active Directory), 


Now I need for this app, to input one or more (or none) attached file 
(quotation in PDF format, Excel file, technical data in PDF format)...
I can upload this files, sort them, display the titles, ...
Impossible to show the file.
I see the file in the OS directories (/upload/, where  is 
TPJ.Document.<.>.extension).
I have a customised html page, but either I get "unknown page", or I get 
... nothing. When I manually copy the link into explorer, I see the file 


The model (only the table for attached) :
dbW.define_table('TPJ',
Field('NumDA',type='integer'),
Field('Document',type='upload',uploadfield=True,uploadfolder=os.path.
join(request.folder,'uploads')),
Field('Titre'),
rname='WFDA_DA_PJ',
migrate=False)



The controlleur for filling in is only a test fonction :
def saisie_pj():
form1 = SQLFORM(dbW.TPJ)
if form1.process().accepted:
response.flash = 'Votre PJ a été enregistrée'
return dict(form1=form1)



The display (and Iif possible showing the files):
It is nested in the main form (and this form is now quite long)
.
form = SQLFORM(dbW.WFDA_DemAchat, DA, formstyle ='bootstrap3_inline', 
buttons=LBoutons)
PiecesJointes = dbW(dbW.TPJ.NumDA==NumDA).select(dbW.TPJ.Titre, dbW.TPJ.
Document)
.



And now the html view..

{{=form.custom.begin}}


DEMANDE D'ACHAT: {{=form.custom.dspval.id}}

..

{{=form.custom.submit}}
{{=form.custom.end}}



Pièces jointes :

{{for ligne in PiecesJointes:}}
 Avec A : {{=A(ligne.Titre, 
_href=URL('upload',ligne.Document))}}
 Avec file:
{{=ligne.Titre}}
 
 {{pass}}







With the "=A(ligne.Titre...", I see the link 
"http://127.0.0.1/da/upload/TPJ.Document.blabla.pdf. When I click I get 
"404 unknown page"
With the "http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


[web2py] upload image and save in dinamic directory profile

2017-04-28 Thread felipe . marcos
hi,

I want save one image in dinamic directory  web2py, but ai not using 
SQLFORM, 

When i do upload the image i recieve in controller C:/FAKEPATH/imagename

how do i handle this path or other upload ?

sorry my inglish.

look my code:

View:


 
  

  Primeiro Nome
  
   

   
   

Segundo Nome


  
   

E-mail

 
  
   

Senha

 
   
 
 
 
   
   
  
   Cadastrar
 Limpar
  
 





$("#btn-user").click(function () {
//ADD show Modal de loading 
//$("#loading").modal('show');
$("#loading").removeClass('hide') 
var firstname = $('#cadfirstname').val();
var lastname = $('#cadsecondname').val();
var email = $('#cademail').val();
var passuser = $('#cadpassuser').val();
var image = $('#image_file').val();

alert(form_vars);
$.getJSON("{{=URL(c='manager', 
f='newuser.json')}}",{firstname,lastname,email,passuser,image}, 
 function(result){
atualizaGrid();
$("#retorno").removeClass('hide');
  
//Atualiza combobox
atualizaCombobox();
//RESETAR FORMULARIO AO INSERIR
$('#insertuser').each (function(){
  this.reset();
});

//$("#loading").modal('hide');
$("#loading").addClass('hide') 
 });   

});


CONTROLLER:

@auth.requires_login()
def newuser(): 
  import json 
  import gluon.contrib.simplejson
  
  #parametros de entrada da grid
  firstname = request.vars['firstname']
  lastname = request.vars['lastname']
  email = request.vars['email']
  passuser = request.vars['passuser']
  image = request.vars['image']
  
  # Query
  db.auth_user.insert(first_name=firstname, last_name=lastname, 
email=email, password = db.auth_user.password.validate(passuser)[0] , image 
= image, emp_id = db.auth_user[auth.user_id].emp_id)
  
  userid = db(db.auth_user).select(db.auth_user.id).last()

  db.auth_membership.insert(user_id=userid,group_id=3)
  
  
  data =  db(db.auth_user).select(db.auth_user.id,db.auth_user.first_name, 
db.auth_user.last_name,db.auth_user.email,Link.id,CentroC.nome
,left=[Link.on(Link.userid == db.auth_user.id), CentroC.on(CentroC.id == 
Link.centroid) ])
  
  code = response.session_id
  message = response.status
 
  #retorno de variaveis grid   
  return dict(code=code,message=message,data=data) 
 


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


[web2py] Upload image and send by email

2017-03-28 Thread Анатолий Стешенко
Good afternoon. I need to upload multiple images and send by mail. After 
sending the images removed. How to do it correctly?

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


Re: [web2py] Upload Video

2016-12-16 Thread David
Does it have to be a certain video format e.g. mp4?

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


Re: [web2py] Upload Video

2016-12-16 Thread Yoel Benitez Fonseca
I don't see wy your upload field is not accepting video files.

El dic. 15, 2016 4:51 PM, "David"  escribió:

> What does RTFM mean?
>
> *db:*
>
>> db.define_table('post',
>>
>>Field('page_id','reference the_page'),
>>
>>Field('your_name', 'string'),
>>
>> Field('video','upload', requires=IS_NOT_EMPTY()),
>>
>> Field('body', 'string'),
>>
>>Field('created_on','datetime', default=request.now),
>>
>>Field('created_by', 'string'),
>>
>>Field('poster' , 'reference auth_user'))
>>
>> db.post.page_id.readable=db.post.page_id.writable=False
>
> db.post.created_by.readable=db.post.created_by.writable=False
>
> db.post.created_on.readable=db.post.created_on.writable=False
>
>
>
>>
>
> *controller : irrelevant code has been omitted *
>
>> @auth.requires_login()
>>
>> @auth.requires(db(db.auth_user.bank>=199).select())
>>
>> def show():
>>
>> db.post.your_name.readable=db.post.your_name.writable=False
>>
>> this_page = db.the_page(request.args(0,cast=int)) or
>>> redirect(URL('index'))
>>
>> db.post.page_id.default = this_page.id
>>
>> pagecomments = db(db.post.page_id==this_page.id).select()
>>
>> form = SQLFORM(db.post).process()
>>
>> if form.accepted:
>>
>> db.auth_user.update_or_insert(db.auth_user.id == auth.user.id,
>>
>>bank=0)
>>
>> response.flash= T("Form Accepted.")
>>
>> elif form.errors:
>>
>> response.flash= T("Error. Please try again")
>>
>> return dict(page=this_page, comments=pagecomments, form=form)
>>
>>
>>>
> *view: irrelevant code has been omitted*
>
>> 
>>
>> Comments
>>
>> 
>>
>> {{for post in comments:}}
>>
>> 
>>
>> {{=post.poster}}: {{=post.body}}
>>
>> {{=post.video}}
>>
>> {{pass}}
>>
>> 
>>
>> 
>>
>> Comment
>>
>> {{=form}}
>>
>> 
>>
>> 
>>
>> 
>>
>> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> 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/d/optout.
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


Re: [web2py] Upload Video

2016-12-16 Thread Philip Kilner

Hi David,

On 15/12/16 21:50, David wrote:

What does RTFM mean?



Politely rendered, it means "Read the Fine Manual", meaning the info you 
are after is in the book.


:-)

HTH

--

Regards,

PhilK


'a bell is a cup...until it is struck'

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


[web2py] Upload complete, but with error

2016-12-15 Thread Dave S
When uploading a file from one of our Windows clients, we sometimes find 
this in the web2py.log file:

   File "/home/ec2-user/web2py/web2py-2.14.6/gluon/rocket.py", line 1337, in 
run

self.run_app(conn)


  File "/home/ec2-user/web2py/web2py-2.14.6/gluon/rocket.py", line 1851, in 
run_app
self.write(data, sections)


  File "/home/ec2-user/web2py/web2py-2.14.6/gluon/rocket.py", line 1766, in 
write
self.send_headers(data, sections)


  File "/home/ec2-user/web2py/web2py-2.14.6/gluon/rocket.py", line 1750, in 
send_headers
self.conn.sendall(b(header_data))


  File "/usr/lib64/python2.7/socket.py", line 228, in meth
return getattr(self._sock,name)(*args)


error: [Errno 32] Broken pipe


Is this basically a timeout because the end of transfer wasn't detected 
properly?  Or is something going wrong with preparing and sending the 
response?

/dps



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


Re: [web2py] Upload Video

2016-12-15 Thread David
What does RTFM mean?

*db:*

> db.define_table('post',
>
>Field('page_id','reference the_page'),
>
>Field('your_name', 'string'),
>
> Field('video','upload', requires=IS_NOT_EMPTY()),
>
> Field('body', 'string'),
>
>Field('created_on','datetime', default=request.now),
>
>Field('created_by', 'string'),
>
>Field('poster' , 'reference auth_user'))
>
> db.post.page_id.readable=db.post.page_id.writable=False

db.post.created_by.readable=db.post.created_by.writable=False

db.post.created_on.readable=db.post.created_on.writable=False

 

>  

*controller : irrelevant code has been omitted *

> @auth.requires_login()
>
> @auth.requires(db(db.auth_user.bank>=199).select())
>
> def show():
>
> db.post.your_name.readable=db.post.your_name.writable=False
>
> this_page = db.the_page(request.args(0,cast=int)) or 
>> redirect(URL('index'))
>
> db.post.page_id.default = this_page.id
>
> pagecomments = db(db.post.page_id==this_page.id).select()
>
> form = SQLFORM(db.post).process()
>
> if form.accepted:
>
> db.auth_user.update_or_insert(db.auth_user.id == auth.user.id,
>
>bank=0)
>
> response.flash= T("Form Accepted.")
>
> elif form.errors:
>
> response.flash= T("Error. Please try again")
>
> return dict(page=this_page, comments=pagecomments, form=form)
>
>
>>
*view: irrelevant code has been omitted*

> 
>
> Comments
>
> 
>
> {{for post in comments:}}
>
> 
>
> {{=post.poster}}: {{=post.body}}
>
> {{=post.video}}
>
> {{pass}}
>
> 
>
> 
>
> Comment
>
> {{=form}}
>
> 
>
> 
>
> 
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


Re: [web2py] Upload Video

2016-12-15 Thread Yoel Benitez Fonseca
Yes u can.

And not, "The normal "upload" type in db only lets me choose an image"
don't do that - RTFM:

http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#More-on-uploads

You are probably including some code from examples and using a image
validator for the upload field.. and pls post your code or else no
body will help.



2016-12-14 20:27 GMT-05:00 David <dshaver...@gmail.com>:
> How can I upload a video and display it in a view from the db?
>
>
> The normal "upload" type in db only lets me choose an image
>
> I have tried these links:
>
> http://www.reddit.com/r/Python/comments/1r7v23/audio_streaming_app_in_web2py_from_scratch/
> https://groups.google.com/forum/#!topic/web2py/B1l_RfCYpXA
> https://groups.google.com/forum/#!searchin/web2py/upload$20video$20%7Csort:relevance/web2py/nV64Vbjc-48/63f7wN5QnEsJ
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> 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/d/optout.



-- 
Yoel Benítez Fonseca
http://redevil.cubava.cu/
$ python -c "import this"

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


[web2py] Upload Video

2016-12-14 Thread David
How can I upload a video and display it in a view from the db?


The normal "upload" type in db only lets me choose an image

I have tried these links:

http://www.reddit.com/r/Python/comments/1r7v23/audio_streaming_app_in_web2py_from_scratch/
 
https://groups.google.com/forum/#!topic/web2py/B1l_RfCYpXA 
https://groups.google.com/forum/#!searchin/web2py/upload$20video$20%7Csort:relevance/web2py/nV64Vbjc-48/63f7wN5QnEsJ

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


[web2py] Upload files folder setup

2016-09-23 Thread SR

When we upload a file via an upload field, by default it goes into the 
/web2py/applications/yourapp/uploads folder, can we specify a different 
folder in a remote server?

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


[web2py] Upload packed application ... error message clarity

2016-09-13 Thread Dave S
I was having trouble using the upload app button.  "errors in form; please 
check it out", and "invalid package name".  It may be that I'm slow today, 
but it took me a while to realize that I was supposed to fill in the 
application name, not just the filename.  

1) maybe changing the color of the text area that's "bad" would help people 
like me
2) is it practical to use the "middle" of the filename to obtain the 
[default] application name?

/dps

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


[web2py] upload field and IS_IMAGE

2016-08-18 Thread Kirill Shatalaev
Hello.

I have in model:

Field('avatar', 'upload', required=False, autodelete=True, label=T('Avatar'),
  uploadfolder=os.path.join(request.folder, 'static/images/avatars'),
  requires=[IS_LENGTH(16384), IS_IMAGE()])


Well, the logic is simple: "avatar is not necessary, but when it uploaded, it 
must be image size of <= 16KiB".


But I *can not* submit form without image uploading, error is "Invalid Image" 
always.


Is it a bug or I do not understand something?


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


[web2py] Upload file from 'static/images' to database

2016-03-29 Thread Nick Michael
Hi, I'm having some trouble and was hoping someone could point me in the 
right direction.

I'm creating an application which has an input form which stores to a 
database. One entry accepts images, but can also be left empty (by using 
requires IS_EMPTY_OR). I also have a placeholder image saved under 
'static/images'. I want to make it so that if the upload file is left 
empty, I store the placeholder image from the 'static/images' folder in the 
database entry, otherwise it'll use the image that was uploaded by the user.

Here's my current implementation:

if request.vars.image == "":
##Enter Code Here##
else:
image_file = db.user_items.image.store(request.vars.image.file, 
request.vars.image.filename)
addItemToData (request.vars.name, request.vars.collection, 
request.vars.tag, request.vars.value, request.vars.story, image_file, 
auth.user.id, request.vars.tradeable)
redirect(URL('default', 'profile'))

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


[web2py] Upload locations in web2py_ckeditor plugin

2016-03-18 Thread David Orme
Hi,

I've installed the web2py_ckeditor plugin from:
https://github.com/timrichardson/web2py_ckeditor4/releases

I think this will working really nicely for providing a table of simple 
blog posts, but I'd like to control where uploaded files get stored. I had 
a look at the source and it seemed like ckeditor.settings.uploadfs might be 
the answer, but I can't get it to work. Everything just gets stores in the 
root of app/uploads.

In an ideal world, I'd like to able to modify this in different controllers 
so that uploads for 'blog' posts go to one folder and uploads for 'news' 
posts go to another.

Cheers,
David


*db tables*

from plugin_ckeditor import CKEditor
ckeditor = CKEditor(db)
ckeditor.define_tables()

db.define_table('blog_posts',
Field('authors', 'string'),
Field('title', 'string'),
Field('content', 'text', widget=ckeditor.widget))



*controller*

def new_blog_post():

# set where the controller is going to save uploads
ckeditor.settings.uploadfs = 'uploads/blog'

form = SQLFORM(db.blog_posts)

if form.process().accepted:
response.flash = CENTER(B('Blog post submitted.'), _style='color: 
green')
else:
response.flash = CENTER(B('Problems.'), _style='color: red')

return dict(form=form)

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


[web2py] upload fields and curl

2016-02-08 Thread Dave S
Loose end from 
:

I have an upload field, and 1 controller to upload to it via SQLFORM and 1 
controller to access it via REST.  Using the SQLFORM, the local filename is 
included in the file data (as seen in the JSON-like representation printed 
to the console during debugging), which is handy.

I've been using CURL to access the REST controller, and I haven't figured 
out how to send the local filename.  As a workaround, I use a string field 
(populated by the URL) to provide a filename.  I would prefer to have this 
field be redundant as it is in the SQLFORM dialog (or perhaps repurpose it; 
there are other strings I might want to record in the record).  My current 
CURL invocation looks like

curl --request POST -T /path/localfile.txt --user user@server pwd
 
http://SERVER/uploader/default/uplift/uploadf/ 

localfile.xt

How can I emulate the SQLFORM's data?

/dps


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


[web2py] upload file to rest service on GAE

2015-11-27 Thread James Burke

I'm having some trouble uploading/accessing a file on Google App Engine 
(GAE).

This is the code used to store the file:

@request.restful()
def workspace():
def POST(*args,**vars):

workspace_id = db.workspace.insert(repository=request.vars.
repository,
name=request.vars.name,
file=db.workspace.file.store(
request.vars.file))
from gluon.serializers import json
return json(dict(workspace_id=workspace_id))


return locals

When I check the field in the Datastore viewer (file_blob) it returns "No 
data was found".

When I change the above code to:

@request.restful()
def workspace():
def POST(*args,**vars):

workspace_id = db.workspace.insert(repository=request.vars.
repository,
name=request.vars.name,
file=db.workspace.file.store(
request.vars.file))

print '###'
print db.workspace(workspace_id).file
print db.workspace.file.retrieve(db.workspace(workspace_id).file)
print '###'

from gluon.serializers import json
return json(dict(workspace_id=workspace_id))


return locals

I get the following in the log:

###

workspace.file.b575903eaa01af0a.6e6f6e65326e6f6e65202831292e666d77.fmw

6051711999279104

ERROR2015-11-28 07:25:42,062 restricted.py:69]  Unable to store in 
FILE: /web2py/applications/init/controllers/workspace.py


Traceback (most recent call last):

  File "/web2py/gluon/restricted.py", line 227, in restricted

exec ccode in environment

  File "/web2py/applications/init/controllers/workspace.py", line 214, in 


  File "/web2py/gluon/globals.py", line 412, in 

self._caller = lambda f: f()

  File "/web2py/gluon/tools.py", line 3785, in f

return action(*a, **b)

  File "/web2py/gluon/globals.py", line 378, in f

return rest_action(*_self.args, **getattr(_self, 'vars', {}))

  File "/web2py/applications/init/controllers/workspace.py", line 128, in 
POST

print db.workspace.file.retrieve(db.workspace(workspace_id).file)

  File "/web2py/gluon/packages/dal/pydal/objects.py", line 1544, in retrieve

raise NotFoundException

NotFoundException


Any help is appreciated.


Cheers,

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


[web2py] upload using restful

2015-11-24 Thread Jose
Hi

How I can upload a file using RESTful api?

Jose

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


[web2py] upload file path

2015-11-17 Thread Manuele Pesenti
Hi!
What's the right way of rebuilding file path of any record of my table
with an upload field like:

Field("archivio", "upload", uploadfolder=archive_upload_path,
uploadseparate=True)

where archive_upload_path = os.path.join(request.folder,'uploads/archives')

maybe something like:

path_to_file = os.path.join(db.mytable.archivio.uploadfolder, ,
row.archivio)

Thank you very mutch in advance

 Manuele

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


[web2py] upload field type doesn't show in grid or smartgrid

2015-10-19 Thread 黄祥
hi,

i have upload field type doesn't show in grid or smartgrid, in the older 
version i believe it shown by default. is it normal in the recent version 
(2.12.3) not shown the upload field type by default?

ref:
http://web2py.com/books/default/chapter/29/03/overview#Adding-grids

p.s.
in the book that i believe using the older version is shown by default

best regards,
stifan

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


[web2py] upload and sqlform.grid

2015-10-05 Thread Laurent Lc
Hi,

I'd like to show pics for each records when i return a grid. My function is 
:

def showonly():
query=(db1.test.present=='present')
grid = SQLFORM.grid(query=query, user_signature=False, maxtextlength = 
40,deletable=False, \
editable=False, create=False, details=False, \
links=[dict(header='picture',body=lambda row: 
A(IMG(_src=URL('download', args=row.picture), _width=50, _height=50), 
_href=URL('download', args=row.picture)))], \

fields=[db1.test.nom,db1.test.burtelephone,db1.test.mail,db1.test.groupe, 
db1.test.picture],orderby=db1.test.nom) 
return dict(grid=grid)  

The pic does not appear (header pb i think, but i follow the doc and i do 
not understand)
And there are 2 times the field "picture" in the columns (it works when i 
click on the link "file")

So i would like to have just one column "picture" whith a pic inside 

thank you

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


[web2py] Upload via ajax

2015-09-03 Thread Jose
Hi

I want to upload a file via ajax. What I have working for when the file is 
stored in a folder, the problem and when I want it stored in a blob field.

*In upload_picture function I do not know how to put the value of 
image_blob *

The code is as follows

==
/models/db.py
==

tb_pictures = db.define_table('pictures',
Field('name'),
Field('image', 'upload', uploadfield='image_blob'),
Field('image_blob', 'blob', writable=False, readable=False),
)



==
/controllers/default.py
==
def pictures():
return dict(f=LOAD('default', 'formpictures.load', ajax=True, ajax_trap=
True))

def formpictures():
form = SQLFORM(tb_pictures, _id="formuploadajax")

return dict(form=form)

def upload_picture():
fd=request.vars.image
tb_pictures.insert(
name=request.vars.name,
image=fd,
*image_blob=fd,* #<===
)

#return



==
/views/default/formpictures.load
==


$(function(){
$("#formuploadajax").on("submit", function(e){
e.preventDefault();
var f = $(this);
var formData = new FormData(document.getElementById(
"formuploadajax"));
$.ajax({
url: "{{=URL('upload_picture')}}",
type: "post",
//dataType: "html",
dataType: "script",
data: formData,
cache: false,
contentType: false,
processData: false,
success: function (result) {
alert(result);
}
})
});
});


{{=form}}


José

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


[web2py] Upload files via ajax using jquery.form

2015-08-11 Thread pang
The web2py book says:

Because Ajax post does not support multipart forms, i.e. file uploads, 
 upload
 fields will not work with the LOAD component


This is a pity, as we are expected to split backend and frontend these 
days, and ajax comes handy. I have found other people hitted the same 
problem but didn't find a solution:

   - 
   
https://groups.google.com/forum/#!searchin/web2py/upload$20file$20ajax/web2py/6yL1pNd7QE0/-9z7DWoQyDwJ
   - 
   
https://groups.google.com/forum/#!searchin/web2py/upload$20file$20ajax/web2py/PmvIKczfn84/MCJso4P0vXEJ
   - 
   
https://groups.google.com/forum/#!searchin/web2py/upload$20file$20ajax/web2py/IHSnr6cppBQ/2FCBSgCCUTcJ

Then I realized there is one part of my app that has been doing file 
uploads via ajax for a long time. I grabbed it from this example appliance 
by Massimo, and never researched the code in depth:

https://github.com/mdipierro/web2py-appliances/tree/master/FileManager


I did some research and found it is using the jQuery.form library, which 
can do file uploads via ajax:


http://malsup.com/jquery/form/#file-upload


I write this in the hope that people trying to do fle uploads via ajax find 
this library, and the example app by Massimo, and it helps them.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


[web2py] Upload multiple files and do background processing

2015-07-28 Thread Phillip
 

I need directions for properly executing the following


 Drop a window for selecting multiple files for upload
 Process the files in the controller (ideally using the scheduler to 
prevent the application from hanging)


Since it appears that the processing must occur after all files are 
imported to use the scheduler, is there a standard way of retrieving the 
id's of the uploaded files?


Please let me know if you need more info


Thanks,


PhillipVW

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


[web2py] upload field

2015-04-25 Thread KevC
Hi!

I want to upload a file type .PDF in upload field but I only aceept this 
type of file.

What can I do?



I hope you can help me.
Best regards.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


[web2py] Upload field default value ?!!

2015-03-04 Thread António Ramos
Hello i have an app that was designed with some required upload fields.

Now after 1 year and around 5gb in my download folder, someone tells me
that the upload fields are not required anymore under some scenarios.

I cannot delete the required value from my dal because the sqlite does not
let it.

So to bypass this problems is there anyway that i can default the upload
field to some trashy value ?

any other thoughts ?

Regards
António

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


[web2py] Upload path broken since 2.9.11 update

2014-11-13 Thread Louis Amon
Hi,

My website has been using web2py for a few months now, and we handle 
pictures using Amazon S3 and Cloudfront for storage and distribution.

The corresponding code in web2py looks like this :

Field('picture_1',
  type='upload',
  requires=IS_EMPTY_OR(IS_IMAGE(extensions=('jpeg', 'png'))),
  uploadfolder='offer/picture_1',
  uploadfs=settings.amazon_fs,
  autodelete=True,
  represent=lambda value, row: cloud_download(value) if value is not 
None else None,
  )


When a picture was uploaded through a form, it was uploaded to our Amazon 
bucket at a path similar to this : 
{bucket_name}/offer/picture_1/offer.picture_1.{timestamp_hash}.{filename_hash}

I recently updated to 2.9.11-stable+timestamp.2014.09.15.23.35.11 but now 
it seems that the uploadfolder does not get prefixed to the path.
i.e. : my uploaded pictures now go to : 
{bucket_name}/offer.picture_1.{timestamp_hash}.{filename_hash}


Was there something in the 2.9.11 patch that modified the behaviour of 
uploads through a filesystem ?

Is there a quick fix for mend these broken paths ?

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


Re: [web2py] Upload path broken since 2.9.11 update

2014-11-13 Thread Louis Amon
Hi Anthony,

I was using 2.9.5 before the upgrade.

In the end, I found that it may be that the part of the code than handles 
uploads through a filesystem never did work with the « uploadfolder » attribute 
(i.e. it might have been a patch I made a few months ago and lost in the 
process of the upgrade).

In any case, here is the solution to my issue if anyone ever meets it :

In dal.py, line 10211:
 os.makedirs(path)
 pathfilename = pjoin(path, newfilename)
 if self.uploadfs:
-dest_file = self.uploadfs.open(newfilename, 'wb')
+dest_file = self.uploadfs.open(pathfilename, 'wb')
 else:
 dest_file = open(pathfilename, 'wb')
 try:


In dal.py, line 10249:
 stream = StringIO.StringIO(data)
 elif self.uploadfs:
 # ## if file is on pyfilesystem
-stream = self.uploadfs.open(name, 'rb')
+fullname = pjoin(file_properties['path'], name)
+stream = self.uploadfs.open(fullname, 'rb')
 else:
 # ## if file is on regular filesystem
 # this is intentially a sting with filename and not a stream


With this, the DAL should be able to both write and retrieve files through a 
filesystem whilst still taking in consideration the prefixed folder (i.e. the « 
uploadfolder » attribute).
That’s very handy if you need to specify multiple upload locations in your 
bucket.

Le 13 nov. 2014 à 15:12, Anthony abasta...@gmail.com a écrit :

 Which version of web2py were you using prior to the upgrade?
 
 On Thursday, November 13, 2014 4:04:19 AM UTC-5, Louis Amon wrote:
 Hi,
 
 My website has been using web2py for a few months now, and we handle pictures 
 using Amazon S3 and Cloudfront for storage and distribution.
 
 The corresponding code in web2py looks like this :
 
 Field('picture_1',
   type='upload',
   requires=IS_EMPTY_OR(IS_IMAGE(extensions=('jpeg', 'png'))),
   uploadfolder='offer/picture_1',
   uploadfs=settings.amazon_fs,
   autodelete=True,
   represent=lambda value, row: cloud_download(value) if value is not None 
 else None,
   )
 
 
 When a picture was uploaded through a form, it was uploaded to our Amazon 
 bucket at a path similar to this : 
 {bucket_name}/offer/picture_1/offer.picture_1.{timestamp_hash}.{filename_hash}
 
 I recently updated to 2.9.11-stable+timestamp.2014.09.15.23.35.11 but now it 
 seems that the uploadfolder does not get prefixed to the path.
 i.e. : my uploaded pictures now go to : 
 {bucket_name}/offer.picture_1.{timestamp_hash}.{filename_hash}
 
 
 Was there something in the 2.9.11 patch that modified the behaviour of 
 uploads through a filesystem ?
 
 Is there a quick fix for mend these broken paths ?
 
 -- 
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list (Report Issues)
 --- 
 You received this message because you are subscribed to a topic in the Google 
 Groups web2py-users group.
 To unsubscribe from this topic, visit 
 https://groups.google.com/d/topic/web2py/f4LoEF9FiiM/unsubscribe.
 To unsubscribe from this group and all its topics, send an email to 
 web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


Re: [web2py] Upload path broken since 2.9.11 update

2014-11-13 Thread Louis Amon
I really don’t have any time to setup my environment for proper testing  git 
contributions.
I still consider myself to be a novice and I’m the only dev in my startup right 
now…

But I do intend to contribute to the framework in a few weeks’ time, when my 
startup will have raised funds :)


Le 13 nov. 2014 à 15:43, Leonel Câmara leonelcam...@gmail.com a écrit :

 Why don't you make a pull request so you don't have to remember this in your 
 next update? 
 
 -- 
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list (Report Issues)
 --- 
 You received this message because you are subscribed to a topic in the Google 
 Groups web2py-users group.
 To unsubscribe from this topic, visit 
 https://groups.google.com/d/topic/web2py/f4LoEF9FiiM/unsubscribe.
 To unsubscribe from this group and all its topics, send an email to 
 web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


[web2py] upload a file with just a post request

2014-11-12 Thread António Ramos
is it possible to just use a post request to upload a file to my web2py app?

I have a situation where i need to receive a file from a cloud service to
my app

Regards
António

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


[web2py] Upload to static folder in other application

2014-10-14 Thread Annet
I web2py/applications I have 3 applications 1 application 'dbmodel' that 
contains the .table files in the databases folder
and static files in the static folder, 1 application 'my' that serves as a 
backend and 1 application 'init' that serves as
a frontend.

As a way to reduce memory usage webfaction recommends a symbolic link to a 
static-only application which serves the 
contents from the static folder of my application 'dbmodel'.

I have the following table definition:

db.define_table('img_logo',
Field('nodeID', 'reference nd_node', ),
Field('imageFilename', length=128, writable=False, readable=False),
Field('image', type='upload', requires=[IS_IMAGE(extensions=('gif', 
'jpg', 'jpeg', 'png'), maxsize=(256, 128), error_message='Afmeting: 
maxWidth is 256 pixels maxHeight is 128 pixels. File format: gif, jpg, 
jpeg, png'), IS_LENGTH(32*1024, error_message='File size overschreidt 32 
KB')], label='Logo * ', autodelete=True),
migrate = False)

In the backend application I have a function which lets the user can upload 
a logo file. In the function I have the following
settings:

folder = 'nodeID' + str(nodeID)
 db.img_logo.image.uploadfolder = os.path.join(request.folder, 'uploads/%s' 
%folder)

To do what Webfaction recommends I wonder whether it is possible to upload 
the logo file to:

/applications/dbmodel/static/uploads/foldername

instead of:

/applications/my/uploads/foldername


Kind regards,

Annet


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


[web2py] Upload field custom manipulation

2014-07-29 Thread Kuba Kozłowicz
I have three tables:

- invoices
- invoice summaries
- invoice bundles

The website I am working on provides such a functionality, that user 
uploads a file, from which invoices and invoice summaries are generated and 
after being generated they are zipped and put into a bundle.

For each upload I create following structure for storing these files:

invoices/
 /bundle_id/list of invoices of bundle bundle_id/
summaries/
 /bundle_id/list of invoices of bundle bundle_id/
bundles/
 /bundle_id/list of invoices of bundle bundle_id/



So I end up having something that looks like this

invoices/
 /1/list of invoices of bundle_1/
/invoice1.pdf
/invoice2.pdf
 /2/list of invoices of bundle_2/
/invoice1.pdf
/invoice2.pdf
 /3/list of invoices of bundle_3/
/invoice1.pdf
/invoice2.pdf
summaries/
 /1/list of summaries of bundle_1/
/summary1.pdf
 /2/list of summaries of bundle_2/
/summary1.pdf
 /3/list of summaries of bundle_3/
/summary1.pdf
bundles/
 /1/bundle_1/
/bundle.zip
 /2/bundle_2/
/bundle.zip
 /3/bundle_3/
/bundle.zip




where inner folder name is ID of recently created bundle.

Now to provide CRUD functionality I am using SMART GRID and I want to be 
able to display the file of invoice, summary, bundle entries ( by 
displaying I mean I want to display file's name and allow downloading it ), 
when a user either chooses VIEW in the SMART GRID or when he looks at the 
list of entries. Since I've chosen my own folder structure for storing 
these invoices, summaries and bundles I can't do it in a simple way, 
because Web2py uses its own mechanism to store and retrieve files and 
changse file's name. So in each of these tables I store the following 
fields:
Field('f_invoice_file_path', type='string')
Field('f_invoice_file', 'upload')



what I wanted to do is something like this:

def on_before_insert_invoice(fields, id):
db(db.t_invoice.id == id).update(
f_invoice_file=fields['f_invoice_file_path']
)
db.t_invoice._before_insert.append(
on_before_insert_invoice
)

, here actually *fields* contains a list of tuples in following format 
(field, value) so I had to iterate over it to find fields[
'f_invoice_file_path'], I just omitted this part for brevity.

, but I get following error and most likely it is not the proper way to do 
that:

*** RuntimeError: Unable to handle upload

Note that the field:

Field('f_invoice_file_path', type='string')

is saved correctly, I just need somehow to make upload field point to that 
location. The next weird thing is that variable *fields* doesn't contain 
field Field('f_invoice_file', 'upload')
, even though I added it to the model, settings.migrate is set to True, and 
server has been restarted.

How can I do it?







-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


[web2py] upload progress recipe not working

2014-07-01 Thread cowbert
I'm trying to do a simple manual file upload (without DAL) and display 
progress bar. I would prefer not to use any ajax helpers.
I'm trying to use the upload progress recipe (involving the cache.ram 
tracking in copystream_progress).

Here's my controller default.py:
def index():
if request.extension=='json' and 'X-Progress-ID' in request.get_vars:
cache_key = 'X-Progress-ID:'+request.get_vars['X-Progress-ID']
length = cache.ram(cache_key+':length', lambda: 0, None)
uploaded = cache.ram(cache_key+':uploaded', lambda: 0, None)
from gluon.serializers import json
return json(dict(length=length, uploaded=uploaded))
else:
form = None
patherror = False
#some checking for a valid target path for later use
if not patherror:
#generate uuid
import binascii
myuuid = binascii.hexlify(os.urandom(24))
form=FORM(INPUT(_name='file', 
_type='file'),INPUT(_type='submit', _value='Upload'))
#will do stuff to file upon form accepts
return dict(form=form, myuuid=myuuid)


views/default/index.html:

script type=text/javascript
//Add upload progress for multipart forms
jQuery(function() {
jQuery('form[enctype=multipart/form-data]').submit(function() {
//only submit once per page load
if (jQuery.data(this,'submitted')) return false;
var freq = 1000; //update every n ms
var uuid = '{{=myuuid}}'; //myuuid was generated by the controller 
above
//console.log(uuid);
var progress_url = '{{=URL(extension=json)}}';
//console.log(progress_url)
//Critical construct X-Progress-ID to request
this.action += ((this.action.indexOf('?') == -1) ? '?' : '') + 
'X-Progress-ID=' + uuid;
var progress = jQuery(
'div id=upload-progress 
class=upload-progress/div').insertAfter(
jQuery('input[type=submit]')).append(
'div class=progress-containerspan 
class=progress-infouploading 0%/spandiv 
class=progress-bar/div/div');
jQuery('input[type=submit]').remove()

progress.find('.progress-bar').height('1em').width(0).css(background-color,red);
//func to update progress bar
function update_progress_info() {
progress.show()
jQuery.getJSON(progress_url, {'X-Progress-ID':uuid, 'dummy': 
'xmlhttprequest fix for IE'}, function(data, status) {
if (data) {
var progress_percent = parseInt(data.uploaded) / 
parseInt(data.length);
var width = 
progress.find('.progress-container').width();
var progress_width = width * progress_percent;
progress.find('.progress-bar').width(progress_width);
progress.find('.progress-info').text('uploading ' + 
progress_percent * 100 + '%');
}
window.setTimeout(update_progress_info, freq);
});
};
window.setTimeout(update_progress_info, freq);
jQuery.data(this, 'submitted', true); //finaly mark form as 
submitted
});
});
/script
{{=form}}

I am getting no javascript errors but i get no progress bar and the 
progress-info span doesn't update either. File uploads.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


[web2py] Upload txt, HTML, etc and display them

2014-06-17 Thread Harish Krishna
I am building this portal where people can upload HTML files. I notice that 
the uploaded files are by default stored in the static folder with a name I 
can't make much sense out of. Now, I want people to view this HTML page on 
their browsers without having them download it. 
What is the simplest way to do this?

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


[web2py] Upload image using RESTful api

2014-05-05 Thread iw3ijq
Hi!

I have a SQLFORM with some filelds and an image (like example here: 
http://web2py.com/books/default/chapter/29/07/forms-and-validators#SQLFORM).

I have to populate the database using a python script. So I made a generic 
restful api:

@request.restful()
def api():
response.view = 'generic.'+request.extension
def GET(*args,**vars):
patterns = [':auto[products]',
'/products/code/{products.code}',
'/products/code/{products.code}/:field',
'/products/image_filename/{products.image_filename}',

'/products/image_filename/{products.image_filename}/:field',
   ]
parser = db.parse_as_rest(patterns,args,vars)
if parser.status == 200:
return dict(content=parser.response)
else:
raise HTTP(parser.status,parser.error)
def POST(table_name,**vars):
return db[table_name].validate_and_insert(**vars)
def PUT(table_name,record_id,**vars):
return db(db[table_name]._id==record_id).validate_and_update(**vars)
def DELETE(table_name,record_id):
return db(db[table_name]._id==record_id).delete()
return dict(GET=GET, POST=POST, PUT=PUT, DELETE=DELETE)

On python script  I use requests.post and genercs fields are ok.
I used sintax from here ( 
http://docs.python-requests.org/en/latest/user/quickstart/#post-a-multipart-encoded-file
 
). /
This upload generally work but I have a big problem:
uploading file from browser I find on DB the encoded name of file, and dhe 
file on filesystem.
Uploading from restful I find on db, instead of encoded file name, this:

'FieldStorage(''image'', ''test_image.jpg'', ''...binary data of image'')'

What's the correct way to upload a file using restful api?

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


[web2py] Upload file to copy.com

2014-02-05 Thread Tiana A. Ralijaona
Hi everyone,

Is there a way for a web2py app, instead of uploading a file to the server 
local file system, to upload a file to a www.copy.com account?

Thanks in advance,

Tiana R.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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.


[web2py] Upload file functionality

2014-01-16 Thread LaDarrius Stewart
I thought I was on the correct path with this can soemone tell me where 
this is going wrong?

db.define_table('consumer',
Field 
http://127.0.0.1:8000/examples/global/vars/Field('lname','string', 
requires=IS_NOT_EMPTY 
http://127.0.0.1:8000/examples/global/vars/IS_NOT_EMPTY()),
Field 
http://127.0.0.1:8000/examples/global/vars/Field('fname','string', 
requires=IS_NOT_EMPTY 
http://127.0.0.1:8000/examples/global/vars/IS_NOT_EMPTY()),
Field 
http://127.0.0.1:8000/examples/global/vars/Field('address','string'),
Field 
http://127.0.0.1:8000/examples/global/vars/Field('city','string'),
Field 
http://127.0.0.1:8000/examples/global/vars/Field('stayte','string'),
Field 
http://127.0.0.1:8000/examples/global/vars/Field('zip','string'),
Field 
http://127.0.0.1:8000/examples/global/vars/Field('h_phone','string'),
Field 
http://127.0.0.1:8000/examples/global/vars/Field('c_phone','string'),
Field 
http://127.0.0.1:8000/examples/global/vars/Field('adm_date','date'),
Field 
http://127.0.0.1:8000/examples/global/vars/Field('dob','date'),
Field 
http://127.0.0.1:8000/examples/global/vars/Field('pod','string'),
auth.signature, #creates fields: created_on, created_by, 
modified_on, modified by, is_active
format= lambda r: r.fname + ' ' + r.lname  #substitutes 
consumer.id for consumer name
)
db.define_table('files',
Field 
http://127.0.0.1:8000/examples/global/vars/Field('name', unique=True, 
length=255),
Field 
http://127.0.0.1:8000/examples/global/vars/Field('phile', 'upload', 
custom_store=lambda file, filename, path: store_file(file, filename, path), 
custom_retrieve=lambda filename, path: retrieve_file(filename, path) ),
Field 
http://127.0.0.1:8000/examples/global/vars/Field('consumerid', 'reference 
consumer'),
auth.signature)

def store_file(file, filename=None, path=None):
path = applications/facesheet/uploads
if not os.path.exists(path):
 os.makedirs(path)
pathfilename = os.path.join(path, filename)
dest_file = open(pathfilename, 'wb')
try:
shutil.copyfileobj(file, dest_file)
finally:
dest_file.close()
return filename
def retrieve_file(filename, path=None):
path = applications/facesheet/uploads
return (filename, open(os.path.join(path, filename), 'rb'))

def upload():
var = request http://127.0.0.1:8000/examples/global/vars/request.args(0)
var1 = request http://127.0.0.1:8000/examples/global/vars/request.args(1)
var2 = request http://127.0.0.1:8000/examples/global/vars/request.args(2)
form=SQLFORM http://127.0.0.1:8000/examples/global/vars/SQLFORM(db.files, 
upload=URL http://127.0.0.1:8000/examples/global/vars/URL(download))
form.vars.consumerid = var
if form.process().accepted:
response http://127.0.0.1:8000/examples/global/vars/response.flash = 
files updated
query=(db.files.consumerid==var)
form2=SQLFORM 
http://127.0.0.1:8000/examples/global/vars/SQLFORM.grid(query, args=[var, 
var1, var2], paginate=1, details=False, searchable=False, editable=False, 
csv=False, create=False, deletable=False, user_signature=False)
return locals()

def download():
if not request http://127.0.0.1:8000/examples/global/vars/request.args:
raise HTTP http://127.0.0.1:8000/examples/global/vars/HTTP(404)
name = request http://127.0.0.1:8000/examples/global/vars/request.args[-1]
field = db[files][phile]
try:
(filename, file) = field.retrieve(name)
except IOError:
raise HTTP http://127.0.0.1:8000/examples/global/vars/HTTP(404)
#response.headers[Content-Type] = c.contenttype(name)
response 
http://127.0.0.1:8000/examples/global/vars/response.headers[Content-Disposition]
 = attachment; filename=%s % name
stream = response 
http://127.0.0.1:8000/examples/global/vars/response.stream(file, 
chunk_size=64*1024, request 
http://127.0.0.1:8000/examples/global/vars/request=request 
http://127.0.0.1:8000/examples/global/vars/request)
raise HTTP http://127.0.0.1:8000/examples/global/vars/HTTP(200, stream, 
**response http://127.0.0.1:8000/examples/global/vars/response.headers)

*The upload functionality is working fine stores the relative information in 
the database*

*and saves the file on the server which i wanted the problem is when someone 
clicks on the file *

*from the form2 within the upload method. The link is 
**http://127.0.0.1:8000/facesheet/default/upload/1/John/Smith/download/test3.docx.*

*This brings back a 404 tried so many different examples on the web the few 
that are out there atleast*

*but I keep running into a brick wall. Thank You in advance.*

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- 

[web2py] upload e CASCADE delete

2014-01-15 Thread maurizio
Hi all,
probably due to my incompetence I have the following problem,
Thank's in advance anyone who wants to help me.

consider the following code:

'''
db.define_table('prodotto',
Field('nome'),
format='%(nome)s',
plural='prodotti')

db.define_table('allegato',
Field('descrizione',requires=IS_NOT_EMPTY()),
Field('documento','upload',autodelete=True),
Field('prodotto','reference 
prodotto',writable=False,readable=False),
format='%(descrizione)s',
plural='allegati')

def index():
grid = SQLFORM.smartgrid(db.prodotto,
deletable=True,
editable=True,
create=True,
csv=False)
return dict(grid=grid)

web2py 2.7.4-stable+timestamp.2013.10.14.15.16.29
(Running on Rocket 1.2.6, Python 2.7.3) Debian  7.2 (wheezy)
'''

Deleting a record from the allegato table, also delete the corresponding 
file (autodelete=True) in the default /uploads folder.
Deleting a record from the prodotto master table, also delete all records 
in the allegato detail table (CASCADE delete), but files in the folder 
uploads are not erased.

Any idea?

thanks again
Maurizio

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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.


[web2py] Upload form

2013-11-02 Thread Martin Weissenboeck
A question about the upload form (Version 2.7.4):

A form like

 form = SQLFORM.factory(Field('file', 'upload', uploadfield=False))

shows something like



But in the admin application the widget for an upload filename looks like



Nice - but how to get it?

Regards, Martin

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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.


[web2py] Upload fields custom_store

2013-10-20 Thread Alan Etkin
Supposing one has a controller like this:


def mycustomstore(f, n, p):
print file length, len(f.read())
print file name, n
print path, p

def index():
form = SQLFORM.factory(Field(myupload, upload, 
custom_store=mycustomstore))
if form.process().accepted:
pass
return dict(form=form)


Running in a welcome app and a linux machine with the rocket builtin server 
(web2py Version 2.7.4-stable+timestamp.2013.10.19.17.40.27)

When one submits the form specifying a file, the form passes validation and 
it is possible to store the file output elswhere or, for example use it as 
custom field input for a custom db interface (which is the way I'd use such 
code). Now, it seems that with this configuration, the upload feature does 
not keep a copy of the file in the filesystem (not within the application 
path afaik).

Is this the correct way of submitting file data without file storage with 
web2py? I belive this feature is not documented. Would this also work on an 
environment without write access to the file system (for example appengine)?

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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.


[web2py] Upload file using POST

2013-09-18 Thread Andreas Wienes
Hello,

I want to upload a file by posting it from another script calling something 
like http://mydomain.com/default/acceptfile?filename=test.txt
What is the easiest way doing this?

Thanks a lot for your help!
Andreas

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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.


[web2py] upload and a process file using SQLFORM.grid

2013-09-11 Thread P T
Hello All,

Just started to learn web2py and here is an idea that I am trying to 
implement. Users creates scenarios, which includes an uploaded file. 
After the new scenario is created, the uploaded file should be processed 
and computed values written to results table. 
So far, I am successful in creating the scenarios and uploading the files. 
But, I am not sure where I would write the controller 
form.process().accepted. 
By the way, I am using SQLFORM.grid and here is complete code. Any help 
and/or pointers is highly appreciated.

-
db.py
from gluon.tools import *

db=DAL(sqlite://storage.sqlite)
auth = Auth(db)
auth.define_tables(username=True)
crud = Crud(db)

db.define_table(scenario, 
Field('title'),
Field('body', 'text'),
Field('created_on', 'datetime', default=request.now),
Field('created_by', 'reference auth_user', default=db.auth_user.id),
Field('file', 'upload'),
Field('file_status', default='file uploaded'))

db.scenario.created_by.requires=IS_IN_DB(db, db.auth_user.id)
db.scenario.title.requires = IS_NOT_EMPTY()
db.scenario.created_on.readable = False
db.scenario.created_by.readable = False

db.define_table(results,
Field('scenario_id', 'reference scenario'),
Field('amps', 'double'),
Field('volts', 'double')) 
default.py
@auth.requires_login()
def index():
   query = (db.scenario.created_by == auth.user.id)
   grid = SQLFORM.grid(query, selectable=lambda ids: [])
   return dict(grid=grid)
   
default/index.html
{{extend 'layout.html'}}
{{if auth.user.id:}}
h2Your Current Scenarios/h2
{{=grid}}
{{pass}}
--

I tested the following code and see that the form accepted is flashed. 
But, how do I link this form to the Add button in the SQLFORM.grid 
def scenario():
form = SQLFORM(db.scenario)
if form.process().accepted:
response.flash = form accepted
##get the uploaded file, process and write results
return dict(form=form)


Thanks,
PT

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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.


[web2py] Upload a file without a form

2013-08-06 Thread Eduardo Cruz
I need to upload a file that I will create on the fly, is there a way to do 
that without using a form?

-- 

--- 
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.




Re: [web2py] Upload a file without a form

2013-08-06 Thread Marin Pranjić
Hello Eduardo,

You can use db.table.insert(...) or db.table.field.store(...).

Details:

http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#More-on-uploads


Marin




On Tue, Aug 6, 2013 at 5:01 PM, Eduardo Cruz educr...@gmail.com wrote:

 I need to upload a file that I will create on the fly, is there a way to
 do that without using a form?

 --

 ---
 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.




-- 

--- 
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.




Re: [web2py] Upload image and make a thumbnail question.

2013-08-05 Thread Richard Vézina
Consider using this slice instead :

http://www.web2pyslices.com/slice/show/1666/improved-smarthumb

I can help you trouble shoot and integrate in your app...

I am the one who refactor smartthumb and set a threshold to make sure it
generate proper resized with good quality thumbnails...

:)

Richard


On Sun, Aug 4, 2013 at 7:13 PM, Michael Gheith gheit...@aol.com wrote:

 Hello web2py community!

 I used to be able to use the following web2py slice successfully in the
 past (about a year ago):

 http://www.web2pyslices.com/slice/show/1387/upload-image-and-make-a-thumbnail

 Now it's not working with the latest build of web2py.  Is anyone able to
 successfully get this slice working with the latest web2py build?

 The code is successfully creating the thumbnail and storing it in the
 uploads folder.  I can physically see it on the file system.  But I get a
 ticket whenever I try to access the thumbnail through the DB admin or
 through the URL bar:
 type 'exceptions.TypeError' Can't retrieve
 uploads.thumb.16e0d9fd-bc66-4b36-9c75-03aaea1d8603.PNG

 I don't think there is anything wrong with what I am doing.  I think the
 problem resides in the slice and web2py breaking backward compatibility...
  Please provide guidance, thanks!

 --

 ---
 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.




-- 

--- 
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.




[web2py] Upload image and make a thumbnail question.

2013-08-04 Thread Michael Gheith
Hello web2py community!

I used to be able to use the following web2py slice successfully in the 
past (about a year ago):
http://www.web2pyslices.com/slice/show/1387/upload-image-and-make-a-thumbnail

Now it's not working with the latest build of web2py.  Is anyone able to 
successfully get this slice working with the latest web2py build?

The code is successfully creating the thumbnail and storing it in the 
uploads folder.  I can physically see it on the file system.  But I get a 
ticket whenever I try to access the thumbnail through the DB admin or 
through the URL bar:
type 'exceptions.TypeError' Can't retrieve 
uploads.thumb.16e0d9fd-bc66-4b36-9c75-03aaea1d8603.PNG

I don't think there is anything wrong with what I am doing.  I think the 
problem resides in the slice and web2py breaking backward compatibility... 
 Please provide guidance, thanks!

-- 

--- 
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.




[web2py] Upload field and SQLFORM.grid problem / bug?

2013-05-22 Thread David Marko
I have a table with upload field defined as follows: Field('file', 
'upload', uploadseparate=True) . When I create some items using database 
administration, the image is displayed correctly. When I involve 
SQLFORM.grid in my controller, the link to file is not correct. See two 
links below:

OK - this URL is produced by database administration interface
http://localhost:8000/periodicke_cinnosti/appadmin/download/db/item.file.8f5a1d4f8f222113.6e61747572616c6c5f30332e706e67.png

BAD - this URL is produced by SQLFORM.grid
http://localhost:8000/periodicke_cinnosti/default/form/download/item.file.8f5a1d4f8f222113.6e61747572616c6c5f30332e706e67.png

The difference is  'db' just after '/download/' in path. I'm running latest 
web2py trunk version.

-- 

--- 
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.




[web2py] Upload a file to a specified folder and not a database

2013-03-20 Thread Costain Nachuma
Greetings,

Is it possible to upload a file to a folder using web2py without having to 
store in a database?if yes how can i do this 

-- 

--- 
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.




[web2py] Upload field with clear text filename

2012-12-28 Thread Joe Barnhart
I'm not sure why this is difficult, but I see many posts about this when I 
search, yet none exactly work for me.  This seems like it should be easy 
but is surprisingly difficult in web2py.

I want to keep a table of uploaded files with the uploads in a blob field 
and the names in clear text in a filename field.  Like this model:

db.define_table(fileobject,
Field(filename,string,length=50,readable=False,writable=False),
Field(upload,upload,uploadfield=object_data),
Field(object_type,string,length=20,readable=False,writable=False),
Field(object_data,blob),
Field(owner,reference auth_user,default=auth.user_id,readable=False,
writable=False),
Field(saved,datetime,default=datetime.now(),readable=False,writable=
False),
Field(state,string,length=16,readable=False,writable=False),
migrate=settings.migrate)

Reading the relevant posts and the online book lead me to believe the way 
is with a controller like this one:

def index():
form=SQLFORM(db.fileobject)
if request.vars.upload:
form.vars.filename = request.vars.upload.filename
if form.process().accepted:
response.flash = 'form accepted'
elif form.errors:
response.flash = 'form has errors'
return dict(form=form)

And yet this controller does not work.  The blob is filled in but the 
filename is ignored and shows in the table as None.  In fact, form.vars 
is an empty collection and placing form.vars.filename in it does not 
produce an error, but it is ignored by the form processing.  In addition to 
the filename, I'd like to add the information about the object type etc. at 
the same point in the process, i.e. after the file has been chosen but 
before it has been loaded into the database.

I've been trying to scan through the code (I'm using 2.3.2 source) to 
answer my own questions about the upload field but it's just taking too 
much time.  The upload field is one of those parts of web2py that you 
either love or... uh... don't.  To me it seems designed for a very specific 
use model.  If my use model deviates too much then using upload is like 
pounding square pegs into round holes.  I'm tired of pounding.  Someone 
show me how to whittle off the corners of my square peg!

(You would think this would be an easy task, yet from the number of posts 
on this exact topic I know I'm in the company of a large number of others.)


-- 





[web2py] upload field without the upload

2012-12-25 Thread lucas
hello one and all,

i am doing en masse data table using xml data to a table that has an upload 
field.  the files are already present in the upload subdirectory but i need 
to populate the table with the data, including the file name that is the 
upload field.  i hope that made sense.

how do i populate the fields using a db.table_name.insert(*...***) without 
web2py wanting to actually upload the file?

thanx in advance, lucas

-- 





Re: [web2py] upload field without the upload

2012-12-25 Thread Bruno Cezar Rocha

AFAIK upload fields are just string fields, so you can insert any string there!

db.table.insert(filefield=blah)

should work!

You just have to use Python glob, os, sh or shutil to take a list of files and 
then populate the database.

On Tue, Dec 25, 2012 at 03:40:51PM -0800, lucas wrote:

hello one and all,

i am doing en masse data table using xml data to a table that has an upload
field.  the files are already present in the upload subdirectory but i need
to populate the table with the data, including the file name that is the
upload field.  i hope that made sense.

how do i populate the fields using a db.table_name.insert(*...***) without
web2py wanting to actually upload the file?

thanx in advance, lucas

--





--





Re: [web2py] upload field without the upload

2012-12-25 Thread Massimo Di Pierro
You can do it and it will work. But you will not be able to download it 
using the download action. That is because it expects a certain format 
for filenames. You will need a custom download action that would know how 
to located the file from its name.

Massimo

On Tuesday, 25 December 2012 18:56:07 UTC-6, rochacbruno wrote:

 AFAIK upload fields are just string fields, so you can insert any string 
 there! 

 db.table.insert(filefield=blah) 

 should work! 

 You just have to use Python glob, os, sh or shutil to take a list of files 
 and then populate the database. 

 On Tue, Dec 25, 2012 at 03:40:51PM -0800, lucas wrote: 
 hello one and all, 
  
 i am doing en masse data table using xml data to a table that has an 
 upload 
 field.  the files are already present in the upload subdirectory but i 
 need 
 to populate the table with the data, including the file name that is the 
 upload field.  i hope that made sense. 
  
 how do i populate the fields using a db.table_name.insert(*...***) 
 without 
 web2py wanting to actually upload the file? 
  
 thanx in advance, lucas 
  
 -- 
  
  
  


-- 





Re: [web2py] upload field without the upload

2012-12-25 Thread lucas
well, i get this error

Traceback (most recent call last):
  File /opt/web-apps/web2py/gluon/restricted.py, line 212, in restricted
exec ccode in environment
  File /opt/web-apps/web2py/applications/iquanta/controllers/site.py 
https://192.168.0.8/admin/default/edit/iquanta/controllers/site.py, line 489, 
in module
  File /opt/web-apps/web2py/gluon/globals.py, line 193, in lambda
self._caller = lambda f: f()
  File /opt/web-apps/web2py/applications/iquanta/controllers/site.py 
https://192.168.0.8/admin/default/edit/iquanta/controllers/site.py, line 484, 
in site_xml_files_import
id = tFls.insert(input_date=inputDate, modified_date=modDate, 
permission=permission, name=fname, ext=fext, type=ftype, description=fdsc, 
file=ffile)
  File /opt/web-apps/web2py/gluon/dal.py, line 7916, in insert
self._attempt_upload(fields)
  File /opt/web-apps/web2py/gluon/dal.py, line 7909, in _attempt_upload
raise RuntimeError(Unable to handle upload)
RuntimeError: Unable to handle upload

where line 484 in site.py is

id = db.files.insert(input_date=inputDate, modified_date=modDate, 
permission=permission, name=fname, ext=fext, type=ftype, description=fdsc, 
file=ffile)

where file is the upload field and i am passing it a string, most of which look 
something like

files.file.8710083b15af8a66.5044505f4c756b6163735f4e6f6973652d52656a656374696f6e5f525349312e706466.pdf

so what am i doing wrong?  lucas




-- 





Re: [web2py] upload field without the upload

2012-12-25 Thread lucas
ok, what if i just upload the file?  how do i do that programmically?  lucas

-- 





Re: [web2py] upload field without the upload

2012-12-25 Thread Massimo Di Pierro
https://groups.google.com/forum/?fromgroups=#!searchin/web2py/upload/web2py/CWNwcgo3wIU/1K_7wJBPh-0J

On Tuesday, 25 December 2012 20:51:21 UTC-6, lucas wrote:

 ok, what if i just upload the file?  how do i do that programmically?  
 lucas


-- 





[web2py] upload from Edit page

2012-12-18 Thread ArNew
Hi Everyone,

I need help urgently.

In my application, I am have included upload fields in Create and edit 
page. Through create page, it was very straight forward with:
td{{=form.custom.widget.attachment}}/td (View)
Field('attachment','upload',uploadfolder=os.path.join(request.folder, 
'attachments')) (DAL). 
if form.vars.attachment:
form.vars.attachment_name = request.vars.attachment.filename
id = 
thisdb.service_attachments.insert(**thisdb.service_attachments._filter_fields(form.vars))
 
.(Controller) And this works great.

That with Edit page is not the same, as it is not about editing the current 
image, but uploading more attachments. So I tried doing something like this:

input class=upload id=service_attachments_attachment name=attachment 
type=file / (view)
if request.vars.attachment != '':
form.vars.attachment = request.vars.attachment.file
filename = request.vars.attachment.filename
form.vars.attachment_name = filename
id = 
thisdb.service_attachments.insert(**thisdb.service_attachments._filter_fields(form.vars))
This follows the very similar procedure of saving the encrypted version of 
attachment name in the attachment field, but it changes the extension to 
.txt for all the attachments. It saves the attachment as 
service_attachments.attachment.b19d4ef38978e8e6.746d707437756c626f.txt 
where as the orginal attachment is photo.JPG. So ideall it should save it 
as  service_attachments.attachment.b19d4ef38978e8e6.746d707437756c626f.JPG. 

Can anyone please help me with this?





-- 





[web2py] Upload file from bash script

2012-12-15 Thread Alfonso Pastor Sierra
Hi, 

I want upload a file to a upload field in a table automatically, sending 
the file from a bash script using wget. How can I do it?.

Thanks

-- 





[web2py] Upload form, onvalidation and postbacks

2012-12-14 Thread Andy Salnikov
Hi, 

I have an issue with the upload form and postbacks. In my application I 
need to validate file contents before accepting it from user upload form, 
so naturally I try to use onvalidation method to it. The table used in 
the forma is defined like this:

db.define_table('input_data',
Field('input_file', 'upload', autodelete=True, 
requires=IS_NOT_EMPTY(), label=T('Input file')),
Field('output_type', default=xxx, 
requires=IS_IN_SET(['xxx', 'yyy']), label=T('Output format')),
Field('original_name', writable=False, readable=False),
Field('created', 'datetime', writable=False, 
readable=False),
)

My simplified action looks like this:

def _validateFileForm(form):
try:
validator.validate(form.vars.input_file.file)
# on success set hidden fields
form.vars.original_name = request.vars.input_file.filename
form.vars.created = datetime.datetime.now()
except Exception, ex:
# if validation fails then display an error
form.errors.input_file = T('file_validation_failed') + ': ' + 
str(ex)

def index():

form = SQLFORM(db.input_data, submit_button=T(Upload))
if form.process(onvalidation=_validateFileForm).accepted:
# save file id in a session and go to options page
session.input_data_id = form.vars.id
redirect(URL(options_odt))

return dict(form=form)

Validation seems to work OK, if file is OK then everything is redirected to 
next page, if file is bad then message is displayed in red under file 
upload field. 

What is interesting about it is that when validation fails and form is 
re-displayed it also looks like that the whole file contents is send back 
to the client together with the form. For large uploaded file this could be 
a lot of data. I see long delays and when I check the HTTP response headers 
I see many-megabytes number there. Is there a way to avoid sending the file 
contents back with the form during a postback?

Thanks,
Andy

-- 





[web2py] Upload directly to the server: error

2012-11-30 Thread Paulo
Hi!

I'm trying to create a very simple upload field, without any complex 
mechanism. A user just uploads a file to a folder in the server (apache), 
without web2py changing the file name, and without any db. I have some 
dozens of files already in a folder in the server, I just need an upload 
form to send new files easly, without having to go personally with an Usb 
Pen to the server to copy new files.

But I'm having an hard time doing it, and dont know why. With small files 
(2mb docx file) it works perfectly. But when uploading a 300mbs wav file it 
gives an error ticket:
type 'exceptions.MemoryError'
TRACEBACK

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.

Traceback (most recent call last):
  File D:\web2py\gluon\restricted.py, line 212, in restricted
exec ccode in environment
  File D:/web2py/applications/Upload_Fala_Bracarense/controllers/default.py 
https://cehum.ilch.uminho.pt/admin/default/edit/Upload_Fala_Bracarense/controllers/default.py,
 line 121, in module
  File D:\web2py\gluon\globals.py, line 188, in lambda
self._caller = lambda f: f()
  File D:/web2py/applications/Upload_Fala_Bracarense/controllers/default.py 
https://cehum.ilch.uminho.pt/admin/default/edit/Upload_Fala_Bracarense/controllers/default.py,
 line 28, in index
form = SQLFORM.factory(Field('myfile', 'upload', 
uploadfolder='/static')).process()
  File D:\web2py\gluon\html.py, line 2170, in process
self.validate(**kwargs)
  File D:\web2py\gluon\html.py, line 2109, in validate
if self.accepts(**kwargs):
  File D:\web2py\gluon\sqlhtml.py, line 1281, in accepts
**kwargs
  File D:\web2py\gluon\html.py, line 2022, in accepts
self._traverse(False, hideerror)
  File D:\web2py\gluon\html.py, line 842, in _traverse
newstatus = c._traverse(status, hideerror) and newstatus
  File D:\web2py\gluon\html.py, line 842, in _traverse
newstatus = c._traverse(status, hideerror) and newstatus
  File D:\web2py\gluon\html.py, line 842, in _traverse
newstatus = c._traverse(status, hideerror) and newstatus
  File D:\web2py\gluon\html.py, line 842, in _traverse
newstatus = c._traverse(status, hideerror) and newstatus
  File D:\web2py\gluon\html.py, line 853, in _traverse
self._postprocessing()
  File D:\web2py\gluon\html.py, line 1762, in _postprocessing
_value = str(self['_value'])
  File C:\Python27\Lib\cgi.py, line 515, in __repr__
self.name, self.filename, self.value)
MemoryError

IN FILE: 
D:\WEB2PY\APPLICATIONS\UPLOAD_FALA_BRACARENSE\CONTROLLERS/DEFAULT.PY
I have tried a lot of diferent ways. I have read everything I could find in 
the web. I found a topic with the same problem but no solution I could use. 
Anyone can help with some tips?

This the code in the controller:

import os

def index():
form = FORM(INPUT(_type='file',_name='myfile'),INPUT(_type='submit'))
if form.accepts(request.vars,session):

open(os.path.join(request.folder,'uploads','filename.wav'),'wb').write(form.vars.myfile.file.read())
return dict(form=form)

I have tried a lot of different ways, this only an example. I used 
SQLFORM.factory {form = SQLFORM.factory(Field('myfile', 'upload', 
uploadfolder='/static')).process()}, shutil 
{shutil.copyfileobj(request.vars.myfile.file,open(os.path.join(request.folder,'static','filename.txt'),'wb'))},
 
and a lot of different code variants but none worked. Its allways the same: 
with small files it works, with a 200mb file it gives an error.


Anyone can help me understand this problem? The max file size I need to 
upload is 500mb. It will be used by only one person, with a login, so there 
is no need to a complex mechanism, and files need to mantain the same name. 
I just need the upload to work. 

Thanks and sorry for my bad english.




I want a user to be able to upload a file to a directory in the server 
(apache), without changing the file name, and wihout databases. A simple 
and direct upload, so a friend of mine can store some files in

-- 





[web2py] Upload fields does not use Bootstrap

2012-11-24 Thread Joe Barnhart
I was just playing with automatically-generated form with an upload field 
and noticed that the button created with that field does not use the btn 
class to invoke the styling of the Bootstrap layer.  Was this deliberate or 
an accident?  Is it easily fixed by a novice CSS/JS programmer?

-- 





[web2py] Upload from git repro - GitCommandError

2012-08-25 Thread Martin Weissenboeck
I have found, that the url to upload a packed application can be a git
repo and I tried it with
https://github.com/niphlod/w2p_scheduler_tests.git

The result:
type 'exceptions.NameError' global name 'GitCommandError' is not defined

Regards, Martin

-- 





[web2py] Upload error field *_newfilename does not belong to the table

2012-08-07 Thread Paolo
Hi all, 
I've just checked out the last trunk, I got the following error:

2012-08-07 19:26:01,063 - web2py - ERROR - Traceback (most recent call 
last):
  File /home/paolo/Desktop/git/web2py/gluon/restricted.py, line 205, in 
restricted
exec ccode in environment
  File 
/home/paolo/Dropbox/git/web2py/applications/bikend/controllers/club.py, 
line 125, in module
  File /home/paolo/Desktop/git/web2py/gluon/globals.py, line 182, in 
lambda
self._caller = lambda f: f()
  File /home/paolo/Desktop/git/web2py/gluon/tools.py, line 2722, in f
return call_or_redirect(
  File 
/home/paolo/Dropbox/git/web2py/applications/bikend/controllers/club.py, 
line 37, in item
m = modal()
  File /home/paolo/Desktop/git/web2py/gluon/tools.py, line 2722, in f
return call_or_redirect(
  File 
/home/paolo/Dropbox/git/web2py/applications/bikend/controllers/club.py, 
line 57, in modal
d['form'] = club_form()
  File 
/home/paolo/Dropbox/git/web2py/applications/bikend/controllers/club.py, 
line 104, in club_form
form.vars.id = db.club.insert(**dict(form.vars))
  File /home/paolo/Desktop/git/web2py/gluon/dal.py, line 7514, in insert
  File /home/paolo/Desktop/git/web2py/gluon/dal.py, line 7475, in _listify
if name != 'id':
SyntaxError: Field picture_newfilename does not belong to the table

The tables involved are defined as follows:

pictures_fields = db.Table(db, 'picture',
Field('picture_desc', 'text', requires=[IS_TRIM(), 
IS_LENGTH(140,error_message=T('Warning, description too long'))]),
Field(picture, upload, autodelete=True, requires=[IS_NOT_EMPTY(), 
IS_IMAGE(), 
IS_UPLOAD_FILENAME(extension='jpg|jpeg|png'),IS_IMAGE(extensions=('jpeg', 
'png'))]),
Field(normal, upload, autodelete=True, requires=[IS_IMAGE()]),
Field(thumbnail, upload, autodelete=True, requires=[IS_IMAGE()]),
)
pictures_fields.thumbnail.compute = lambda row: THUMBER(row.picture, 200, 
200, name='thumb') 
pictures_fields.normal.compute = lambda row: THUMBER(row.picture, 600, 600, 
name='normal') 
pictures_fields.picture_desc.label = T('Picture description')


db.define_table('club',
Field('title', 'string', requires=[IS_TRIM(), 
IS_LENGTH(150,error_message=T('Warning, title too long'))]),
Field('description', 'text', 
requires=[IS_NOT_EMPTY(error_message=T('Please, enter a description')),
   
IS_LENGTH(250,error_message=T('Warning, description too long')), 
   IS_LENGTH(minsize=75, 
error_message=T('Warning, the description is too short, reviews must be at 
least 75 characters long.')),
   IS_TRIM()]),
Field(type, requires=IS_IN_SET(['cerco', 'offro']), default='offro'),
Field(location, 'string'),
pictures_fields,
auth.signature
)
db.club.picture.requires = IS_EMPTY_OR(db.club.picture.requires)
db.club.picture_desc.readable = False
db.club.picture_desc.writable = False
db.club._common_filter = lambda query: (db.club.is_active==True)

What could be the problem?

Regards,
paolo

-- 





[web2py] Upload file using the LOAD (....., ajax = True)

2012-08-06 Thread Picheth
I have a problem with the upload file using the LOAD (., ajax = True)


please .. any help, cues or snippets of codes to accomplish this ... will 
be greatly appreciated

Picheth.

-- 





[web2py] Upload file into DB without SQLFORM

2012-07-09 Thread Athelionas
What is the proper way of uploading a file without SQLFORM into the 
following database table?

db.define_table('files',
Field('original_filename', 'string'),
Field('file', 'upload', uploadfield='file_data'),
Field('file_data', 'blob'))

A simple insert won't help here so I'm sure there's some kind of trick to 
it which I'm unable to figure out on my own.

Any help is highly appreciated!


[web2py] Upload the more than 100 MB file

2012-06-15 Thread Sanjeet Roy
Can i upload the more than 100 mb file using web2py when i tried got the 
error:-


Traceback (most recent call last):
  File /home/tls-sanjeet/Desktop/web2py/gluon/restricted.py, line 205, in 
restricted
exec ccode in environment
  File 
/home/tls-sanjeet/Desktop/web2py/applications/upload_test/views/appadmin.html 
http://127.0.0.1:8000/admin/default/edit/upload_test/views/appadmin.html, 
line 56, in module
{{if rows:}}
  File /home/tls-sanjeet/Desktop/web2py/gluon/globals.py, line 182, in write
self.body.write(xmlescape(data))
  File /home/tls-sanjeet/Desktop/web2py/gluon/html.py, line 114, in xmlescape
return data.xml()
  File /home/tls-sanjeet/Desktop/web2py/gluon/html.py, line 848, in xml
(fa, co) = self._xml()
  File /home/tls-sanjeet/Desktop/web2py/gluon/html.py, line 839, in _xml
self.components])
MemoryError




[web2py] Upload filename - extension maintains original case

2012-06-14 Thread villas
If I upload a file,  it is renamed as follows:

.jpg   --   new.name.abcdefgh.jpg
.JPG   --   new.name.xyzdefgh.JPG

Note that despite the renaming,  the extension maintains its original case.

I do not like this because I want all my files to be saved in lowercase.

For me it is unexpected behaviour and maybe we can change this??
If we cannot change web2py,  then how can I make sure all my file 
extensions are lowercase?

Thanks, David


[web2py] upload - exceptions.MemoryError

2012-06-12 Thread Janath
Hi,

I am trying to upload a file using follwing code segment (database table is 
shown below).

I tried a file ~25MB. It generates a exceptions.MemoryError and there is no 
record insert to the table. 

Tried and was successful with a 2 MB file. I think I will have to upload 
max ~30MB.

Error description is shown below.

Support appreciated!
Janath


*this routine uploads file:*

def new_network_data():
form = SQLFORM(db.network_data)
if form.process().accepted:
response.flash = 'new record inserted'
download = URL('download')  # to see the picture
records = SQLTABLE(db().select(db.network_data.ALL), upload=download,
   headers='fieldname:capitalize')
return dict(form=form, records=records)

*network_data table:*

db.define_table(
'network_data',
Field('sav_file', 'upload', default=''),
Field('description', 'text', default='network data will be selected 
based on the description'),
format = '%(name)s')
db.network_data.sav_file.requires=IS_UPLOAD_FILENAME(extension='sav')


--

TICKET ID

127.0.0.1.2012-06-12.15-34-51.d5191840-7166-40fe-9cd8-5508007b894e
type 'exceptions.MemoryError'VERSIONweb2py™(1, 99, 7, 
datetime.datetime(2012, 3, 4, 22, 12, 8), 'stable')PythonPython 2.5.1: 
C:\Python25\pythonw.exeTRACEBACK

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.

Traceback (most recent call last):
  File C:\Users\umgeegan\Desktop\web2py_src\web2py\gluon\restricted.py, line 
205, in restricted
exec ccode in environment
  File 
C:\Users\umgeegan\web2py_src\web2py\applications\PythonPSSE\views\default/new_network_data.html,
 line 56, in module
  File C:\Users\umgeegan\web2py_src\web2py\gluon\tools.py, line 1189, in 
navbar
next = '?_next='+urllib.quote(URL(args=request.args,vars=request.vars))
  File C:\Python25\lib\urllib.py, line 1205, in quote
res = map(safe_map.__getitem__, s)
MemoryError

ERROR SNAPSHOT [image: help]

type 'exceptions.MemoryError'()


[web2py] Web2py upload behind apache mod proxy

2012-02-16 Thread Álvaro J . Iradier
Hi,

I have a testing web2py environment running on a system on port 8000,
and then apache2 using mod_proxy to redirect requests to a virtual
host on port 80 to the web2py rocket server. This is the apache config
for the vhost:

---

VirtualHost *:80
 ...

  Proxy *
Order deny,allow
Allow from all
  /Proxy

  ProxyPass / http://127.0.0.1:8000/
  ProxyPassReverse / http://127.0.0.1:8000/

/VirtualHost

---

When I upload a file to a form, I get this error from the Framework:

Traceback (most recent call last):
  File /var/www/web2py_klnetcenter/gluon/main.py, line 447, in
wsgibase
parse_get_post_vars(request, environ)
  File /var/www/web2py_klnetcenter/gluon/main.py, line 275, in
parse_get_post_vars
request.body = copystream_progress(request) ### stores request
body
  File /var/www/web2py_klnetcenter/gluon/main.py, line 143, in
copystream_progress
copystream(source, dest, size, chunk_size)
  File /var/www/web2py_klnetcenter/gluon/fileutils.py, line 376, in
copystream
data = src.read(chunk_size)
  File /usr/lib/python2.6/socket.py, line 353, in read
data = self._sock.recv(left)
timeout: timed out

It seems to be happening even before my controler is run, just when
receiving the post variables. ¿Any idea what might be wrong?

Thanks very much.


[web2py] upload field value reset on form failure of another field

2011-12-05 Thread thodoris
Is there any way to keep the value that was inserted on an upload
field after failing to validate the form due to another field, so that
the user doesn't have to search for the file again?


[web2py] Upload in GAE, SQLFORM.factory, multiple tables

2011-11-19 Thread Bruno Rocha
I have One form for multiple tables working very well locally, I can
include data and upload images normally on rocket server and sqlite.

my model

*  Field(author, reference auth_user),
 **  Field(author_nickname, string),
 **  Field(title, string),
 **  Field(description, text),
 **  Field(picture, upload),
 **  Field(thumbnail, upload),
 **  Field(draft, boolean),
 **  Field(tags, list:string),
 **  Field(keywords, string),*


My form (form.factory for multiple tables, no fields repeated, works ok on
nginx and sqlite):


*import os
 path = os.path.join(request.folder, 'uploads')
 if request.env.web2py_runtime_gae:
 db.article.picture.uploadfolder = path
 db.article.thumbnail.uploadfolder = path
 else:
 db.article.picture.uploadfield = picture_blob
 db.article.thumbnail.uploadfield = thumbnail_blob
 form = SQLFORM.factory(db.article, db.article_content,
 table_name=article)
 if form.process().accepted:
 try:
 id =
 db.article.insert(**db.article._filter_fields(form.vars))
 form.vars.article_id = id
 id
 = db.article_content.insert(**db.article_content._filter_fields(form.vars))
 except Exception:
 db.rollback()
 response.flash = T(error including)
 else:
 db.commit()
 response.flash = self.T(Included.)*



But, in GAE data are inserted, but no the images are not inserted in to
blob field, in GAE web2py created picture_blob and thumbnail_blob
automatically, it works ok with SQLFORM and CRUD, but does not works with
SQLFORM.factory. I get the *_blob fields none

Someone knows about it?

Thanks

-- 

Bruno Rocha
[http://rochacbruno.com.br]


[web2py] UPLOAD without DBIO

2011-11-17 Thread Phyo Arkar
Hello Web2py.

I am needing a function that Filename need to be reserved. Using
filemanager (Elfinder) is the way i am treating currently but it do not use
web2py's upload function.
Need to keep file-name as it.

is web2py's default upload function cand do without DB IO ?

Thanks

Phyo.


[web2py] upload file to database using curl

2011-10-27 Thread thodoris
Hello,

I have been trying to find a way of how to upload a file in a database
using curl but i can't find any references. I have found a reference
that describes how to submit text  so i  guess that uploading a file
should possible as well. What i want to do is to upload a file from my
application that is written in C++ to the web server. I am new to
web2py so i would appreciate any advice.

Thodoris



[web2py] upload

2011-10-25 Thread lucas
hello one and all,

i know i have a lot of posts.  i will become proficient soon.  i am
getting the hang of web2py's rythums.

i get the response.download function, it is for the server to receive
files from the client and put the files onto the server.

i want to allow the user to download files to the client computer.  so
how would i best do an upload from the server to the client.
specifically, i want to store files under static or static/pdf and
upload static files from there to the client.

thank you in advance and have a great day.  lucas


[web2py] upload field in a generic form?

2011-10-24 Thread pepper_bg
Have to go to the experts for this. I have a table for storing
arbitrary user data:

db.define_table('extra_attributes',
Field('user',   db.auth_user),
Field('name'),
Field('type', requires = IS_IN_SET(('text','file'))),
Field('value',  'string') )

'value' could be text of file. Then the controller looks like:

def upload_birth_certificate():
form = SQLFORM.factory( Field('document', 'upload', uploadfolder =
'uploads') )
if form.accepts(request.vars, session):
db.extra_attributes.insert( user=auth.user.id, name='birth
cert', type='file', value=form.vars['document'] )

Like you notice I am bending the rules a little to make the 'value'
string field hold an upload path. This all works fine, uploads my
files and all, but turns out even if I know the file name and
location, using say 
http://mysite.com/my_app/my_cont/download/uploads/no_table.document.9b6...b10.62...67.png
I can't get my files. 'download' is just the standard:

def download():
return response.download(request,db)

I can live with the uploads/no_table.document.9b6...b10.62...67.png
uploaded file name but Response.download insists on 'no_table' and
'document' being actual table/column names.

I do have my reasons to keep my schema loose like this and not define
a dedicated 'upload' field and would explore other options before
messing with the schema.

So is there any way to change this behavior? What comes to mind is
somehow fool the Field or the Form to take an existing table/column
names so Response.download is happy but I am not sure it is absolutely
safe with no side effects downstream. Put another way can 'upload'
fields be used in truly generic SQLFORM.factory(...) forms?

Thanks for your help!




[web2py] upload - file in custom folder

2011-10-17 Thread miroslavgojic
I have upload form and my files go to default uploads folder.

Can I have more than one upload folder
I have need to chose folder folder where I need to store file

Is this possible



[web2py] upload and download with multiparty filter

2011-10-13 Thread miroslavgojic
Hi,

I need to create upload and download page:
On both page there is filter what should be applied for upload or
download.
Upload form have filter with 4 drop down list and one input field for
text after this there is field for file selection and button for
upload.
I need to select some values from drop down lists and than make title
in text field and than make upload file.
Data need to bee stored in database and file should be saved in folder
but it should bee renamed in accordance to filter options.
Download have same filter but instead upload options there should be
link for file download.

Is there an example of something similar to this, I know to make my
own forms and lists, but is there some built in class and methods for
this.

Thanks


[web2py] upload/post of semi-large files

2011-09-05 Thread Carlos
Hi,

My production environment is ubuntu, postgresql, uwsgi and nginx.

The issue I'm having is when posting a form with a semi-large file (~2 mb), 
where it keeps 'resetting' the % uploaded every 30 seconds up to 2 to 3 
times, and finally failing (with no specific error that I could see).

I thought this could be fixed by setting a big number for uwsgi's harakiri 
option (which defaults to 60 secs), but that doesn't seem to help.

What should I do to fix this and allow posting forms with semi-large files 
that take about a minute or so to upload?.

Thanks!,

   Carlos



Re: [web2py] upload/post of semi-large files

2011-09-05 Thread Roberto De Ioris

 Hi,

 My production environment is ubuntu, postgresql, uwsgi and nginx.

 The issue I'm having is when posting a form with a semi-large file (~2
 mb),
 where it keeps 'resetting' the % uploaded every 30 seconds up to 2 to 3
 times, and finally failing (with no specific error that I could see).

 I thought this could be fixed by setting a big number for uwsgi's harakiri
 option (which defaults to 60 secs), but that doesn't seem to help.

 What should I do to fix this and allow posting forms with semi-large files
 that take about a minute or so to upload?.

 Thanks!,

Carlos



Check your nginx error log, you are probably receiving a 413 error (entity
too large). By default the limit is 1 mb

http://wiki.nginx.org/HttpCoreModule#client_max_body_size

-- 
Roberto De Ioris
http://unbit.it


Re: [web2py] upload/post of semi-large files

2011-09-05 Thread Carlos
Hi Roberto,

I was just about to post the solution I found: precisely what you mention 
:-)

   client_max_body_size 10M;

Thanks!,

   Carlos



Re: [web2py] Upload File via HTTP

2011-07-29 Thread Ismael Serratos
anybody?
On Jul 27, 2011 1:02 PM, Ismael Serratos ialejandr...@gmail.com wrote:
 I found this for Django I need exactly the same but for web2py could you
 help me to translate??? or to give me a hint?

 # - upload_file.py # upload binary file with
 pycurl by http postc = pycurl.Curl()c.setopt(c.POST, 1)c.setopt(c.URL,
 http://127.0.0.1:8000/receive/;)c.setopt(c.HTTPPOST, [(file1,
 (c.FORM_FILE, c:\\tmp\\download\\test.jpg))])#c.setopt(c.VERBOSE,
 1)c.perform()c.close()print that's it ;)
 # # DJANGO RECEIVE TEST APPLICATION#
 
 # - urls.py from django.conf.urls.defaults
 import *urlpatterns = patterns('',
 (r'^receive/$', 'web.views.receive'),
 )
 # - web\views.py def receive(request):
 assert request.method==POST
 print receive.META.SERVER_PORT, request.META[SERVER_PORT],
request.POST
 files = []
 for multipart_name in request.FILES.keys():
 multipart_obj = request.FILES[multipart_name]
 content_type = multipart_obj['content-type']
 filename = multipart_obj['filename']
 content = multipart_obj['content']
 files.append((filename, content_type, content))
 import datetime
 # write file to the system - add timestamp in the name
 file(c:\\tmp\\%s_%s %
 (datetime.datetime.now().isoformat().replace(:, -), filename),
 wb).write(content)

 fnames = ,.join([fname for fname, ct, c in files])
 return HttpResponse(me-%s-RECEIVE-OK[POST=%s,files=%s] %
 (request.META[SERVER_PORT], request.POST.values(), fnames ))



 On Wed, Jul 27, 2011 at 11:57 AM, pbreit pbreitenb...@gmail.com wrote:

 The problem with SQLFORM is that I think it's going to be expecting a
 hidden field for security purposes. You might need to just write a
 controller that processes request.post_vars.myfile manually.


Re: [web2py] Upload File via HTTP

2011-07-27 Thread Ismael Serratos
Like this??

db.define_table('configfiles'
Field('cfgfile','upload'))

def getfiles():

form= SQLFORM(db.configfiles)

if form.accepts(request.vars):

db.configfiles.insert(cfgfile=db.configfiles.cfgfile.store(request.vars.Filedata.file,
request.vars.Filedata.filename))

return dict(form=form)

On Tue, Jul 26, 2011 at 4:15 PM, Bruno Rocha rochacbr...@gmail.com wrote:

 I did it with forms. Client needs to make a POST to web2py with input file
 in form (make sure the right content type)

 in web2py server create an action that does:

 example:

 #model
 Field('picture','upload',uploadfolder=request.folder+'static/uploads',
 autodelete=True )

 #receiver
 in form.accepts():
 db.table.insert(picture=db.photo.picture.store(request.vars.Filedata.file,
 request.vars.Filedata.filename))



 On Tue, Jul 26, 2011 at 6:01 PM, Ismael Serratos 
 ialejandr...@gmail.comwrote:

 Hi! I was wondering how could I upload a file to web2py from another PC
 (intranet app) but via http, I mean, make a server and a client script.

 Is it possible??

 client does't have web2py, just python, server is running web2py.




 --



 --
 Bruno Rocha
 [ About me: http://zerp.ly/rochacbruno ]
 [ Aprenda a programar: http://CursoDePython.com.br ]
 [ O seu aliado nos cuidados com os animais: http://AnimalSystem.com.br ]
 [ Consultoria em desenvolvimento web: http://www.blouweb.com ]




Re: [web2py] Upload File via HTTP

2011-07-27 Thread pbreit
The problem with SQLFORM is that I think it's going to be expecting a hidden 
field for security purposes. You might need to just write a controller that 
processes request.post_vars.myfile manually.

Re: [web2py] Upload File via HTTP

2011-07-27 Thread Ismael Serratos
I found this for Django I need exactly the same but for web2py could you
help me to translate??? or to give me a hint?

# - upload_file.py # upload binary file with
pycurl by http postc = pycurl.Curl()c.setopt(c.POST, 1)c.setopt(c.URL,
http://127.0.0.1:8000/receive/;)c.setopt(c.HTTPPOST, [(file1,
(c.FORM_FILE, c:\\tmp\\download\\test.jpg))])#c.setopt(c.VERBOSE,
1)c.perform()c.close()print that's it ;)
# # DJANGO RECEIVE TEST APPLICATION#

# - urls.py from django.conf.urls.defaults
import *urlpatterns = patterns('',
(r'^receive/$', 'web.views.receive'),
)
# - web\views.py def receive(request):
   assert request.method==POST
   print receive.META.SERVER_PORT, request.META[SERVER_PORT], request.POST
   files = []
   for multipart_name in request.FILES.keys():
  multipart_obj = request.FILES[multipart_name]
  content_type  = multipart_obj['content-type']
  filename  = multipart_obj['filename']
  content   = multipart_obj['content']
  files.append((filename, content_type, content))
  import datetime
  # write file to the system - add timestamp in the name
  file(c:\\tmp\\%s_%s %
(datetime.datetime.now().isoformat().replace(:, -), filename),
wb).write(content)

   fnames = ,.join([fname for fname, ct, c in files])
   return HttpResponse(me-%s-RECEIVE-OK[POST=%s,files=%s] %
(request.META[SERVER_PORT], request.POST.values(), fnames ))



On Wed, Jul 27, 2011 at 11:57 AM, pbreit pbreitenb...@gmail.com wrote:

 The problem with SQLFORM is that I think it's going to be expecting a
 hidden field for security purposes. You might need to just write a
 controller that processes request.post_vars.myfile manually.


[web2py] Upload File via HTTP

2011-07-26 Thread Ismael Serratos
Hi! I was wondering how could I upload a file to web2py from another PC
(intranet app) but via http, I mean, make a server and a client script.

Is it possible??

client does't have web2py, just python, server is running web2py.


Re: [web2py] Upload File via HTTP

2011-07-26 Thread Bruno Rocha
I did it with forms. Client needs to make a POST to web2py with input file
in form (make sure the right content type)

in web2py server create an action that does:

example:

#model
Field('picture','upload',uploadfolder=request.folder+'static/uploads',
autodelete=True )

#receiver
in form.accepts():
db.table.insert(picture=db.photo.picture.store(request.vars.Filedata.file,
request.vars.Filedata.filename))



On Tue, Jul 26, 2011 at 6:01 PM, Ismael Serratos ialejandr...@gmail.comwrote:

 Hi! I was wondering how could I upload a file to web2py from another PC
 (intranet app) but via http, I mean, make a server and a client script.

 Is it possible??

 client does't have web2py, just python, server is running web2py.




-- 



--
Bruno Rocha
[ About me: http://zerp.ly/rochacbruno ]
[ Aprenda a programar: http://CursoDePython.com.br ]
[ O seu aliado nos cuidados com os animais: http://AnimalSystem.com.br ]
[ Consultoria em desenvolvimento web: http://www.blouweb.com ]


[web2py] upload - S3 storage

2011-07-25 Thread Nils Olofsson
Hi all,

 Before I go off and make an  attempt at creating a S3 upload
function, I was just wondering if anyone has a working version ?

I read the discussion on this and for me I need a way of storing
uploaded images on S3 to share between a few  VPS on Amazon's EC2.

The only other way to accomplish the same thing would be to use rsync,
which is not ideal.

I want to stay within the functionality of web2py SQLforms, maybe by
having the field type 'uploadS3' so web2py would know that the file is
going to be uploaded to amazons S3 service.

Is this a good approach ?

So far I've only used the functionality of web2py, I never had to
change or customize it, so any help or pointer would be appreciated.

Regards,

Nils


Re: [web2py] upload - S3 storage

2011-07-25 Thread nils
HI,

Just looking at dal.py and there is a SQLCustomType, I was wondering
if the functionality i would require could be added via  this class?,
Would this be the way to go ?

Nils


On Mon, Jul 25, 2011 at 1:04 PM, Nils Olofsson nils.olofs...@gmail.com wrote:
 Hi all,

  Before I go off and make an  attempt at creating a S3 upload
 function, I was just wondering if anyone has a working version ?

 I read the discussion on this and for me I need a way of storing
 uploaded images on S3 to share between a few  VPS on Amazon's EC2.

 The only other way to accomplish the same thing would be to use rsync,
 which is not ideal.

 I want to stay within the functionality of web2py SQLforms, maybe by
 having the field type 'uploadS3' so web2py would know that the file is
 going to be uploaded to amazons S3 service.

 Is this a good approach ?

 So far I've only used the functionality of web2py, I never had to
 change or customize it, so any help or pointer would be appreciated.

 Regards,

 Nils


[web2py] Upload form using Load

2011-07-01 Thread David J.

I had this working a few weeks ago.

I have an upload form which I load into the page using the LOAD helper.

Right now I get an exception when I try to upload.

Here is the code.

def upload_contacts():
form = FORM(INPUT(_type='file', 
_name='data',requires=[IS_NOT_EMPTY()]), INPUT(_type='submit'))


if form.accepts(request):


contact_list = request.vars.data #I also tried 
form.vars.data.file Exception about data being a string.


...csv processing left out for brevity

I am just trying to access the file at this point.

I followed the example in the book in DAL for uploading CSV data.
http://web2py.com/book/default/chapter/06#CSV-%28one-table-at-a-time%29



[web2py] upload file without storing it

2011-06-01 Thread jc
I wish to upload a file, then process it without storing it in the
upload folder (or anywhere else on the file system). I am trying to
use the 'SQLFORM.Factory' because it gives me the nice html table of
input fields, and the normal 'if form.accepts' processing for
convenience. I thought I could persuade the form to upload and store
the file contents in 'request.vars.field.file' for processing.

Nothing I have tried so far in the field definition has allowed me to
access the contents of the file in a variable, without it being stored
to disk. Can anybody advise me what is the simplest way to achieve
this?

Thanks.


Re: [web2py] upload file without storing it

2011-06-01 Thread Bruno Rocha
request.vars.field_in_form.file

should give you the binary definition of the file, I am using it with
uploadify



--
Bruno Rocha
[ About me: http://zerp.ly/rochacbruno ]
[ Aprenda a programar: http://CursoDePython.com.br ]
[ O seu aliado nos cuidados com os animais: http://AnimalSystem.com.br ]
[ Consultoria em desenvolvimento web: http://www.blouweb.com ]



On Wed, Jun 1, 2011 at 11:43 AM, jc j-cl...@lineone.net wrote:

 I wish to upload a file, then process it without storing it in the
 upload folder (or anywhere else on the file system). I am trying to
 use the 'SQLFORM.Factory' because it gives me the nice html table of
 input fields, and the normal 'if form.accepts' processing for
 convenience. I thought I could persuade the form to upload and store
 the file contents in 'request.vars.field.file' for processing.

 Nothing I have tried so far in the field definition has allowed me to
 access the contents of the file in a variable, without it being stored
 to disk. Can anybody advise me what is the simplest way to achieve
 this?

 Thanks.


  1   2   >