Re: [web2py] trying to help young son learn Python, and...

2014-03-04 Thread Calvin Morrison
Hi,

http://web2py.com/books/default/chapter/29/13/deployment-recipes

this page offers different deployment  recipes for hosting like
PythonAnywhere. If your host (i am unfamiliar with go-daddy) provides you
root/shell access to a linux box, you shouldn't have any trouble. I am
Running my web2py instance from a VPS service.


On 4 March 2014 13:58,  wrote:

> 1. does anyone know if web2py can be installed on a common web host like
> verio or go daddy hosting, and if so, if there is a "how to" anywhere to do
> it
> 2. does, or will, web2py support python 3.x any time soon?
>
> thanks much!
>
> --
> 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.
>

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


Re: [web2py] March 4 & Lab 8

2014-03-04 Thread Calvin Morrison
I am so glad I am not taking intro to programming ever again. I hate string
manipulation!

Massimo - you might want to resend this to your actual students

Calvin


On 4 March 2014 14:20, Massimo Di Pierro  wrote:

> During lab today you will begin writing the solutions for these problems:
>
>
>1.
>
>Write a version of a palindrome recogniser that accepts a file name
>from the user, reads each line, and prints the line to the screen if it is
>a palindrome.
>2.
>
>According to Wikipedia, a *semordnilap* is a word or phrase that
>spells a *different* word or phrase backwards. ("Semordnilap" is
>itself "palindromes" spelled backwards.) Write a semordnilap recogniser
>that accepts a file name (pointing to a list of words) from the user and
>finds and prints all pairs of words that are semordnilaps to the screen.
>For example, if "stressed" and "desserts" is part of the word list, the the
>output should include the pair "stressed desserts". Note, by the way, that
>each pair by itself forms a palindrome!
>3.
>
>Write a *procedure* char_freq_table() that, when run in a terminal,
>accepts a file name from the user, builds a frequency listing of the
>characters contained in the file, and prints a sorted and nicely formatted
>character frequency table to the screen.
>
> You start today and continue at home. They will count as problems a8p1,
> a8p2, a8p3 of lab 8. They will be graded next week. Next week you will also
> work on problems a8p4, a8p5, a8p6.
>
>
>  --
> 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.
>

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


Re: [web2py] Best practices for using mercurial within web2py

2014-02-21 Thread Calvin Morrison
> Also, relatedly, I was trying to restart apache from within a web2py app.
> That was giving me errors, so I'm doing something else.  Is there a way to
> do this?

you can do it from the shell. Look up your relevant distro information
on init scripts.

usually it's something like

sudo service apache2 restart

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


Re: [web2py] Using "Homemade task queues"

2014-01-30 Thread Calvin Morrison
Look at the scheduler documentation. I have mine called this way from
my db.py. This calls a few different tasks, adding file size and also
calling a task called unzip / untar which are functions i have written
to handle zipping and unzipping. Hopefully this explains it somewhat


def upload_post_hook(row_id):

row = db(db.uploads.id == row_id).select('up_file', 'username',
'filename')[0]

add_size(row_id)

if row.filename.endswith('.zip'):
scheduler.queue_task(unzip,pvars=dict(filename=row.up_file,
username=row.username, folder=request.folder,
real_filename=row.filename, id=row_id))
if any(row.filename.endswith(ext) for ext in ['.tar', 'tgz',
'.tar.gz', '.tar.bz', '.tar.xz', '.tar.bz2']):
  scheduler.queue_task(untar,pvars=dict(filename=row.up_file,
username=row.username, folder=request.folder,
real_filename=row.filename, id=row_id))

return None


db.uploads._after_insert.append(lambda id, i: upload_post_hook(i))

On 30 January 2014 16:31, desta  wrote:
> Hello everyone,
>
> A user uploads a file through a form and I want to process it using an
> external python script. I read from the manual about the Homemade task
> queues (http://web2py.com/books/default/chapter/29/04#Homemade-task-queues).
> I understand how it works.
>
> What I am missing is how to actually run the following command from my
> controller
>
> python web2py.py -S app -M -R applications/app/private/myscript.py -A a b c
>
>
> I would appreciate any help!
>
> Thanks for reading
>
> --
> 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.

-- 
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] CentOS install notes

2014-01-27 Thread Calvin Morrison
I've been having trouble with centOS getting a 503 Service unavailable 
using Apache's httpd. If anyone else is seeing this same problem, I 
found that this solved my problem:


adding this to my main httpd.conf:

WSGISocketPrefix /var/run/wsgi

--
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] Slow response

2014-01-27 Thread Calvin Morrison

Hi guys,

I have a fairly typical web2py application I am trying to deploy with a 
standard CentOS 6 configuration using Apache and MySQL.


What seems to be bugging me right now is that the responses are very 
slow, around .7 seconds to load the home page. I have a feeling this is 
because of my apache WSGI setup.


It seems that web2py doesn't stay running as a process on the server,
so i guess each time it has to reimport and load everything up, seems 
quite slow.


 Before when running using the Rocket sever for development the site 
was snappy, now it's slow.


Any tips/tricks to keep web2p in the background for wsgi so that it's 
not so slow?


Calvin

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


Re: [web2py] Printing statements from Python

2014-01-26 Thread Calvin Morrison
A ghetto way: just open a file and use regular write commands
On Jan 26, 2014 1:30 PM, "horridohobbyist" 
wrote:

> I'm looking for a simple way to print out statements in Python. I
> understand the 'print' function outputs to the console on the server side,
> but once web2py is deployed through Apache, I don't there's a "console"
> anymore.
>
> I tried looking at Python logging. The simplest case from the Python
> documentation suggests the following *should* work:
>
> import logging
> logging.basicConfig(filename=URL('static','debug.log'),level=logging.DEBUG)
>
> logging.debug('this is a test')
>
>
> But when I examine debug.log, it's empty. (Without the filename
> configuration, I have NO IDEA where the logging outputs to.)
>
> Is there no way to obtain a simple outputting mechanism in web2py?
>
> 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.
> For more options, visit https://groups.google.com/groups/opt_out.
>

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


Re: [web2py] Re: Writing Web2Py specification and finding free lance Web2Py coders

2014-01-13 Thread Calvin Morrison
elance.com?

On 11 January 2014 23:04, Simon Ashley  wrote:
> Often thought that it would be good to push this to another level. We have
> projects from time to time that would be good to outsource, if people were
> interested. Something like a project post board, with bidders, assignment,
> monitoring and completion.
>
> --
> 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.

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


Re: [web2py] Multiple Uploads using jQuery-File-Upload: Javascript/CSS Conflict?

2014-01-09 Thread Calvin Morrison
Brando,

Thanks for working this out!

it would be good to make a web2py slice or add it to the documentation/ examples

Calvin

On 8 January 2014 14:35, Brando  wrote:
> This works, added the requires statement for form validation:
>
> def submit():
> import datetime
> form = FORM(LABEL("File(s):"), INPUT(_name='up_files', _type='file',
> _multiple='', requires=IS_NOT_EMPTY()),  BR(),INPUT(_type='submit'))
> if form.accepts(request.vars, formname="form"):
> files = request.vars['up_files']
> if not isinstance(files, list):
> files = [files]
> for f in files:
> print f.filename
> up_file = db.uploads.up_file.store(f, f.filename)
> i = db.uploads.insert(notes=request.vars.notes, up_file=up_file,
> filename=f.filename, up_date= datetime.datetime.now())
> db.commit()
> return "form submitted" #redirect(URL('data', 'index'))
> 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/groups/opt_out.

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


Re: [web2py] Multiple Uploads using jQuery-File-Upload: Javascript/CSS Conflict?

2014-01-08 Thread Calvin Morrison
that'd be a Jquery thing.

jQuery("input#fileid").change(function () {
alert(jQuery(this).val())
});



On 8 January 2014 14:36, Brando  wrote:

> Question, how could I make it so I don't have to click the submit button.
>  How could i make it to where they choose the files and it auto submits it?
>
>
>
> On Wednesday, January 8, 2014 11:35:44 AM UTC-8, Brando wrote:
>>
>> This works, added the requires statement for form validation:
>>
>> def submit():
>> import datetime
>> form = FORM(LABEL("File(s):"), INPUT(_name='up_files', _type='file',
>> _multiple='', requires=IS_NOT_EMPTY()),  BR(),INPUT(_type='submit'))
>> if form.accepts(request.vars, formname="form"):
>> files = request.vars['up_files']
>> if not isinstance(files, list):
>> files = [files]
>> for f in files:
>> print f.filename
>> up_file = db.uploads.up_file.store(f, f.filename)
>> i = db.uploads.insert(notes=request.vars.notes,
>> up_file=up_file, filename=f.filename, up_date= datetime.datetime.now())
>> db.commit()
>> return "form submitted" #redirect(URL('data', 'index'))
>> 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/groups/opt_out.
>

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


Re: [web2py] Multiple Uploads using jQuery-File-Upload: Javascript/CSS Conflict?

2014-01-08 Thread Calvin Morrison
Yes I am getting that same problem here.

Like I said, I don't really know how to properly test if the variable has
been set.

Any input from more wise web2pyers would be great

Calvin


On 8 January 2014 14:03, Brando  wrote:

> Calvin, I'm getting this error when I select only 1 file to upload:
>
>
>
> Traceback (most recent call last):
>  File "/Volumes/BrandonsData/Google
> Drive/web2py/web2py.app/Contents/Resources/gluon/restricted.py", line 217,
> in restricted
>  File "/Volumes/BrandonsData/Google
> Drive/web2py/web2py.app/Contents/Resources/applications/calvinsmultiuploadfromgooggroup/controllers/default.py"
> , line 158, in 
>  File "/Volumes/BrandonsData/Google
> Drive/web2py/web2py.app/Contents/Resources/gluon/globals.py", line 372, in
> 
>  File "/Volumes/BrandonsData/Google
> Drive/web2py/web2py.app/Contents/Resources/applications/calvinsmultiuploadfromgooggroup/controllers/default.py"
> , line 116, in submit
>  File "cgi.pyc", line 591, in __len__
>  File "cgi.pyc", line 574, in keys
> TypeError: not indexable
>
> Which is coming from the highlighted line:
> def submit():
>   import datetime
>
>   form = FORM(LABEL("File(s):"), INPUT(_name='up_files', 
> _type='file',_multiple
> =''), INPUT(_type='submit'))
>
>
>   if form.accepts(request.vars, formname="form"):
>
> if hasattr(request.vars, 'up_files'):
>   if len(request.vars.up_files) > 0:
>
> files = request.vars['up_files']
> if not isinstance(files, list):
>   files = [files]
>
> for f in files:
>   print f.filename
>   up_file = db.uploads.up_file.store(f, f.filename)
>   i = db.uploads.insert(notes=request.vars.notes, up_file=up_file,
> filename=f.filename, username = auth.user.email, up_date= datetime.
> datetime.now())
>   db.commit()
>
>
> return "form submitted" #redirect(URL('data', 'index'))
>
>   else:
> form.errors.up_files = "No files selected"
>
>   return dict(form=form)
>
>
>
>
>
> Did you see that during your testing? Any thoughts on 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/groups/opt_out.
>

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


Re: [web2py] Multiple Uploads using jQuery-File-Upload: Javascript/CSS Conflict?

2014-01-08 Thread Calvin Morrison
instead of inserting it, you could write the file stream out to whereever
you want.

It's really just a python cgi module object. so you can use all
corresponding documentation to help

look at this SO answer

https://stackoverflow.com/questions/15947988/in-my-python-cgi-script-how-do-i-save-to-disk-a-file-uploaded-via-post-request


On 8 January 2014 10:44, Brando  wrote:

> Also, should it be possible to adapt this so that I could use
> SQLFORM.factory instead of FORM?  I notice this uploads the files to the
> db.  What would need to change so that I'm just pulling it to the local
> disk?
>
>
>
>
>
>
>
> On Wednesday, January 8, 2014 7:18:28 AM UTC-8, Calvin Morrison wrote:
>
>> I  just wrote my own way to do it yesterday which worked great. I would
>> love it to go upstream.
>>
>> It's just a standard file upload with the multiple attribute.
>>
>> here's the entire thing: it spits out a form.
>>
>> my db looks like this:
>>
>> db.define_table('uploads',
>> Field('username', 'string'),
>> Field('filename', represent = lambda x, row: "None" if x == None else
>> x[:45]),
>> Field('up_file', 'upload', uploadseparate=True,
>> requires=IS_NOT_EMPTY()),
>> Field('up_date', 'datetime'),
>> Field('up_size', 'integer', represent= lambda x, row:
>> quikr_utils.sizeof_fmt(x) ),
>> Field('notes', 'text'))
>>
>>
>> my contorller
>>
>> def submit():
>>   import datetime
>>
>>   form = FORM(LABEL("File(s):"), INPUT(_name='up_files', _type='file',
>> _multiple=''), BR(), LABEL("Notes:"), TEXTAREA(_name='notes'),
>> BR(),INPUT(_type='submit'))
>>
>>   if form.accepts(request.vars, formname="form"):
>>
>> if hasattr(request.vars, 'up_files'):
>>   if len(request.vars.up_files) > 0:
>>
>> files = request.vars['up_files']
>> if not isinstance(files, list):
>>   files = [files]
>>
>> for f in files:
>>   print f.filename
>>   up_file = db.uploads.up_file.store(f, f.filename)
>>   i = db.uploads.insert(notes=request.vars.notes,
>> up_file=up_file,filename=f.filename, username = auth.user.email,
>> up_date= datetime.datetime.now())
>>   db.commit()
>>
>> redirect(URL('data', 'index'))
>>   else:
>> form.errors.up_files = "No files selected"
>>
>>   return dict(form=form)
>>
>>
>> On 8 January 2014 10:14, Brando  wrote:
>>
>>> I'm trying to use 
>>> jQuery-File-Upload<http://blueimp.github.io/jQuery-File-Upload/>to 
>>> implement multiple file uploads.  I'm using this
>>> tutorial<http://in10min.blogspot.com/2013/04/web2py-implement-multiple-files-upload.html>
>>>  as
>>> well as this sample app 
>>> HERE<https://bitbucket.org/xavrenard/multiupload_module/src>.
>>>
>>>
>>> Is there something in the standard web2py build that would be preventing
>>> the proper javascript or CSS from running?  The sample app should work
>>> right out of the box; however, no buttons are displayed.
>>>
>>> Has anyone successfully implemented this on web2py before?
>>>
>>>
>>>
>>>
>>>
>>>  --
>>> 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+un...@googlegroups.com.
>>>
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>
>>  --
> 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.
>

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


Re: [web2py] Multiple Uploads using jQuery-File-Upload: Javascript/CSS Conflict?

2014-01-08 Thread Calvin Morrison
:-) I was having a hell of a time trying to get all the AJAX examples to
work and well, none of it f***ing would. Yesterday I brewed an extra strong
pot of coffee and cranked this out.

Some of the code i would like review on, I am not sure how to properly
check for if there was an uploaded file or not, i have that weird "is in"
then "len() < 0" but i don't think it's the best.

Whoever is a maintainer/developer of web2py - could we integrate this
somehow?

Calvin


On 8 January 2014 10:40, Brando  wrote:

> Calvin, you are awesome.  I will try this on my end and report back.
>
>
>
>
>
> On Wednesday, January 8, 2014 7:18:28 AM UTC-8, Calvin Morrison wrote:
>
>> I  just wrote my own way to do it yesterday which worked great. I would
>> love it to go upstream.
>>
>> It's just a standard file upload with the multiple attribute.
>>
>> here's the entire thing: it spits out a form.
>>
>> my db looks like this:
>>
>> db.define_table('uploads',
>> Field('username', 'string'),
>> Field('filename', represent = lambda x, row: "None" if x == None else
>> x[:45]),
>> Field('up_file', 'upload', uploadseparate=True,
>> requires=IS_NOT_EMPTY()),
>> Field('up_date', 'datetime'),
>> Field('up_size', 'integer', represent= lambda x, row:
>> quikr_utils.sizeof_fmt(x) ),
>> Field('notes', 'text'))
>>
>>
>> my contorller
>>
>> def submit():
>>   import datetime
>>
>>   form = FORM(LABEL("File(s):"), INPUT(_name='up_files', _type='file',
>> _multiple=''), BR(), LABEL("Notes:"), TEXTAREA(_name='notes'),
>> BR(),INPUT(_type='submit'))
>>
>>   if form.accepts(request.vars, formname="form"):
>>
>> if hasattr(request.vars, 'up_files'):
>>   if len(request.vars.up_files) > 0:
>>
>> files = request.vars['up_files']
>> if not isinstance(files, list):
>>   files = [files]
>>
>> for f in files:
>>   print f.filename
>>   up_file = db.uploads.up_file.store(f, f.filename)
>>   i = db.uploads.insert(notes=request.vars.notes,
>> up_file=up_file,filename=f.filename, username = auth.user.email,
>> up_date= datetime.datetime.now())
>>   db.commit()
>>
>> redirect(URL('data', 'index'))
>>   else:
>> form.errors.up_files = "No files selected"
>>
>>   return dict(form=form)
>>
>>
>> On 8 January 2014 10:14, Brando  wrote:
>>
>>> I'm trying to use 
>>> jQuery-File-Upload<http://blueimp.github.io/jQuery-File-Upload/>to 
>>> implement multiple file uploads.  I'm using this
>>> tutorial<http://in10min.blogspot.com/2013/04/web2py-implement-multiple-files-upload.html>
>>>  as
>>> well as this sample app 
>>> HERE<https://bitbucket.org/xavrenard/multiupload_module/src>.
>>>
>>>
>>> Is there something in the standard web2py build that would be preventing
>>> the proper javascript or CSS from running?  The sample app should work
>>> right out of the box; however, no buttons are displayed.
>>>
>>> Has anyone successfully implemented this on web2py before?
>>>
>>>
>>>
>>>
>>>
>>>  --
>>> 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+un...@googlegroups.com.
>>>
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>
>>  --
> 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.
>

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


Re: [web2py] Multiple Uploads using jQuery-File-Upload: Javascript/CSS Conflict?

2014-01-08 Thread Calvin Morrison
I  just wrote my own way to do it yesterday which worked great. I would
love it to go upstream.

It's just a standard file upload with the multiple attribute.

here's the entire thing: it spits out a form.

my db looks like this:

db.define_table('uploads',
Field('username', 'string'),
Field('filename', represent = lambda x, row: "None" if x == None else
x[:45]),
Field('up_file', 'upload', uploadseparate=True,
requires=IS_NOT_EMPTY()),
Field('up_date', 'datetime'),
Field('up_size', 'integer', represent= lambda x, row:
quikr_utils.sizeof_fmt(x) ),
Field('notes', 'text'))


my contorller

def submit():
  import datetime

  form = FORM(LABEL("File(s):"), INPUT(_name='up_files', _type='file',
_multiple=''), BR(), LABEL("Notes:"), TEXTAREA(_name='notes'),
BR(),INPUT(_type='submit'))

  if form.accepts(request.vars, formname="form"):

if hasattr(request.vars, 'up_files'):
  if len(request.vars.up_files) > 0:

files = request.vars['up_files']
if not isinstance(files, list):
  files = [files]

for f in files:
  print f.filename
  up_file = db.uploads.up_file.store(f, f.filename)
  i = db.uploads.insert(notes=request.vars.notes,
up_file=up_file,filename=f.filename, username = auth.user.email, up_date=
datetime.datetime.now())
  db.commit()

redirect(URL('data', 'index'))
  else:
form.errors.up_files = "No files selected"

  return dict(form=form)


On 8 January 2014 10:14, Brando  wrote:

> I'm trying to use 
> jQuery-File-Uploadto implement 
> multiple file uploads.  I'm using this
> tutorial
>  as
> well as this sample app 
> HERE.
>
>
> Is there something in the standard web2py build that would be preventing
> the proper javascript or CSS from running?  The sample app should work
> right out of the box; however, no buttons are displayed.
>
> Has anyone successfully implemented this on web2py before?
>
>
>
>
>
>  --
> 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.
>

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


Re: [web2py] Re: custom widgets

2014-01-07 Thread Calvin Morrison
great thanks!

On 7 January 2014 15:18, Anthony  wrote:
>> 1. Where should I put my custom widget logic?
>>
>> Right now i have it grossely stored in my db.py
>
>
> You can always put it in a module file and import it.
>
>>
>> 2. Can i pass more information to my widget other than field, value from
>> my
>> db.table.colum.widget = mywidgetfunc
>
>
> If you have:
>
> def mywidget(field, value, arg1, arg2):
>
> you can do:
>
> db.table.column.widget = lambda f, v: mywidget(f, v, value1, value2)
>
> or:
>
> import functools
> db.table.column.widget = functools.partial(mywidget, arg1=value1,
> arg2=value2)
>
> Anthony
>
> --
> 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.

-- 
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] require based on another field.

2014-01-02 Thread Calvin Morrison
Hi!

I have a field called "Job Type", and another field "database" that
depends on the type. If the user selects "Train" for Job Type, they
don't need to enter a database (a integer id), but i don't know how to
make validators do this for me.

Right now I have this:

db.jobs.db.requires =
IS_NULL_OR(IS_IN_DB(db((db.quikr_database.username == auth.user.email)
| (db.quikr_database.share_with_others == True)),
db.quikr_database.id, '%(name)s'))

Either it can be null (in the case of Train) or otherwise it needs to
be in the list of shared quikr_databases.

Any ideas?

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


Re: [web2py] Re: save upload filename in database

2013-12-31 Thread Calvin Morrison
Here is my solution!


  if hasattr(request.vars['up_file'],"filename"):
form.vars.filename = request.vars['up_file'].filename

  if form.process().accepted:
redirect(URL('data', 'index'))
  elif form.errors:
response.flash = "form has errors"

On 28 December 2013 17:08, Calvin Morrison  wrote:
> More specifically this only happens if I put in the if up_name != None check
> to set the filename in the database, otherwise it works well
>
>
> On Friday, December 27, 2013 11:48:09 PM UTC-5, Massimo Di Pierro wrote:
>>
>> Let's isolate the problem.
>>
>> Are you saying that even if you have this:
>>
>> Field('up_file', 'upload', uploadseparate=True, requires =[IS_NOT_EMPTY(),
>> IS_UPLOAD_FILENAME(extension=ext_regex)]),
>>
>> You can submit a form that does not upload a file into up_file?
>>
>> On Thursday, 26 December 2013 13:21:35 UTC-6, Calvin Morrison wrote:
>>>
>>> I'm following the documentation trying to figure out how to correctly
>>> save a filename to my uploads database.
>>>
>>> Basically i have the same code as the website shows in it's examples
>>>
>>>
>>> def submit():
>>>
>>>
>>>  import datetime
>>>
>>>
>>>  form = SQLFORM(db.uploads, fields=['up_file', notes], deletable=True)
>>>
>>>
>>>  form.vars.up_date = datetime.datetime.now()
>>>  form.vars.username = auth.user.email
>>>
>>>
>>>  if request.vars.up_file != None:
>>>  form.vars.filename = request.vars.up_file.filename
>>>
>>>
>>>  if form.process().accepted:
>>>  redirect(URL('data', 'index'))
>>>  elif form.errors:
>>>  response.flash = "form has errors"
>>>
>>>
>>> But my form doesn't appear to be validating correctly. It allows me to
>>> hit submit even if a file is not supplied. This leads to a error being
>>> logged, so I want to avoid things getting submitted.  My only thought is
>>> that it could be my requires not working correctly
>>>
>>> ext_regex = '|'.join(quikr_utils.all_ext)
>>>
>>> db.define_table('uploads',
>>> Field('username', 'string'),
>>> Field('filename', represent = lambda x, row: "None" if x == None else
>>> x[:45]),
>>> Field('up_file', 'upload', uploadseparate=True,
>>> requires=[IS_NOT_EMPTY(), IS_UPLOAD_FILENAME(extension=ext_regex)]),
>>> Field('up_date', 'datetime'),
>>> Field('up_size', 'integer', represent= lambda x, row:
>>> quikr_utils.sizeof_fmt(x) ),
>>> Field('notes', 'text'))
>>>
>>> >>> print quikr_utils.all_ext
>>> ['fasta','fa','fna','fasta.gz','fa.gz','fna.gz']
>>>
>>> Any ideas?
>>> 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.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
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] Re: save upload filename in database

2013-12-28 Thread Calvin Morrison
More specifically this only happens if I put in the if up_name != None 
check to set the filename in the database, otherwise it works well

On Friday, December 27, 2013 11:48:09 PM UTC-5, Massimo Di Pierro wrote:
>
> Let's isolate the problem.
>
> Are you saying that even if you have this:
>
> Field('up_file', 'upload', uploadseparate=True, requires =[IS_NOT_EMPTY(),
>  IS_UPLOAD_FILENAME(extension=ext_regex)]),
>
> You can submit a form that does not upload a file into up_file?
>
> On Thursday, 26 December 2013 13:21:35 UTC-6, Calvin Morrison wrote:
>>
>> I'm following the documentation trying to figure out how to correctly 
>> save a filename to my uploads database.
>>
>> Basically i have the same code as the website shows in it's examples
>>
>>
>> def submit():
>>
>>
>>  import datetime
>>
>>
>>  form = SQLFORM(db.uploads, fields=['up_file', notes], deletable=True)
>>
>>
>>  form.vars.up_date = datetime.datetime.now()
>>  form.vars.username = auth.user.email
>>
>>
>>  if request.vars.up_file != None:
>>  form.vars.filename = request.vars.up_file.filename
>>
>>
>>  if form.process().accepted:
>>  redirect(URL('data', 'index'))
>>  elif form.errors:
>>  response.flash = "form has errors"
>>
>>
>> But my form doesn't appear to be validating correctly. It allows me to 
>> hit submit even if a file is not supplied. This leads to a error being 
>> logged, so I want to avoid things getting submitted.  My only thought is 
>> that it could be my requires not working correctly
>>
>> ext_regex = '|'.join(quikr_utils.all_ext)
>>
>> db.define_table('uploads',
>> Field('username', 'string'),
>> Field('filename', represent = lambda x, row: "None" if x == None elsex
>> [:45]),
>> Field('up_file', 'upload', uploadseparate=True, requires=[
>> IS_NOT_EMPTY(), IS_UPLOAD_FILENAME(extension=ext_regex)]),
>> Field('up_date', 'datetime'), 
>> Field('up_size', 'integer', represent= lambda x, row: quikr_utils.
>> sizeof_fmt(x) ), 
>> Field('notes', 'text'))
>>
>> >>> print quikr_utils.all_ext
>> ['fasta','fa','fna','fasta.gz','fa.gz','fna.gz']
>>
>> Any ideas?
>> 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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [web2py] Re: save upload filename in database

2013-12-28 Thread Calvin Morrison
Yes that's exactly the problem!

Which in turn causes the other problems I think
On Dec 27, 2013 11:48 PM, "Massimo Di Pierro" 
wrote:

> Let's isolate the problem.
>
> Are you saying that even if you have this:
>
> Field('up_file', 'upload', uploadseparate=True, requires =[IS_NOT_EMPTY(),
>  IS_UPLOAD_FILENAME(extension=ext_regex)]),
>
> You can submit a form that does not upload a file into up_file?
>
> On Thursday, 26 December 2013 13:21:35 UTC-6, Calvin Morrison wrote:
>>
>> I'm following the documentation trying to figure out how to correctly
>> save a filename to my uploads database.
>>
>> Basically i have the same code as the website shows in it's examples
>>
>>
>> def submit():
>>
>>
>>  import datetime
>>
>>
>>  form = SQLFORM(db.uploads, fields=['up_file', notes], deletable=True)
>>
>>
>>  form.vars.up_date = datetime.datetime.now()
>>  form.vars.username = auth.user.email
>>
>>
>>  if request.vars.up_file != None:
>>  form.vars.filename = request.vars.up_file.filename
>>
>>
>>  if form.process().accepted:
>>  redirect(URL('data', 'index'))
>>  elif form.errors:
>>  response.flash = "form has errors"
>>
>>
>> But my form doesn't appear to be validating correctly. It allows me to
>> hit submit even if a file is not supplied. This leads to a error being
>> logged, so I want to avoid things getting submitted.  My only thought is
>> that it could be my requires not working correctly
>>
>> ext_regex = '|'.join(quikr_utils.all_ext)
>>
>> db.define_table('uploads',
>> Field('username', 'string'),
>> Field('filename', represent = lambda x, row: "None" if x == None elsex
>> [:45]),
>> Field('up_file', 'upload', uploadseparate=True, requires=[
>> IS_NOT_EMPTY(), IS_UPLOAD_FILENAME(extension=ext_regex)]),
>> Field('up_date', 'datetime'),
>> Field('up_size', 'integer', represent= lambda x, row: quikr_utils.
>> sizeof_fmt(x) ),
>> Field('notes', 'text'))
>>
>> >>> print quikr_utils.all_ext
>> ['fasta','fa','fna','fasta.gz','fa.gz','fna.gz']
>>
>> Any ideas?
>> 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.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
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] save upload filename in database

2013-12-27 Thread Calvin Morrison
I'm following the documentation trying to figure out how to correctly save 
a filename to my uploads database.

Basically i have the same code as the website shows in it's examples


def submit():


 import datetime


 form = SQLFORM(db.uploads, fields=['up_file', notes], deletable=True)


 form.vars.up_date = datetime.datetime.now()
 form.vars.username = auth.user.email


 if request.vars.up_file != None:
 form.vars.filename = request.vars.up_file.filename


 if form.process().accepted:
 redirect(URL('data', 'index'))
 elif form.errors:
 response.flash = "form has errors"


But my form doesn't appear to be validating correctly. It allows me to hit 
submit even if a file is not supplied. This leads to a error being logged, 
so I want to avoid things getting submitted.  My only thought is that it 
could be my requires not working correctly

ext_regex = '|'.join(quikr_utils.all_ext)

db.define_table('uploads',
Field('username', 'string'),
Field('filename', represent = lambda x, row: "None" if x == None else x
[:45]),
Field('up_file', 'upload', uploadseparate=True, requires=[IS_NOT_EMPTY
(), IS_UPLOAD_FILENAME(extension=ext_regex)]),
Field('up_date', 'datetime'), 
Field('up_size', 'integer', represent= lambda x, row: quikr_utils.
sizeof_fmt(x) ), 
Field('notes', 'text'))

>>> print quikr_utils.all_ext
['fasta','fa','fna','fasta.gz','fa.gz','fna.gz']

Any ideas?
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.
For more options, visit https://groups.google.com/groups/opt_out.