Re: [web2py] OAuth - Can Users Authenticate without an Internet connection?

2014-05-01 Thread Brando
What are my options if I want users to be able to login with or without an 
internet connection and still be able to centrally control authentication 
on all the nodes?   Keep in mind that these machines will have internet 
connection throughout the day, however they will be offline for an hour or 
two at the time.



On Wednesday, April 30, 2014 1:46:01 PM UTC-7, yamandu wrote:

 If each node must authenticate with OAuth with it will requires internet 
 connection.
 Give a look here: https://developers.google.com/accounts/docs/OAuth2


 2014-04-30 16:30 GMT-03:00 Brando bhe...@trustcc.com javascript::

 I want to use OAuth + Google and want to know if things will work if a 
 node is offline.  My app model is as follows.


 I will have about 15 laptops in the field.
 Each laptop will have a local copy of the app installed.
 The laptop may/may not have Internet access.
 I plan on using Couchbase for the DB
 I need to be able to restrict access to a particular user (if they get 
 fired or something)

 Is it possible to allow people to login even if they don't have Internet 
 access?  How would this work?

 -- 
 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 javascript:.
 For more options, visit https://groups.google.com/d/optout.




 -- 
 Att.

 Carlos J. Costa
 Cientista da Computação
 Esp. Gestão em Telecom

 EL MELECH NEEMAN!
 אָמֵן

 

-- 
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] OAuth - Can Users Authenticate without an Internet connection?

2014-05-01 Thread Brando
Really stupid question.I'm not planning on using the DAL (because i'll 
be using CouchBase).  I'd rather not use sqlite at all.  What do I need to 
do to save the credentials into the couchbase db instead of the sqlite? 
 I'm assuming the DAL handles the password encryption and all that.

Thanks for your help yamandu.



On Thursday, May 1, 2014 10:03:02 AM UTC-7, yamandu wrote:

 If they share the same DB and they all are in the same network, the 
 builtin authentication will work.

 If not, you may want to sync the authentication tables while you have 
 connection. So each local application will have a copy.



 2014-05-01 12:22 GMT-03:00 Brando bhe...@trustcc.com javascript::

 What are my options if I want users to be able to login with or without 
 an internet connection and still be able to centrally control 
 authentication on all the nodes?   Keep in mind that these machines will 
 have internet connection throughout the day, however they will be offline 
 for an hour or two at the time.



 On Wednesday, April 30, 2014 1:46:01 PM UTC-7, yamandu wrote:

 If each node must authenticate with OAuth with it will requires internet 
 connection.
 Give a look here: https://developers.google.com/accounts/docs/OAuth2


 2014-04-30 16:30 GMT-03:00 Brando bhe...@trustcc.com:

  I want to use OAuth + Google and want to know if things will work if 
 a node is offline.  My app model is as follows.


 I will have about 15 laptops in the field.
 Each laptop will have a local copy of the app installed.
 The laptop may/may not have Internet access.
 I plan on using Couchbase for the DB
 I need to be able to restrict access to a particular user (if they get 
 fired or something)

 Is it possible to allow people to login even if they don't have 
 Internet access?  How would this work?

 -- 
 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/d/optout.




 -- 
 Att.

 Carlos J. Costa
 Cientista da Computação
 Esp. Gestão em Telecom

 EL MELECH NEEMAN!
 אָמֵן

   -- 
 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 javascript:.
 For more options, visit https://groups.google.com/d/optout.




 -- 
 Att.

 Carlos J. Costa
 Cientista da Computação
 Esp. Gestão em Telecom

 EL MELECH NEEMAN!
 אָמֵן

 

-- 
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] OAuth - Can Users Authenticate without an Internet connection?

2014-04-30 Thread Brando
I want to use OAuth + Google and want to know if things will work if a node 
is offline.  My app model is as follows.


I will have about 15 laptops in the field.
Each laptop will have a local copy of the app installed.
The laptop may/may not have Internet access.
I plan on using Couchbase for the DB
I need to be able to restrict access to a particular user (if they get 
fired or something)

Is it possible to allow people to login even if they don't have Internet 
access?  How would this work?

-- 
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] Re: CouchDB driver No Tables/FIELDS?

2014-04-22 Thread Brando
What about the auth tables?  Do I also need to keep sqlite to handle 
authentication?

Also, what couchdb driver do people prefer these days?

Thanks Massimo.







On Tuesday, April 22, 2014 6:50:20 AM UTC-7, Massimo Di Pierro wrote:

 Mind you can use Couch db (and you do not need to specify tables) but it 
 is not supported by the web2py DAL (although there is some untested 
 experimental code related to Couch in there).



 On Tuesday, 22 April 2014 00:23:51 UTC-5, Brando wrote:

 I want to use CouchDB for an upcoming project.  I know that i'm supposed 
 to install a couchdb driver, but i have no idea where to get the driver 
 from and where exactly it needs to be installed.

 Also, I'm assuming since couch is a document database that it will be 
 unnecessary for me to define tables and fields, is this correct?




-- 
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] Re: CouchDB driver No Tables/FIELDS?

2014-04-22 Thread Brando
2 more questions

1. I'm assuming the couchdb library I want to use needs to live in the 
modules folder?
2. What is the best way to bundle couch with web2py so I can distribute 
everything together?

On Tuesday, April 22, 2014 9:28:12 AM UTC-7, Brando wrote:

 What about the auth tables?  Do I also need to keep sqlite to handle 
 authentication?

 Also, what couchdb driver do people prefer these days?

 Thanks Massimo.







 On Tuesday, April 22, 2014 6:50:20 AM UTC-7, Massimo Di Pierro wrote:

 Mind you can use Couch db (and you do not need to specify tables) but it 
 is not supported by the web2py DAL (although there is some untested 
 experimental code related to Couch in there).



 On Tuesday, 22 April 2014 00:23:51 UTC-5, Brando wrote:

 I want to use CouchDB for an upcoming project.  I know that i'm supposed 
 to install a couchdb driver, but i have no idea where to get the driver 
 from and where exactly it needs to be installed.

 Also, I'm assuming since couch is a document database that it will be 
 unnecessary for me to define tables and fields, is this correct?




-- 
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] CouchDB driver No Tables/FIELDS?

2014-04-21 Thread Brando
I want to use CouchDB for an upcoming project.  I know that i'm supposed to 
install a couchdb driver, but i have no idea where to get the driver from 
and where exactly it needs to be installed.

Also, I'm assuming since couch is a document database that it will be 
unnecessary for me to define tables and fields, is this correct?


-- 
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] Need a developer. Seattle Wa

2014-04-04 Thread Brando
It's pretty easy to find Django developers out there; however, I can't seem to 
find web2py devs.  I have an upcoming project to build an app for data entry 
and report generation for security audits (penetration testing).  I need a 
developer who can help me build out the code base and is familiar with 
ajax/jquery data entry.

Can someone point me in the right direction?  

-- 
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] Re: Bootstrap3 package - help to test

2014-03-14 Thread Brando
Paolo, I got everything moved over.  So far no problems.  I'm trying to 
figure out the best way to style a SQLFORM.grid without using custom js. 
What is the easiest way to style the SQLFORM.grid with bootstrap3?





On Thursday, March 13, 2014 8:59:07 AM UTC-7, Brando wrote:

 Just found this Post.  Thanks Paolo.  I'll move my app over to this 
 template and report any issues I find.




 On Monday, December 23, 2013 12:20:48 PM UTC-8, Paolo Caruccio wrote:

 I just completed a package that applies the bootstrap3 style to some 
 web2py elements - the current version covers the navigation menus, the auth 
 navbar and SQLFORMs (via formstyle) - but I need your help for testing it.

 The package includes the following files:

  - bootstrap3.py
  - web2py-bootstrap3.css
  - web2py-bootstrap3.js
  - example of layout.html
  - a readme file containing the istallation and usage instructions
  - license (please report if the license is right for a future inclusion 
 in web2py)

 Here attached some screenshots and a web2py app with examples. 

 Thank you in advance for your feedbacks, suggestions for optimizing the 
 code and any additions and everything else useful to improve the package.

 Marry Christmas. 







-- 
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] Re: Bootstrap3 package - help to test

2014-03-13 Thread Brando
Just found this Post.  Thanks Paolo.  I'll move my app over to this 
template and report any issues I find.




On Monday, December 23, 2013 12:20:48 PM UTC-8, Paolo Caruccio wrote:

 I just completed a package that applies the bootstrap3 style to some 
 web2py elements - the current version covers the navigation menus, the auth 
 navbar and SQLFORMs (via formstyle) - but I need your help for testing it.

 The package includes the following files:

  - bootstrap3.py
  - web2py-bootstrap3.css
  - web2py-bootstrap3.js
  - example of layout.html
  - a readme file containing the istallation and usage instructions
  - license (please report if the license is right for a future inclusion 
 in web2py)

 Here attached some screenshots and a web2py app with examples. 

 Thank you in advance for your feedbacks, suggestions for optimizing the 
 code and any additions and everything else useful to improve the package.

 Marry Christmas. 







-- 
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] Re: Want to use Bootstrap 3. Should I wait? Timeframe?

2014-03-13 Thread Brando
I just found Paolo's post about bootstrap3 here.  

https://groups.google.com/forum/#!topic/web2py/oSABtjmnYM0

I'll give that a try.




On Wednesday, March 12, 2014 1:30:01 PM UTC-7, Brando wrote:

 I'm about to start changing my styles to use Bootstrap 3, but I don't know 
 if i should just wait until the official update comes that has it baked in. 
  Is Bootstrap 3 integration going to happen in the next few months?


-- 
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] Want to use Bootstrap 3. Should I wait? Timeframe?

2014-03-12 Thread Brando
I'm about to start changing my styles to use Bootstrap 3, but I don't know 
if i should just wait until the official update comes that has it baked in. 
 Is Bootstrap 3 integration going to happen in the next few months?

-- 
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] Re: Formatting JSON objects with XML() -TypeError: gluon.html.XML object xxxx is not JSON serializable

2014-02-25 Thread Brando
Sorry...This should have read:

Line: 324 ~ tom
Line: 246 ~ dick
Line: 112 ~ harry

also, I am displaying this info in a SQLFORM.grid

-- 
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: Formatting JSON objects with XML() -TypeError: gluon.html.XML object xxxx is not JSON serializable

2014-02-25 Thread Brando
Anthony, I got this figured out.  I had a syntax error on my side.  Thanks 
as always.



On Tuesday, February 25, 2014 4:25:14 AM UTC-8, Anthony wrote:

 Yes, but what code is running that produces the error? Can we see the 
 relevant controller and/or view code? Also, did you edit the traceback? I 
 don't see any of the calls shown in it.

 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.


[web2py] Represent: List indexing problem.

2014-02-24 Thread Brando
I am parsing data out of files and inputting this data into a sqlite db. 
 One file may have multiple username entries.  The data looks something 
like this:

[['tom', 324],['dick', 246],['harry', 112]]

The first item in each list is obviously the name.  The second line is the 
line number (i used enumerate) from my parsed file.

I want to be able to display html like follows:

Line: 324 - tom
Line: 246 - dick
Line: 112 - harry

I'd like to be able to access items in my lists by index; however, 
everything inside my individual lists are strings.  Do I have to convert 
the strings back to a list?

Example:

The following returns ['tom', 324]

Field('username', represent = lambda x, row: x[0]),

While this returns '['

Field('username', represent = lambda x, row: x[0][0]),


I'd rather not have to convert every line back into a listis there a 
better 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/groups/opt_out.


[web2py] Re: Represent: List indexing problem.

2014-02-24 Thread Brando
I solved this by inserting the data as json.  

This line now returns '324'.

Field('username', represent = lambda x, row: x[0][1]),


-- 
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] Formatting JSON objects with XML() -TypeError: gluon.html.XML object xxxx is not JSON serializable

2014-02-24 Thread Brando
I have json data that looks like this:

[['tom', 324],['dick', 246],['harry', 112]]

I want to be able to display html like follows:

Line: 324 - tom
Line: 246 - dick
Line: 112 - harry


SoI made a function to reformat my data and use represent to run the 
data through the function:

Field('username', 'json', represent = lambda usernames, row: displayrecords(
usernames)),


Here is the function:
def displayrecords(value):
values = []
for x, y in value:
values.append(str('Line: '+ str(y) + ' ~ ' + x))
return values

This function then give me a list as follows:

['Line: 324 ~ tom', 'Line: 246 ~ dick', 'Line: 112 ~ harry']


Now, whenever I change the field line to this
Field('username', 'json', represent = lambda usernames, row: 
XML('br'.join(displayrecords(usernames,

I get the following traceback:
Traceback

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.

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/Contour/controllers/devices2.py
 http://127.0.0.1:8000/admin/default/edit/Contour/controllers/devices2.py, 
line 214, in module
  File /Volumes/BrandonsData/Google 
Drive/web2py/web2py.app/Contents/Resources/gluon/globals.py, line 372, in 
lambda
  File /Volumes/BrandonsData/Google 
Drive/web2py/web2py.app/Contents/Resources/applications/Contour/controllers/devices2.py
 http://127.0.0.1:8000/admin/default/edit/Contour/controllers/devices2.py, 
line 47, in list2
  File applications/Contour/modules/engine5.py, line 395, in show_settings
  File /Volumes/BrandonsData/Google 
Drive/web2py/web2py.app/Contents/Resources/gluon/sqlhtml.py, line 2473, in grid
  File /Volumes/BrandonsData/Google 
Drive/web2py/web2py.app/Contents/Resources/gluon/dal.py, line 9921, in 
formatter
  File /Volumes/BrandonsData/Google 
Drive/web2py/web2py.app/Contents/Resources/gluon/validators.py, line 2681, in 
formatter
  File /Volumes/BrandonsData/Google 
Drive/web2py/web2py.app/Contents/Resources/gluon/validators.py, line 369, in 
formatter
  File json/__init__.pyc, line 231, in dumps
  File json/encoder.pyc, line 201, in encode
  File json/encoder.pyc, line 264, in iterencode
  File json/encoder.pyc, line 178, in default
TypeError: gluon.html.XML object at 0x10fecc190 is not JSON serializable



Where am I going wrong here?

-- 
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: Formatting JSON objects with XML() -TypeError: gluon.html.XML object xxxx is not JSON serializable

2014-02-24 Thread Brando
Anthony, that error is produced when I change the field line like i show 
above.  I basically need to know how to change this list:

['Line: 324 ~ tom', 'Line: 246 ~ dick', 'Line: 112 ~ harry']

into this html:

Line: 324 - tom
Line: 246 - dick
Line: 112 - harry

The problem seems to arise when I try to use XML() with  a json object. 
 I'm trying to add a br in between each item in the list, but XML() 
doesn't seem to play well with JSON.  How could I accomplish this?






On Monday, February 24, 2014 7:19:28 PM UTC-8, Anthony wrote:

 What exactly produced that error, and can you show the rest of the 
 traceback details?

 On Monday, February 24, 2014 10:04:09 PM UTC-5, Brando wrote:

 I have json data that looks like this:

 [['tom', 324],['dick', 246],['harry', 112]]

 I want to be able to display html like follows:

 Line: 324 - tom
 Line: 246 - dick
 Line: 112 - harry


 SoI made a function to reformat my data and use represent to run the 
 data through the function:

 Field('username', 'json', represent = lambda usernames, row:displayrecords
 (usernames)),


 Here is the function:
 def displayrecords(value):
 values = []
 for x, y in value:
 values.append(str('Line: '+ str(y) + ' ~ ' + x))
 return values

 This function then give me a list as follows:

 ['Line: 324 ~ tom', 'Line: 246 ~ dick', 'Line: 112 ~ harry']


 Now, whenever I change the field line to this
 Field('username', 'json', represent = lambda usernames, row: 
 XML('br'.join(displayrecords(usernames,

 I get the following traceback:
 Traceback

 1.
 2.
 3.
 4.
 5.
 6.
 7.
 8.
 9.
 10.
 11.
 12.
 13.
 14.
 15.
 16.

 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/Contour/controllers/devices2.py
  http://127.0.0.1:8000/admin/default/edit/Contour/controllers/devices2.py, 
 line 214, in module
   File /Volumes/BrandonsData/Google 
 Drive/web2py/web2py.app/Contents/Resources/gluon/globals.py, line 372, in 
 lambda
   File /Volumes/BrandonsData/Google 
 Drive/web2py/web2py.app/Contents/Resources/applications/Contour/controllers/devices2.py
  http://127.0.0.1:8000/admin/default/edit/Contour/controllers/devices2.py, 
 line 47, in list2
   File applications/Contour/modules/engine5.py, line 395, in show_settings
   File /Volumes/BrandonsData/Google 
 Drive/web2py/web2py.app/Contents/Resources/gluon/sqlhtml.py, line 2473, in 
 grid
   File /Volumes/BrandonsData/Google 
 Drive/web2py/web2py.app/Contents/Resources/gluon/dal.py, line 9921, in 
 formatter
   File /Volumes/BrandonsData/Google 
 Drive/web2py/web2py.app/Contents/Resources/gluon/validators.py, line 2681, 
 in formatter
   File /Volumes/BrandonsData/Google 
 Drive/web2py/web2py.app/Contents/Resources/gluon/validators.py, line 369, 
 in formatter
   File json/__init__.pyc, line 231, in dumps
   File json/encoder.pyc, line 201, in encode
   File json/encoder.pyc, line 264, in iterencode
   File json/encoder.pyc, line 178, in default
 TypeError: gluon.html.XML object at 0x10fecc190 is not JSON serializable



 Where am I going wrong here?



-- 
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: Updating a distributed web2py app.

2014-02-21 Thread Brando
Thanks for the feedback.





On Wednesday, February 19, 2014 2:29:06 PM UTC-8, Niphlod wrote:

 Did it with a bit of turnarounds, but it's pretty solid.
 Check out 
 https://github.com/niphlod/w2p_tvseries/blob/master/private/w2p_tvseries_installer.py

 a tiddle bit of tl/dr:
 - somewhere on the internet there's an updated version of the app. in my 
 case, a tagged github zipball
 - somewhere on the internet there's a version file that can be fetched 
 and compared to the local one to initiate the upgrade process (in my case, 
 a file stored on github)
 - there is an upgrade process defined . in my case, a bit of turnarounds 
 but you can safely assume the following:
   - compare versions
   - download new archive
   - backup current app
   - overwrite with new archive
   - initialize what needs to be initialized

 From experience I can tell you that the upgrade process should be 
 two-stepped (because it's unlikely you'll create an update routine that 
 works every time)... so, I do it in two steps... start the script, compare 
 versions... at this point, download the newest update routine and 
 overwrite it. Then start it, check again versions, and start the real 
 update process.




-- 
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: Pack on OSX, Import on Windows bug (binary only)

2014-02-19 Thread Brando
My bad, thanks M.



On Tuesday, February 18, 2014 6:58:56 PM UTC-8, Massimo Di Pierro wrote:

 It isn't that. The problem is that when you use py2pp, the latter freezes 
 the path of the build machine for the purpose of reporting errors. I hate 
 it but I have not fund a solution.
 This is not cause of errors. This is case of incorrect paths in reported 
 errors.

 The error is in your engine5.py

 from html import FORM, INPUT, LABEL, OPTION, SELECT, BUTTON

 should be

 from gluon import FORM, INPUT, LABEL, OPTION, SELECT, BUTTON

 or

 from gluon.html import FORM, INPUT, LABEL, OPTION, SELECT, BUTTON

 because html is not in path. gluon is.

 On Tuesday, 18 February 2014 20:08:09 UTC-6, Brando wrote:

 Ticket ID
 127.0.0.1.2014-02-18.20-21-14.5e42032d-3fa0-4fc5-8a93-9ca1ef22e89f

 type 'exceptions.ImportError' No module named html

 Version
 web2py™ Version 2.8.2-stable+timestamp.2013.11.28.13.54.07
 Python Python 2.7.5: \\vmware-host\Shared 
 Folders\Desktop\web2py\web2py.exe (prefix: C:\Python27)
 Traceback
 1.
 2.
 3.
 4.
 5.
 6.
 7.
 8.
 9.
 10.
 11.
 12.
 Traceback (most recent call last):
   File /home/mdipierro/make_web2py/web2py/gluon/restricted.py, line 
 217, in restricted
   File //vmware-host/Shared 
 Folders/Desktop/web2py/applications/c2/controllers/devices2.py, line 3, in 
 module
 from engine5 import  Formulator, Uploader, maketable
   File /home/mdipierro/make_web2py/web2py/gluon/custom_import.py, line 
 86, in custom_importer
   File /home/mdipierro/make_web2py/web2py/gluon/custom_import.py, line 
 125, in __call__
   File applications\c2\modules\engine5.py, line 4, in module
 from html import FORM, INPUT, LABEL, OPTION, SELECT, BUTTON
   File /home/mdipierro/make_web2py/web2py/gluon/custom_import.py, line 
 86, in custom_importer
   File /home/mdipierro/make_web2py/web2py/gluon/custom_import.py, line 
 125, in __call__
 ImportError: No module named html

 OSX version is Mavericks.  Pack all and import it into Windows 7 binary 
 version of Web2py (latest).

 This bug is not present in the Windows source version.  Massimo, it looks 
 like it's trying to load modules from your personal computer.



-- 
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] License? Is it ok to distribute commerciallly without restriction?

2014-02-19 Thread Brando
I'm new to licensing and I want to make sure I stay within license scope:

Here's what I want to do:

Distribute a stand-alone app that uses the built in rocket server and 
sqlite db.  
I plan on building the app so that there is no start-up dialogjust 
launch the app and it opens the login page.  
I don't plan on significantly editing source (maybe some default CSS or 
something)

Here's what I need to know:

   1. What web2py branding is required within my app (if any).
   2. Are there any restrictions distributing this app commercially?
   



-- 
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] Updating a distributed web2py app.

2014-02-19 Thread Brando
I assume this is a dumb question, but here goes.If I distribute my 
web2py app what is the best way to push updates to my clients that are 
spread out all over the place?

-- 
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: Updating a distributed web2py app.

2014-02-19 Thread Brando
Updating would happen have to happen over the WAN.

I would prefer to update realtime/in the background (like chrome).  Is this 
possible?



On Wednesday, February 19, 2014 8:34:56 AM UTC-8, 黄祥 wrote:

 if the client is not same network (lan), i think you can pack web2py app 
 and upload it on your client via web2py appadmin (if you use sqlite, please 
 ensure backup and edit database, because it store on the same folder 
 databases). 
 if the client is on the lan, i usually use configuration management to 
 push the web2py app and it's setting.

 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/groups/opt_out.


[web2py] Pack on OSX, Import on Windows bug (binary only)

2014-02-18 Thread Brando
Ticket ID
127.0.0.1.2014-02-18.20-21-14.5e42032d-3fa0-4fc5-8a93-9ca1ef22e89f

type 'exceptions.ImportError' No module named html

Version
web2py™ Version 2.8.2-stable+timestamp.2013.11.28.13.54.07
Python Python 2.7.5: \\vmware-host\Shared Folders\Desktop\web2py\web2py.exe 
(prefix: C:\Python27)
Traceback
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
Traceback (most recent call last):
  File /home/mdipierro/make_web2py/web2py/gluon/restricted.py, line 217, 
in restricted
  File //vmware-host/Shared 
Folders/Desktop/web2py/applications/c2/controllers/devices2.py, line 3, in 
module
from engine5 import  Formulator, Uploader, maketable
  File /home/mdipierro/make_web2py/web2py/gluon/custom_import.py, line 
86, in custom_importer
  File /home/mdipierro/make_web2py/web2py/gluon/custom_import.py, line 
125, in __call__
  File applications\c2\modules\engine5.py, line 4, in module
from html import FORM, INPUT, LABEL, OPTION, SELECT, BUTTON
  File /home/mdipierro/make_web2py/web2py/gluon/custom_import.py, line 
86, in custom_importer
  File /home/mdipierro/make_web2py/web2py/gluon/custom_import.py, line 
125, in __call__
ImportError: No module named html

OSX version is Mavericks.  Pack all and import it into Windows 7 binary 
version of Web2py (latest).

This bug is not present in the Windows source version.  Massimo, it looks 
like it's trying to load modules from your personal computer.

-- 
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: track_changes is Broken? I keep having to restart web2py

2014-02-13 Thread Brando
2.8.2 stable, OSX, web2py.app






On Wednesday, February 12, 2014 6:11:55 PM UTC-8, Richard wrote:

 Brando, which version of web2py you experiment this issue?

 Richard


 On Wed, Feb 12, 2014 at 9:06 PM, Brando bhe...@trustcc.com 
 javascript:wrote:

 I consolidated all of my different modules to 1 module file and it is now 
 working. 








 On Wednesday, February 12, 2014 4:08:04 PM UTC-8, Brando wrote:

 I've put the following in my model:

 from gluon.custom_import import track_changes
 track_changes(True)

 and all modules i am working with are in the modules folder within the 
 app.



 The last thread I read on here says that this functionality isn't 
 working.  Is that the case?  Development is taking a really long time since 
 i have to manually restart the app every time I want the modules refreshed.

 Also, I do understand that the track_changes feature is intended for 
 development only.  I don't plan on using this in production.


 Any suggestions?

  -- 
 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 javascript:.
 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] track_changes is Broken? I keep having to restart web2py

2014-02-12 Thread Brando
I've put the following in my model:

from gluon.custom_import import track_changes
track_changes(True)

and all modules i am working with are in the modules folder within the 
app.



The last thread I read on here says that this functionality isn't working. 
 Is that the case?  Development is taking a really long time since i have 
to manually restart the app every time I want the modules refreshed.

Also, I do understand that the track_changes feature is intended for 
development only.  I don't plan on using this in production.


Any suggestions?

-- 
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: track_changes is Broken? I keep having to restart web2py

2014-02-12 Thread Brando
I consolidated all of my different modules to 1 module file and it is now 
working. 








On Wednesday, February 12, 2014 4:08:04 PM UTC-8, Brando wrote:

 I've put the following in my model:

 from gluon.custom_import import track_changes
 track_changes(True)

 and all modules i am working with are in the modules folder within the 
 app.



 The last thread I read on here says that this functionality isn't working. 
  Is that the case?  Development is taking a really long time since i have 
 to manually restart the app every time I want the modules refreshed.

 Also, I do understand that the track_changes feature is intended for 
 development only.  I don't plan on using this in production.


 Any suggestions?


-- 
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: Storing lots of txt files: Database or Filesystem? Advantages/Disadvantages

2014-01-14 Thread Brando
Stifan, that is great info.  pulling from the filesystem is much faster.  I 
think i'm going to go this route.  Thanks!



On Monday, January 13, 2014 7:15:22 PM UTC-8, 黄祥 wrote:

 please check this discussion.
 https://groups.google.com/forum/#!topic/web2py/t83nQfT24gE

 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/groups/opt_out.


[web2py] Storing lots of txt files: Database or Filesystem? Advantages/Disadvantages

2014-01-13 Thread Brando

   
   - The files will not be larger than say 200kb, but there will be lots of 
   them(1000's).  
   - Users will need to download the original file.  
   - The files will be parsed on the initial upload, but I don't expect to 
   touch the files much after that.
   - The files will have sensitive info and will need to be encrypted while 
   being stored.

From my research it appears that storing the files to the filesystem is the 
way to go in this scenario.  Am I missing anything here?  Are there any 
other advantages to having the files in the db?

-- 
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] Need a Web2py tutor/mentor.

2014-01-13 Thread Brando
 I don't know anyone who builds webapps with python.  I've watched A LOT of 
videos and read A LOT of posts about web2py.  I've got the basics down and 
have built a couple of basic apps using web2py.  I'd like to find a 
tutor/mentor who could spend a couple of hours with me (skype/google 
hangout) to point me in the right direction on a few items.  I'm willing to 
pay for your time.

Suggestions?


-- 
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: Multiple File Upload Form Works! - Need Help with validation for multiple files

2014-01-10 Thread Brando
From my research, it looks like maybe an onvalidation function is the way 
to do this.  Can someone confirm this?

Something like:

def validate_upload():
passed_validation = []
files = request.vars['upload_files']

for file in files:
extension_file = file.split('.')[-1]
if extension_file == [csv|txt]
passed_validation.append(file)

return passed_validation


Thoughts?








On Thursday, January 9, 2014 2:57:40 PM UTC-8, Brando wrote:

 Thanks to Calvin Morrison's excellent work here is a really simple 
 solution to uploading multiple items.  I need help validating multiple 
 files.  I can upload one .txt file without issue; however, if i choose more 
 than one it will not pass validation.  Can someone tell me what kind of 
 loop or function would help me validate files BEFORE they are uploaded? 
  Also, if there is a more elegant way to code the controller please let me 
 know.

 Model:
 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'))

 Controller:
 def submit():
 import datetime
 form = FORM(LABEL(File(s):), INPUT(_name='up_files', _type='file', 
 _multiple=True, 
 requires=IS_UPLOAD_FILENAME(extension='txt|config|log')),INPUT(_type='submit'))
 if form.accepts(request.vars, formname=form):
 response.flash = 'form accepted'
 files = request.vars['up_files']
 if not isinstance(files, list):
 files = [files]
 for f in files:
 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()
 elif form.errors:
 response.flash = 'form has errors'
 else:
 response.flash = 'please fill the form'
 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.


[web2py] Re: Multiple File Upload Form Works! - Need Help with validation for multiple files

2014-01-10 Thread Brando
Success!  Here is how you can validate all files in a multiple file upload. 
 In this example if one document does not validate then the entire 
validation fails.  You could easily just drop the files that don't validate 
and only let the accepted files through for processing.  

*If anyone has a more elegant solution please let me know.*

def submit():
form = FORM(LABEL(), INPUT(_name='up_files', _type='file', 
_multiple=True, requires=IS_NOT_EMPTY()),INPUT(_type='submit')) # The 
multiple param lets us choose multiple files.
if form.accepts(request.vars, formname=file_upload, 
onvalidation=upload_validation): #onvalidation checks the uploaded files to 
make sure they are only txt, config, or log.
response.flash = 'Bro...uploading files' 
files = request.vars['up_files'] 
if not isinstance(files, list): #convert files to a list if they 
are not one already.
files = [files]
for file in files:
up_file = db.uploads.up_file.store(file, file.filename) #store 
is a FIELD method that let's you save a file to disk.  you can choose the 
directory if you want using the 'path' param.
else:
response.flash = 'Choose the Files you would like to upload'
return dict(form=form)


def upload_validation(form):
files = request.vars['up_files']
if not isinstance(files, list):
files = [files]
for file in files:
file_extension = file.filename.split('.')[-1] #find the file 
extension
acceptable_file = file_extension in ('txt', 'config', 'log') 
#choose the allowed file extensions
if not acceptable_file:
form.errors.up_files = Only .txt, .config, or .log files are 
allowed. #if they files are not acceptable return False. Validation 
failselse process the files.
return False



-- 
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 Brando
Calvin, I have a few other things I want to work out, but I'm going to 
start a new thread with a more relevant title.  

On Thursday, January 9, 2014 10:10:04 AM UTC-8, Calvin Morrison wrote:

 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 bhe...@trustcc.com javascript: 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+un...@googlegroups.com javascript:. 
  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] Multiple File Upload Form Works! - Need Help with validation for multiple files

2014-01-09 Thread Brando
Thanks to Calvin Morrison's excellent work here is a really simple solution 
to uploading multiple items.  I need help validating multiple files.  I can 
upload one .txt file without issue; however, if i choose more than one it 
will not pass validation.  Can someone tell me what kind of loop or 
function would help me validate files BEFORE they are uploaded?  Also, if 
there is a more elegant way to code the controller please let me know.

Model:
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'))

Controller:
def submit():
import datetime
form = FORM(LABEL(File(s):), INPUT(_name='up_files', _type='file', 
_multiple=True, 
requires=IS_UPLOAD_FILENAME(extension='txt|config|log')),INPUT(_type='submit'))
if form.accepts(request.vars, formname=form):
response.flash = 'form accepted'
files = request.vars['up_files']
if not isinstance(files, list):
files = [files]
for f in files:
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()
elif form.errors:
response.flash = 'form has errors'
else:
response.flash = 'please fill the form'
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.


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

2014-01-08 Thread Brando
I'm trying to use 
jQuery-File-Uploadhttp://blueimp.github.io/jQuery-File-Upload/to implement 
multiple file uploads.  I'm using this 
tutorialhttp://in10min.blogspot.com/2013/04/web2py-implement-multiple-files-upload.html
 as 
well as this sample app 
HEREhttps://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+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 Brando
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 bhe...@trustcc.com javascript: wrote:

 I'm trying to use 
 jQuery-File-Uploadhttp://blueimp.github.io/jQuery-File-Upload/to implement 
 multiple file uploads.  I'm using this 
 tutorialhttp://in10min.blogspot.com/2013/04/web2py-implement-multiple-files-upload.html
  as 
 well as this sample app 
 HEREhttps://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 javascript:.
 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 Brando
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 bhe...@trustcc.com javascript: wrote:

 I'm trying to use 
 jQuery-File-Uploadhttp://blueimp.github.io/jQuery-File-Upload/to implement 
 multiple file uploads.  I'm using this 
 tutorialhttp://in10min.blogspot.com/2013/04/web2py-implement-multiple-files-upload.html
  as 
 well as this sample app 
 HEREhttps://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 javascript:.
 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 Brando
Calvin, i stripped out a variable or two, but it appears to work great. 
 I'm getting a crazy twitch trying to figure out a javascript/ajax solution 
for this.  I second the idea of building this into Web2py, I would be more 
than happy to contribute, but I'm just starting out with web2py and I would 
probably make something burst into flames.  

Thanks for your help, I'll be sure to post my end code I use.

-- 
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 Brando
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.pyhttp://127.0.0.1:8000/admin/default/edit/calvinsmultiuploadfromgooggroup/controllers/default.py
, line 158, in module
 File /Volumes/BrandonsData/Google 
Drive/web2py/web2py.app/Contents/Resources/gluon/globals.py, line 372, in 
lambda
 File /Volumes/BrandonsData/Google 
Drive/web2py/web2py.app/Contents/Resources/applications/calvinsmultiuploadfromgooggroup/controllers/default.pyhttp://127.0.0.1:8000/admin/default/edit/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.


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

2014-01-08 Thread Brando
I removed that if loop completely and it works fine now:
def submit():
  import datetime

  form = FORM(LABEL(File(s):), INPUT(_name='up_files', _type='file', 
_multiple=''),  BR(),INPUT(_type='submit'))
  
  # if hasattr(request.vars, 'up_files'):
  #   form.process()
  if form.accepts(request.vars, formname=form):

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

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'))
  # else:
  #   form.errors.up_files = No files selected

  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.


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

2014-01-08 Thread Brando
I'm working on that now.

if anyone beats me to it please post the solution.


On Wednesday, January 8, 2014 11:23:21 AM UTC-8, Dave S wrote:

 On Wednesday, January 8, 2014 11:07:03 AM UTC-8, Brando wrote:

 I removed that if loop completely and it works fine now:

  
 The next obvious question:  did you test with no files?  To deal with 
 those of us who click too fast?

 /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/groups/opt_out.


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

2014-01-08 Thread Brando
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.


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

2014-01-08 Thread Brando
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.


Re: [web2py] Re: Inserting to db from module. Why do I need to keep restarting Web2py?

2014-01-04 Thread Brando
Richard, is this feature unreliable at this point or am i using it 
incorrectly?




On Friday, January 3, 2014 12:54:12 PM UTC-8, Brando wrote:

 Version

 2.8.2-stable+timestamp.2013.11.28.13.54.07
 (Running on Rocket 1.2.6, Python 2.7.3)






 Also, I doubt it's relevant, but I'm using Sublime Text as my IDE. 


-- 
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] Inserting to db from module. Why do I need to keep restarting Web2py?

2014-01-03 Thread Brando
I have the following code to insert a dictionary into my sqlite db from a 
module. 

#!/usr/bin/env python
# -*- coding: utf-8 -*-

from gluon import current
from gluon.dal import DAL, Field
from gluon.sqlhtml import SQLFORM
from gluon.validators import IS_NOT_EMPTY, IS_EMAIL, IS_LENGTH

class Parse(object):

def __init__(self):
self.db = current.db
# self.db = 
DAL('sqlite://storage.sqlite',pool_size=1,check_reserved=['all'])
# self.db = DAL(sqlite://mydb.sqlite)
self.session = current.session
self.request = current.request
self.response = current.response
self.cache = current.cache
self.maketable()
self.settings()
# self.set_validators()
self.addtodb()
def settings():

self.settings = {
'filepath': 'tom', #File path.
'filename': 'dick', #Name of the file being processed.
'hostname': 'harry', #What is the hostname?
}


def maketable(self):
self.testrecord = self.db.define_table(testrecord,
Field(filepath),
Field(filename),
Field(hostname)
 )

def addtodb(self):
self.db.testrecord.insert(**self.settings)
self.testrecord = self.db().select(self.db.testrecord.ALL)
return self.testrecord


If I change either tom, dick or harry; save the file, and reload my 
browser; I still get tom, dick and harry being returned to the screen. 
 HOWEVER, if I stop the web2py server, quit web2py (osx), and restart 
web2py I will get my new values when I reload the url.  

Any ideas what is going on here?


-- 
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: Inserting to db from module. Why do I need to keep restarting Web2py?

2014-01-03 Thread Brando
Actually, any changes made to my module file will not be reflected until i 
restart the web2py.app.










On Friday, January 3, 2014 8:14:36 AM UTC-8, Brando wrote:

 I have the following code to insert a dictionary into my sqlite db from a 
 module. 

 #!/usr/bin/env python
 # -*- coding: utf-8 -*-

 from gluon import current
 from gluon.dal import DAL, Field
 from gluon.sqlhtml import SQLFORM
 from gluon.validators import IS_NOT_EMPTY, IS_EMAIL, IS_LENGTH

 class Parse(object):

 def __init__(self):
 self.db = current.db
 # self.db = 
 DAL('sqlite://storage.sqlite',pool_size=1,check_reserved=['all'])
 # self.db = DAL(sqlite://mydb.sqlite)
 self.session = current.session
 self.request = current.request
 self.response = current.response
 self.cache = current.cache
 self.maketable()
 self.settings()
 # self.set_validators()
 self.addtodb()

 def settings(self):

 self.settings = {
 'filepath': 'tom', #File path.
 'filename': 'dick', #Name of the file being processed.
 'hostname': 'harry', #What is the hostname?
 }


 def maketable(self):
 self.testrecord = self.db.define_table(testrecord,
 Field(filepath),
 Field(filename),
 Field(hostname)
  )

 def addtodb(self):
 self.db.testrecord.insert(**self.settings)
 self.testrecord = self.db().select(self.db.testrecord.ALL)
 return self.testrecord


 If I change either tom, dick or harry; save the file, and reload my 
 browser; I still get tom, dick and harry being returned to the screen. 
  HOWEVER, if I stop the web2py server, quit web2py (osx), and restart 
 web2py I will get my new values when I reload the url.  

 Any ideas what is going on here?




-- 
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: Inserting to db from module. Why do I need to keep restarting Web2py?

2014-01-03 Thread Brando
Anthony, I added the line to a modeland it still doesn't work. Any other 
thoughts?

Also, why is it not recommended for production?




On Friday, January 3, 2014 8:26:13 AM UTC-8, Anthony wrote:

 It's the same with any Python module -- they only get loaded once on first 
 import. web2py does include a feature to automatically re-load upon change, 
 though not recommended for production. In a model file (before any imports):

 from gluon.custom_import import track_changes; track_changes(True)


 See 
 http://web2py.com/books/default/chapter/29/04/the-core#Accessing-the-API-from-Python-modules
 .

 Anthony

 On Friday, January 3, 2014 11:14:36 AM UTC-5, Brando wrote:

 I have the following code to insert a dictionary into my sqlite db from a 
 module. 

 #!/usr/bin/env python
 # -*- coding: utf-8 -*-

 from gluon import current
 from gluon.dal import DAL, Field
 from gluon.sqlhtml import SQLFORM
 from gluon.validators import IS_NOT_EMPTY, IS_EMAIL, IS_LENGTH

 class Parse(object):

 def __init__(self):
 self.db = current.db
 # self.db = 
 DAL('sqlite://storage.sqlite',pool_size=1,check_reserved=['all'])
 # self.db = DAL(sqlite://mydb.sqlite)
 self.session = current.session
 self.request = current.request
 self.response = current.response
 self.cache = current.cache
 self.maketable()
 self.settings()
 # self.set_validators()
 self.addtodb()

 def settings(self):

 self.settings = {
 'filepath': 'tom', #File path.
 'filename': 'dick', #Name of the file being processed.
 'hostname': 'harry', #What is the hostname?
 }


 def maketable(self):
 self.testrecord = self.db.define_table(testrecord,
 Field(filepath),
 Field(filename),
 Field(hostname)
  )

 def addtodb(self):
 self.db.testrecord.insert(**self.settings)
 self.testrecord = self.db().select(self.db.testrecord.ALL)
 return self.testrecord


 If I change either tom, dick or harry; save the file, and reload my 
 browser; I still get tom, dick and harry being returned to the screen. 
  HOWEVER, if I stop the web2py server, quit web2py (osx), and restart 
 web2py I will get my new values when I reload the url.  

 Any ideas what is going on here?




-- 
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: Inserting to db from module. Why do I need to keep restarting Web2py?

2014-01-03 Thread Brando


 Version

 2.8.2-stable+timestamp.2013.11.28.13.54.07
 (Running on Rocket 1.2.6, Python 2.7.3)






Also, I doubt it's relevant, but I'm using Sublime Text as my IDE. 

-- 
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] Using Modules Class - AttributeError: 'Engine' object has no attribute 'form'

2014-01-01 Thread Brando
I'm testing using Classes within my Modules to handle a lot of the heavy 
lifting.  I can't figure out what i'm doing wrong here.  I need an adult.


#No Model

#Controller: devices.py
from general import Engine

def upload():
page = Engine()
form = page.form()
return dict(form=form)

#Module: general.py
from gluon import *
import os

class Engine(object):
def __init__(self):
self.request = current.request
def form(self):
filedir = os.path.join(self.request.folder, 'data', 'configs/')
return SQLFORM.factory(Field('config', 'upload', uploadfolder=filedir), 
table_name='raw_config').process()


#View: upload.html
{{extend 'layout.html'}}
h1This is a form/h1
{{=form)}}




traceback
Error ticket for classtestTicket ID

127.0.0.1.2014-01-01.00-47-28.74c7a12f-c68d-4641-8807-ab14a7c8cc01
type 'exceptions.AttributeError' 'Engine' object has no attribute 'form'
Versionweb2py™Version 2.8.2-stable+timestamp.2013.11.28.13.54.07PythonPython 
2.7.3: /Applications/web2py.app/Contents/MacOS/python (prefix: 
/Applications/web2py.app/Contents/Resources)Traceback

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

Traceback (most recent call last):
  File /Applications/web2py.app/Contents/Resources/gluon/restricted.py, line 
217, in restricted
  File 
/Applications/web2py.app/Contents/Resources/applications/classtest/controllers/devices.py
 http://127.0.0.1:8000/admin/default/edit/classtest/controllers/devices.py, 
line 8, in module
  File /Applications/web2py.app/Contents/Resources/gluon/globals.py, line 
372, in lambda
  File 
/Applications/web2py.app/Contents/Resources/applications/classtest/controllers/devices.py
 http://127.0.0.1:8000/admin/default/edit/classtest/controllers/devices.py, 
line 5, in upload
AttributeError: 'Engine' object has no attribute 'form'

Error snapshot [image: 
help]http://127.0.0.1:8000/admin/default/ticket/classtest/127.0.0.1.2014-01-01.00-47-28.74c7a12f-c68d-4641-8807-ab14a7c8cc01#

type 'exceptions.AttributeError'('Engine' object has no attribute '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.


[web2py] Re: Using Modules Class - AttributeError: 'Engine' object has no attribute 'form'

2014-01-01 Thread Brando
Alan, thanks for your response.  I fixed that line and still got the error. 
 After I bounced web2py it worked, but started giving me the error again. 
 The ultimate prob was that I didn't include the #!/usr/bin/env python 
statement at the top of my module.  I added the line and all is well.

Happy new year!  Suck it 2013!





On Wednesday, January 1, 2014 5:57:32 AM UTC-8, Alan Etkin wrote:

 I'm testing using Classes within my Modules to handle a lot of the heavy 
 lifting.  I can't figure out what i'm doing wrong here.  I need an adult.

  

  def __init__(self):
 self.request = current.request
 def form(self):


 Your Engine class has a form function defined within the constructor 
 block, so you ought to de-dent your function so it becomes a class method 
 to use that syntax.

 class Engine(object):
 def __init__(self):
 ...
 def form(self):
 ...




-- 
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: I'm really struggling - Upload file, parse out variables, display in a table.

2013-12-29 Thread Brando
Simon, this is helpful.  Thank you.







On Friday, December 27, 2013 8:24:27 PM UTC-8, Simon Ashley wrote:


1. We just do it in the controller as a function . Try an .insert but 
.bulk_insert should be fine for individual records.
2. You may need a path to find the file.

 Following code is cut, pasted and sanitised from a working controller.
 (for illustration only)

 ## initiates getting files from a remote server
 def GET():
 getfile('_00_S_BTRI')
 getfile('_ST_S_ELST')


 ## reads remote files and writes to a folder on the local server
 def getfile(f3):
 import datetime
 from datetime import date, timedelta
 import urllib2
 import contextlib
 import requests
 import time
 f0 = 'http://mcs./getfile.aspx?filename='
 dr = 15 #target range

 today = datetime.date.today()
 for x in range(dr):
 start = today-timedelta(days=x)
 f1 = start.strftime('%Y%m%d')
 path = os.path.join(request.folder, 'data//')
 f4 = '.xml'
 file1 = f0 + f1 + f3 + f4
 try:
 u = urllib2.urlopen(file1)
 except urllib2.HTTPError, e:
 print str(e)
 else:
 if not 'alert' in u.read(100):
 rf = requests.get(file1)
 wf = open(path + f1 + f3 + f4, 'w')
 for line in rf:
 newline = line
 wf.write(newline)
 wf.close()


 # scans folder and writes db records of files found
 def update_PROCESS():
 import os
 path = os.path.join(request.folder, 'data\\')
 p1 = {}
 d1 = {}
 d2 = {}
 for files in os.listdir(path):
 if files.endswith(.xml):
 p1 = path + files
 dd1 = {'FILE': p1}
 d1.update(dd1)
 dd2 = {'PREFIX': p1[-8:-4]}
 d1.update(dd2)
 d1.update({'UPDATED':0})
 d1.update({'RETRIEVED':datetime.now()})
 db1.PROCESSING.bulk_insert([d1])
 db.commit()


 # processes unprocessed files
 def PROCESS():
 q = db1(db1.PROCESSING.UPDATED == 0).select()
 if q:
 for row in q:
 f1 = row.FILE
 if row.PREFIX == 'ASUM':
 try:
 attend(f1)
 d1 = db1.PROCESSING.update_or_insert((
 db1.PROCESSING.id == row.id), UPDATED = 1, PROCESSED=datetime.now())
 except:
 d1 = db1.PROCESSING.update_or_insert((
 db1.PROCESSING.id == row.id), UPDATED = 2)
 db1.commit()


 # reads file, create dict, performs bulk_insert
 def atten(f1):
 from xml.etree import ElementTree
 with open(f1, 'rt') as f:
 try:
 tree = ElementTree.parse(f)
 except:
 pass
 else:
 dh = {}
 dd = {}

 def onlyascii(char):
 if ord(char)  32 or ord(char)  127: return ''
 else: return char

 for node in tree.iter():
 if node.tag == 'ATTEN':
 dh = node.attrib

 if node.tag == 'RECORD':
 dd = node.attrib
 remap = 
 {'DATE':'RECORD_DATE','TOTAL':'RECORD_TOTAL','PUBLIC':'RECORD_PUBLIC','MEMS':'RECORD_MEMS','COSE':'RECORD_COSE'}
 dd = dict((remap[key], value) for (key, value) in 
 dd.items())
 dd.update(dh)
 db1.ATTEN.bulk_insert([dd])
 dd = {}
 db1.commit()




-- 
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: I'm really struggling - Upload file, parse out variables, display in a table.

2013-12-27 Thread Brando
Simon, could you share your code or possibly provide a w2p app?  Thanks for 
the reply.



On Friday, December 27, 2013 3:29:51 AM UTC-8, Simon Ashley wrote:

 Failing any other replies, this is what we do:

1. copy the file to the server (read then write; we get the files 
first and store them natively, outside a db, for later batch processing ) 
2. use ElementTree to parse the file to get a decent dict
3. use the dict in a bulk_insert into the db file
4. sqlform it to the view

  



-- 
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: I'm really struggling - Upload file, parse out variables, display in a table.

2013-12-27 Thread Brando
I think i'm pretty close to understanding.  I still have a few questions 
here:

*1. You need to upload the files to the server, then parse them to get each 
dict. *

The code I have to generate my dictionaries follows this format (let's 
assume there are 3 different config formats):

parse.config_type_A(file)  where parse is the class, config_type_A is 
the method, and file is the file I want to parse
parse.config_type_B(file)  where parse is the class, config_type_B is 
the method, and file is the file I want to parse
parse.config_type_C(file)  where parse is the class, config_type_C is 
the method, and file is the file I want to parse

The resulting dictionary looks something like this (this is the default 
dict before the data is pulled):

self.settings = {
'filepath': 'Not Available', #File path.
'filename': 'Not Available', #Name of the file being processed.
'hostname': 'Not Available', #What is the hostname?
'model': 'Not Available', #What type of device are we looking at?
'enable': 'Not Available', #Is there an enable password?  Is it using md5 
encryption?
'domain-name': 'Not Available', #Domain name.
'username': 'Not Available', #Are user accounts using strong encryption 
(non-Cisco 7)?
'logging': 'Not Available', #Are security and event logs being collected?
'log-server': 'Not Available', #Log Servers for centralized log correlation 
and SIEM.
'aaa': 'Not Available', #AAA is advanced radius or tacacs+ based 
authentication.
'sshv2': 'Not Available', #SSHv2 is the current protocol.
'port-security':'Not Available', #SSHv2 is the current protocol.
'intf-inside': 'Not Available', #Inside Interface: Connects to the LAN.
'intf-outside': 'Not Available', #Outside Interface: Connects to the WAN.
'any-any': 'Not Available', #Any-Any Rules can allow overly permissive 
traffic.
'access-group': 'Not Available' #The access-group line ties an ACL to an 
interface.
}

What I end up with is dictionary for each config file that has all the 
relevant settings I am interested in.  I'd like to use a class to parse, 
but I'm not sure if the class should be defined in a  model, controller or 
module.

   1. Where should I define the class?
   2. If I want to insert the self.settings dict (above) is this the 
   correct syntax I need to follow (from your link)?
   
db.config_settings.bulk_insert([{'name':'Alex'}, {'name':'John'}, 
{'name':'Tim'}])

 
  3. Is there a different insert statement that would let me say 
something like. db.config_settings.insert(self.settings) ?




*2. My feeling that you may be having issues with parsing the uploaded 
file.*

Why doesn't the following controller code work? (it gives me the following 
error: type 'exceptions.TypeError'(coercing to Unicode: need string or 
buffer, Row found))  What should I be using to open the files?

def showconfig():
files = db().select(db.config_file.ALL)
for file in files:
if 'ASA Version' in open(file).read():
return dict(file=file)
else:
return dict(Not a Firewall)









On Friday, December 27, 2013 3:07:07 PM UTC-8, Simon Ashley wrote:

 A little difficult to share to code (done for a client, its similar and 
 but not exactly what you're doing i.e. maybe a lot more complicated than 
 what you need), but I think you're almost there. 

 You need to upload the files to the server, then parse them to get each 
 dict. My understanding is that you don't have issues generating the dict 
 and there it should be a simple bulk_insert ...  
 http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer?search=bulk_insert
 .

 My feeling that you may be having issues with parsing the uploaded file 
 and you should be able to get the file name/ location for parsing routines 
 by following 
 http://web2py.com/books/default/chapter/29/07/forms-and-validators?search=upload#SQLFORM-and-uploadshttp://www.google.com/url?q=http%3A%2F%2Fweb2py.com%2Fbooks%2Fdefault%2Fchapter%2F29%2F07%2Fforms-and-validators%3Fsearch%3Dupload%23SQLFORM-and-uploadssa=Dsntz=1usg=AFQjCNGXDIOqfpU4LwSIlWV5tY9VvdvhEw


-- 
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] I'm really struggling - Upload file, parse out variables, display in a table.

2013-12-26 Thread Brando
I've watched every web2py video I could find and read through all the 
material.  Still not getting it.  I'm new to web2py and webapps.  

Here's what I want to do:

1. Have a page to upload multiple configuration files (plaintext.txt)
2. Parse items out of those files and store the results in the sqlite 
database.  
3. Retrieve the stored items (variables) and show them in a table.  

For Example...let's say I upload the following files:

document_a.txt
grep_a Merry

Blah blah blah

Words words words

grep_b Christmas

More Words More Words

grep_d I need help

document_b.txt

grep_a Halloween

Blah blah blah

Words words words

grep_b Easter

More Words More Words

grep_c This document has a line with grep_c the other one doesn't

For each file i will be parsing out variable_a, variable_b, variable_c,  
variable_d which will essentially be grepping out the grep_a, b, c  d 
statements (via regex mostly). 

In my stand alone python script I do this by defining a class with several 
methods.  The results are stored in a dictionary.  So for example:

document_a.parse() would yield an object that contains a dictionary with 
the different settings I want to extract.  I can then do what I want with 
them.  

I have no idea how to do this within the context of a web app using a 
database.








--
That's what I want, here's what I've done so far.

Model: db.py
from gluon.tools import Auth
db = DAL(sqlite://storage.sqlite)
auth = Auth(db)
auth.define_tables(username=True)

db.define_table('config_file',
   #Field('title', unique=True),
   Field('file', 'upload', requires=IS_NOT_EMPTY()),
   format = '%(title)s')


Controller: default.py
def showconfig():
files = db().select(db.config_file.ALL)
return dict(files=files)


View: default/showconfig.html
{{extend 'layout.html'}}
h1
Current Files
/h1
ul
{{for file in files:}}
{{=LI(A(file, _href=URL('showconfig')))}}
{{pass}}
/ul


I then upload a few files using the database manager built in.

https://lh3.googleusercontent.com/-kHe6iJKI9_4/UrxxS8N_m9I/DQ4/LoNw-sLgzqA/s1600/Contour-2.png






















and then call the showconfig.html view which prints a list of the 
uploaded file names (which web2py has changed).

https://lh6.googleusercontent.com/-k9QApJ0V4Cw/UrxwlnwnsxI/DQw/q89QuaJ2YkA/s1600/Contour-1.png
https://lh6.googleusercontent.com/-k9QApJ0V4Cw/UrxwlnwnsxI/DQw/q89QuaJ2YkA/s1600/Contour-1.png
https://lh6.googleusercontent.com/-k9QApJ0V4Cw/UrxwlnwnsxI/DQw/q89QuaJ2YkA/s1600/Contour-1.png



Really sorry for the newb questions, but I can't find any good web2py 
tutorials that show uploading files, parsing the data/putting that data 
into a db, and then sending that data to the screen.


   1. Where do I define the variables to extract the info I want (regex 
   grepping mostly)?..I assume in a controller?
   2. How do I then get that data into the sqlite database stored under the 
   corresponding document?
   3. How do I then get select that info out of the database for a specific 
   document and send it to the screen in the form of a table?
   


Any guidance you can give is greatly appreciated.  If anyone has a sample 
web2py app that can do this I can reverse engineer it, but i haven't found 
anything out there that does this.


Merry Christmas!





-- 
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: Distributing as a Binary - External Libraries?

2013-12-16 Thread Brando
Is it possible to configure web2py so that when you open the binary it 
automatically launches web2py on pre-configured port (click the binary and 
the web page comes updon't need to start the server)?  Also, I noticed 
the new build has the web2py branding on the start server dialog box.  Is 
it possible to remove that?







On Sunday, December 15, 2013 4:33:45 AM UTC-8, Niphlod wrote:

 err... actually it uses bbfreeze (for win) + py2app for mac ^_^


 On Sunday, December 15, 2013 5:57:36 AM UTC+1, Massimo Di Pierro wrote:

 Actually web2py uses py2exe+py2app, not pyinstaller. Perhaps we should.

 Anyway, you are right that if you installed BeautifulSoup, it will not 
 ship with your apps. But, for pure python packages (and I think 
 BeautifulSoup is pure python), if you copy the package under your app 
 modules/ folder, then it will ship with it.

 Massimo



 On Saturday, 14 December 2013 19:46:59 UTC-6, Brando wrote:


 Let's say I package my app via this method: 
 http://web2py.com/AlterEgo/default/show/270.  If my underlying python 
 contains external libraries, will the program work?  Let's say I give the 
 app to someone who doesn't have the BeautifulSoup library installed.  Am I 
 correct in assuming the program would not work?  Mac or Windows platform.

 I know Web2py uses pyinstaller, does that handle the external 
 dependencies automatically?  I am new to Web2pysorry if this is a dumb 
 question.



-- 
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] Distributing as a Binary - External Libraries?

2013-12-14 Thread Brando

Let's say I package my app via this method: 
http://web2py.com/AlterEgo/default/show/270.  If my underlying python 
contains external libraries, will the program work?  Let's say I give the 
app to someone who doesn't have the BeautifulSoup library installed.  Am I 
correct in assuming the program would not work?  Mac or Windows platform.

I know Web2py uses pyinstaller, does that handle the external dependencies 
automatically?  I am new to Web2pysorry if this is a dumb question.

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