[web2py] Re: web2py admin app

2017-04-14 Thread Michael Beller
Yes - you can store sessions in a database rather than the filesystem or 
cookies.

Here is some info:
http://www.web2py.com/books/default/chapter/29/04/the-core#session



On Wednesday, April 12, 2017 at 6:37:40 AM UTC-7, James Holstead wrote:
>
> I was testing clustering in our test environment and noticed the admin app 
> didn't behave well. Is there a way to push admin sessions to a pG database?
>
> -v/r
> J
>

-- 
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: CKEditor CDN

2017-04-14 Thread Michael Beller
I created a custom css file and limited the tags available in the example I 
posted, you can remove those arguments and you'll get the ckeditor defaults.

If you're using SQLFORM then the text field is updated automatically along 
with any other form field - there's no special processing you have to 
handle.  If it's a custom form, then you can access the form field in 
form.vars.

I just looked and the fields I use with ckeditor I define as follows:

Field(
 'body', 'text', length=7,
 represent=lambda v, r: XML(v, sanitize=True)
),



On Friday, April 14, 2017 at 10:44:30 AM UTC-7, Alex Glaros wrote:
>
> It's looking better Michael but based on code example below, could you 
> please help with:
>
> 1. Remind me how to get the updated text from textarea back into the table
> 2. the fromat_tags parm,, seems that purpose is to limit what user can do? 
>  If yes, don't seem to make the rest of the tags disappear.
>
> https://cdn.ckeditor.com/4.6.2/standard/ckeditor.js
> ">
>
> {{=person.summary_self_description}}
>
> 
>   CKEDITOR.replace('z', {
> height: 500,
> contentsCss: '{{=URL('static','css/contract.css')}}',
> format_tags: 'p;h1;h2;h3;h4;div',
>   });
> 
>
>
> thanks,
>
> Alex
>

-- 
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: CKEditor CDN

2017-04-14 Thread Michael Beller
I add this to my base template:


  // Replace the textarea with a CKEditor instance (replace 'content_body' with 
the id of your textarea)
  CKEDITOR.replace('content_body', {
height: 500,
contentsCss: '{{=URL('static','css/contract.css')}}',
format_tags: 'p;h1;h2;h3;h4;div',
  });



On Thursday, April 13, 2017 at 11:51:55 AM UTC-7, Alex Glaros wrote:
>
> CKEditor is now available from CDN: http://cdn.ckeditor.com/
>
> can someone please provide example of how to integrate into w2p?
>
> is it safe, if not, way to sanitize?
>
> thanks,
>
> Alex Glaros
>

-- 
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: Making application looks better.

2017-04-14 Thread Michael Beller
I created my own scaffold app based on the AdminLTE layout, similar to what 
António did in terms of layout but replaced the Welcome app.  I use this 
for each new app instead of the Welcome app as my base app:

https://github.com/mjbeller/web2py-starter




On Thursday, April 13, 2017 at 3:38:52 AM UTC-7, akshay0...@gmail.com wrote:
>
> Hello web2py team,
>   I just started using web2py for my application. When i am going 
> deeper with my application, i am facing issues. The problem is that i have 
> a basic idea about HTML tags only. I have never worked with CSS, Bootstrap, 
> ajax, javascript etc. As of now i am able to add basic functionality to my 
> application like creating forms which are dealing with database or printing 
> things via creating simple views. Real problem is coming when i want to 
> make my webpages look beautiful.
> For instance suppose i want to show few things in left side of my webpage 
> with different background color like a side menu, few things in center of 
> the webpage with diff background color.(this example i am giving to show 
> that i am at complete beginner in web development)
>  I am not getting whether i have to create my own css files and use them 
> or extending existing or make changes in existing files. As of now i don't 
> have idea about things like sidebars and all which are used in existing 
> layout files or CSS files.
> So my question is how should i approach things? Do i need to have a 
> complete understanding of CSS, ajax and bootstrap etc? or if i get basic 
> idea of things then it will work? How should i move forward?
>
> Thanks.
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: custom forms

2016-11-08 Thread Michael Beller
The online web2py book is a great place to start:
http://web2py.com/book

Web2py will "automatically" generate a form (with dropdowns, radio buttons, 
etc.) and the form field validation based on the database model (along with 
the create, read, and edit forms).

The forms chapter I think provides everything you need:
http://web2py.com/books/default/chapter/29/07/forms-and-validators


On Monday, November 7, 2016 at 8:46:06 PM UTC-5, Tom Schuerlein wrote:
>
> I am new to Web2Pyl. I am looking for a help building a custom form. 
>  Specifically how to pass db fields to the HTML View when building the 
> code.  I've been looking for a tutorial on building custom forms with no 
> luck.  I need to be able to have several input fields on one row; with a 
> mixture of radio buttons, pull downs and text fields.  Any direction would 
> be greatly appreciated. 
>

-- 
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: Push Notifications

2016-11-08 Thread Michael Beller
I've been thinking about trying https://pusher.com/


On Wednesday, November 2, 2016 at 6:32:54 PM UTC-4, David wrote:
>
> Hello, 
>
> My website allows users to send messages to one another; however, the only 
> way to see their new messages is to refresh the page. Is there any way to 
> notify the user via any method? 
>
> Thanks for your time
>
>

-- 
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: Bootstrap datepicker plugin

2016-07-10 Thread Michael Beller
I'm using bootstrap-datepicker.js also with these changes, not sure it's as 
robust but works and I use it for multiple date formats such as this:

Field('origination_date', 'date',
  widget=datepicker_widget(format='mm/', min_view_mode='months'
), requires=IS_DATE('%m/%Y')),  # example using just mm/

added widget
def datepicker_widget(**settings):

def widget(field, value, **attributes):
default = {'value': value}
attributes = FormWidget._attributes(field, default, **attributes)
attributes['_class'] = 'form-control date'

# default format “mm/dd/”
data_attributes = {}
data_attributes['date-format'] = '-mm-dd'
for item in settings.iteritems():
data_attributes['date-'+item[0].replace('_', '-')] = item[1]

return INPUT(
data=data_attributes,
**attributes
)

return widget


added this to my layout (I actually place this in a .js file I then add to 
layout.html:
$('input.date').datepicker({
 todayBtn: "linked",
 autoclose: true,
 todayHighlight: true
});

I removed for web2py_ajax.html:
# response.files.insert(1,URL('static','css/calendar.css'))
# response.files.insert(2,URL('static','js/calendar.js'))


On Wednesday, July 6, 2016 at 6:59:02 PM UTC-4, Donald McClymont wrote:
>
> This now seems to be along the correct lines  - the issue I had was a 
> styling conflict with calendar.css file in web2py for the hour class being 
> set to 2em and my hack for now to fix was to append the following to the 
> std datetimepicker.css that can  be downloaded however not sure if there is 
> a better way.
>
> /* To revernt font 2em in web2py calendar component */
> .hour, .minute {font-size: 14px;}
>
>
>
>
> On Wednesday, July 6, 2016 at 1:17:59 PM UTC+1, Donald McClymont wrote:
>>
>> This is nice and a great improvement for dates.  I thought I could easily 
>> replicate for datetime by using this which seems to be a fork of the 
>> original to allow time input as well
>>
>>
>> http://www.malot.fr/bootstrap-datetimepicker/demo.php?utm_source=siteweb_medium=demo_campaign=Site%2BWeb
>>
>> https://github.com/smalot/bootstrap-datetimepicker
>>
>> however it seems to not be formatting the time selection correctly for 
>> some reason and may well need some adjustment to update with the script.  I 
>> will continue to look at getting working but if anyone else can provide 
>> some hints on how to do this then would be good to have both options 
>> available in some manner.
>>
>> Donald
>>
>>
>> On Tuesday, July 5, 2016 at 5:10:44 PM UTC+1, Ron Chatterjee wrote:
>>>
>>> I had my fair share of evaluation. Which looks better?
>>>
>>>
>>>
>>> On Monday, May 11, 2015 at 5:01:36 PM UTC-4, villas wrote:

 Thanks Leonel.

 BTW in your first post you said:   
 Field('birthdate', 'date', widget=bsdatepicker_widget) 

 It should be with brackets at the end:
 Field('birthdate', 'date', widget=bsdatepicker_widget()) 

>>>

-- 
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: save the original value of one field in another field

2016-07-10 Thread Michael Beller
For n2, you could try only updating if n2 was not empty.  This is not 
tested but something like ...

Field('n2', 'integer', compute=lambda r: r.start_number if not r.n2 else 
None)


On Sunday, July 10, 2016 at 4:38:33 PM UTC-4, ahz...@gmail.com wrote:
>
> In my application a user enters a boolean value, and later the user can 
> modify the value*.* I want to save the original value in another field, 
> and the user shouldn't be able to see or alter the original value.
>
> Based on the stackoverflow 
> 
>  
> conversation I tried a simple table with two  methods
> db.define_table('mytable',
> Field('start_number', 'integer', requires=IS_NOT_EMPTY()),
> Field('n1', 'integer', default=request.post_vars.start_number),
> Field('n2', 'integer', compute=lambda r: r.start_number)
> )
>
>
>
> Then I used the database administration to insert a value of 5, but *n1 *had 
> a value of zero (instead of 5).
>
> While *n2 *started with the value of 5, whenever I modified *start_number*, 
> it also modified *n2*.
>
> By the way, I wish I had web2py in 2003 when I started a bigger web 
> application.
>

-- 
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: jQuery.web2py.component "Synchronous XMLHttpRequest ..." error

2016-06-30 Thread Michael Beller
arghh ... this one was a pain.  For the record:

I had created a listener on the modal's show event to load the component 
(using the code below).  Datepicker also triggers an event it calls show. 
Since it was loading within the scope of the modal, it would trigger the 
show listener when it was opened. After triggering another show, it would 
use the parent URL, which replaced the page.


I still don't fully understand (so my description may not be complete) but 
attaching the listener to the link click event rather than the modal show 
event solved the problem.


On Wednesday, June 29, 2016 at 1:21:31 AM UTC-4, Michael Beller wrote:
>
> I'm loading an edit form in a boostrap modal 
> using  jQuery.web2py.component().
> I'm using bootstrap-datepicker.js for my date fields.
> The edit form works outside the modal.
>
> When I load the edit form inside the modal, everything works fine except 
> for the datepicker. When I click on the text field with the datepicker, the 
> console shows the error below and then just replaces the entire page with 
> just the year, e.g., "2016":
> Synchronous XMLHttpRequest on the main thread is deprecated because of 
> its detrimental effects to the end user's experience. For more help, 
> check https://xhr.spec.whatwg.org/.
>
> I'm loading the modal with (link contains the URL):
>   jQuery.web2py.component(link,'modal-body');
>   $('input.date').datepicker();
>
> Has anybody encountered this?
>
> I've seen some other mentions of similar problems related to calendar.js 
> so I don't think this is specific to datepicker.
>

-- 
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] jQuery.web2py.component "Synchronous XMLHttpRequest ..." error

2016-06-28 Thread Michael Beller
I'm loading an edit form in a boostrap modal 
using  jQuery.web2py.component().
I'm using bootstrap-datepicker.js for my date fields.
The edit form works outside the modal.

When I load the edit form inside the modal, everything works fine except 
for the datepicker. When I click on the text field with the datepicker, the 
console shows the error below and then just replaces the entire page with 
just the year, e.g., "2016":
Synchronous XMLHttpRequest on the main thread is deprecated because of its 
detrimental effects to the end user's experience. For more help, check 
https://xhr.spec.whatwg.org/.

I'm loading the modal with (link contains the URL):
  jQuery.web2py.component(link,'modal-body');
  $('input.date').datepicker();

Has anybody encountered this?

I've seen some other mentions of similar problems related to calendar.js so 
I don't think this is specific to datepicker.

-- 
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: how to debug weasyprint error - failed to load a library: cairo / cairo-2

2016-06-15 Thread Michael Beller
Just for the record ... I solved this by deleting the virtualenv and all 
user installed libraries (using 'pip uninstall ...').  Then simply 
reinstalling 'pip install --user weasyprint==0.27'

I never found the root cause of the problem.  Here is the conversation on 
PAW with some more info if anybody in the future needs it ...
https://www.pythonanywhere.com/forums/topic/4898/#id_post_21876


On Tuesday, June 14, 2016 at 3:57:34 PM UTC-7, Michael Beller wrote:
>
> I posted this on the pythonanywhere (PAW) forums also but I think it may 
> be web2py specific (or at least specific to the PAW/web2py combination) ...
>
> I'm using weasyprint to generate a PDF.  It's working on my local dev 
> environment and my PAW personal account.
>
> On a new PAW account it fails on:
> from weasyprint import HTML, CSS
>
> with the error:
> OSError: dlopen() failed to load a library: cairo / cairo-2
>
> On the new PAW account, the import works in a python console (just not 
> from within the web2py app).
>
> As far as I can tell, the original and new PAW accounts are identical.  I 
> also recently create a new virtualenv on the new account to try and isolate 
> the library/package that may be out of sync but I'm getting the same error.
>
> Any ideas how to debug?
>

-- 
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] how to debug weasyprint error - failed to load a library: cairo / cairo-2

2016-06-14 Thread Michael Beller
I posted this on the pythonanywhere (PAW) forums also but I think it may be 
web2py specific (or at least specific to the PAW/web2py combination) ...

I'm using weasyprint to generate a PDF.  It's working on my local dev 
environment and my PAW personal account.

On a new PAW account it fails on:
from weasyprint import HTML, CSS

with the error:
OSError: dlopen() failed to load a library: cairo / cairo-2

On the new PAW account, the import works in a python console (just not from 
within the web2py app).

As far as I can tell, the original and new PAW accounts are identical.  I 
also recently create a new virtualenv on the new account to try and isolate 
the library/package that may be out of sync but I'm getting the same error.

Any ideas how to debug?

-- 
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: [SOLVED] Custom form not accepted (formkey missing)

2016-05-08 Thread Michael Beller
Thanks Carlos!  I just came across this and your post helped me.

On Friday, March 11, 2016 at 5:09:50 AM UTC-8, Carlos Kitu wrote:
>
> Hi guys, I don't show up here too often because all the issues I find use 
> to be solved here. Good job.
>
> Today I was going nuts with one issue, and I would like to share my 
> findings for other developer's sake.
>
> I was generating a form with SQLFORM.factory:
> form= SQLFORM.factory(...)
>
> In the controller, I was creating a custom form for the view, something 
> like:
> custom_form= CAT(form.custom.begin,
>  ... custom fields...
>  form.custom.submit,
>  form.custom.end)
>
> The custom_form displayed fine in the browser, but when I submitted the 
> form, it wasn't accepted at:
> if form.process().accepted:
>response.flash='Accepted'
>
> Digging in the SQLFORM and FORM classes I learnt a lot about them, and 
> finally I realized the origin of the problem:
>
>- form.process() requires a hidden field (*formkey*) with valid data 
>for security reasons. That field uses to be in form.custom.end
>- that field was missing in my custom_form
>- The reason was that when you create a form with SQLFORM.factory, 
>initially, there is no hidden *formkey* field in form.custom.end, just 
>a humble 
>- That *formkey* hidden field gets inserted in form.custom.end when 
>you call form.process()
>- That means that form.process() must be called before generating the 
>view, in order to have a formkey in form.custom.end. My failure was to try 
>to create custom_form = CAT() before calling form.process()
>- Should I have use {{=form.custom.end}} straight in the view, I would 
>have had no problem.
>- As I had quite a complex form, I preferred to have it generated in 
>the controller, and I just had to put the if form.process().accepted: 
> before programatically generating 
>the custom_form and everything worked fine
>
> Thanks a lot guys for this helpful group.
> Best regards.
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: How to integrate SendGrid in Web2py ?

2016-04-28 Thread Michael Beller
I haven't used yagmail, I only looked quickly but I didn't see an advantage 
of yagmail over the web2py mail functions.

The bootply layout below looks great - I don't see any reason that wouldn't 
work.

Do you want to receive email into the app?  I didn't see how yagmail 
supports inboud email, that's where you need a service to route email to a 
webhook that you define.  Services like sendgrid, mandrill, and mailgun 
will also parse the headers, body, and attachments and POST them to your 
webhook where you can easily process and 'add' to your inbox.

They each have different methods to track related emails, e.g., the 
response to an outbound email so you know if somebody responded.

On Thursday, April 28, 2016 at 11:38:07 AM UTC-4, Ron Chatterjee wrote:
>
> Have anyone used yagmail?
> http://kootenpv.github.io/2016-04-24-yagmail 
> 
>
>
>
>
> And regarding the outlook like mailbox interface as Michael mentioned, 
> Michael, we can simply do this. Right?
> http://www.bootply.com/XXmcPas41w
>
>
> And for the code use sandgrid or yagmail or whatever. for example if 
> request.args(i) is 0, inbox is "unread" and it is, its been read. Mails 
> that's been sent goes to the send folder etc... Am I wrong?
>
>
>
>
>
> On Friday, April 22, 2016 at 2:34:54 AM UTC-4, Mirek Zvolský wrote:
>>
>> Not sure if I properly understand your question.
>> But..
>>
>> I use this in starting web in such easy way:
>> - Virtual server Debian, no SMTP/POP3 installed at all,
>> - web2py app sends what is necessary through SparkPost,
>> - all incomming mails for the domain I have redirected in hosting admin 
>> settings (at forpsi) to my personal e-mail address.
>>
>>

-- 
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] new Starter app (alternative to Welcome app)

2016-04-27 Thread Michael Beller
It was fixed in the repo, I just updated the demo site - can you try again?

On Wed, Apr 27, 2016 at 11:35 AM, Antonio Salazar <asalaza...@gmail.com>
wrote:

> The login menu dropdown also becomes white on white on small screen sizes.
> Looks really nice on those screens, though.
>
> On Monday, April 25, 2016 at 6:27:14 PM UTC-5, Michael Beller wrote:
>>
>> Yes - thanks.  I knew about that bug, just fixed it.  The background and
>> font were both white.  Can you check now?
>>
>> On Mon, Apr 25, 2016 at 6:07 PM, Ron Chatterjee <achatte...@gmail.com>
>> wrote:
>>
>>> Have you tested this starter app on mobile. When I hover over "log in"
>>> from a 9 inch tablet or small phone, I see a blank white screen for log in
>>> till I start scrolling, I see the other menu one by one.
>>>
>>>
>>>
>>> On Friday, March 25, 2016 at 12:39:53 PM UTC-4, Alessio Varalta wrote:
>>>>
>>>> Is great! I think is a good choose to introduce a functionality that in
>>>> admin console you can choose this as starter
>>>>
>>>> On Friday, 25 March 2016 11:09:38 UTC+1, Ramos wrote:
>>>>>
>>>>> This starter is sooo cool.
>>>>> Its was time we had something like this.
>>>>>
>>>>>
>>>>>
>>>>> 2016-03-24 19:51 GMT+00:00 Ron Chatterjee <achatte...@gmail.com>:
>>>>>
>>>>>> Its all good. Just asked.
>>>>>>
>>>>>>
>>>>>> On Thursday, March 24, 2016 at 3:33:00 PM UTC-4, Michael Beller wrote:
>>>>>>>
>>>>>>> No Avatar field yet!  It's hardcoded in the template.  It should be
>>>>>>> easy to add a custom field to the auth_user table following these
>>>>>>> instructions:
>>>>>>>
>>>>>>> http://web2py.com/books/default/chapter/29/09/access-control?search=auth_user#Customizing-Auth
>>>>>>>
>>>>>>> Then you can upload an avatar using the user profile page.
>>>>>>>
>>>>>>> I haven't done this with images but it should be straight forward
>>>>>>> (it's on my todo list!)
>>>>>>>
>>>>>>> You can also designate a dedicated folder for the avatar uploads so
>>>>>>> they're not commingled with other upload files ...
>>>>>>>
>>>>>>> http://web2py.com/books/default/chapter/29/07/forms-and-validators?search=upload#SQLFORM-and-uploads
>>>>>>>
>>>>>>> On Thursday, March 24, 2016 at 3:03:41 PM UTC-4, Ron Chatterjee
>>>>>>> wrote:
>>>>>>>>
>>>>>>>> I am sorry, I was having some problem downloading the latest
>>>>>>>> version so everything is good. Quick question Michael, how does someone
>>>>>>>> change the profile picture? There is a avatar field?
>>>>>>>>
>>>>>>>> On Thursday, March 24, 2016 at 11:56:27 AM UTC-4, Michael Beller
>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>> The appconfig in 2.13 has a problem with strings separated by
>>>>>>>>> comma's in the appconfig.ini file.  Starter app uses 2.14.1
>>>>>>>>>
>>>>>>>>> You can either install 2.14.1 or just change ...
>>>>>>>>>
>>>>>>>>> line 34 in initialize.py:
>>>>>>>>> for group in myconf.get('admin_user.auth_groups'):
>>>>>>>>>
>>>>>>>>> could replace with
>>>>>>>>> for group in ['Admin', 'Customer Service', 'Operations']:
>>>>>>>>>
>>>>>>>>> or just change the function to create the Admin group which is all
>>>>>>>>> that's needed.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Thu, Mar 24, 2016 at 11:20 AM, Ron Chatterjee <
>>>>>>>>> achatte...@gmail.com> wrote:
>>>>>>>>>
>>>>>>>>>> Not sure its ready to be posted. I just downloaded the app and I
>>>>>>>>>> don't see any initialization. My experience...it seems have some 
>>>>>>>&

Re: [web2py] new Starter app (alternative to Welcome app)

2016-04-25 Thread Michael Beller
Yes - thanks.  I knew about that bug, just fixed it.  The background and
font were both white.  Can you check now?

On Mon, Apr 25, 2016 at 6:07 PM, Ron Chatterjee <achatterjee...@gmail.com>
wrote:

> Have you tested this starter app on mobile. When I hover over "log in"
> from a 9 inch tablet or small phone, I see a blank white screen for log in
> till I start scrolling, I see the other menu one by one.
>
>
>
> On Friday, March 25, 2016 at 12:39:53 PM UTC-4, Alessio Varalta wrote:
>>
>> Is great! I think is a good choose to introduce a functionality that in
>> admin console you can choose this as starter
>>
>> On Friday, 25 March 2016 11:09:38 UTC+1, Ramos wrote:
>>>
>>> This starter is sooo cool.
>>> Its was time we had something like this.
>>>
>>>
>>>
>>> 2016-03-24 19:51 GMT+00:00 Ron Chatterjee <achatte...@gmail.com>:
>>>
>>>> Its all good. Just asked.
>>>>
>>>>
>>>> On Thursday, March 24, 2016 at 3:33:00 PM UTC-4, Michael Beller wrote:
>>>>>
>>>>> No Avatar field yet!  It's hardcoded in the template.  It should be
>>>>> easy to add a custom field to the auth_user table following these
>>>>> instructions:
>>>>>
>>>>> http://web2py.com/books/default/chapter/29/09/access-control?search=auth_user#Customizing-Auth
>>>>>
>>>>> Then you can upload an avatar using the user profile page.
>>>>>
>>>>> I haven't done this with images but it should be straight forward
>>>>> (it's on my todo list!)
>>>>>
>>>>> You can also designate a dedicated folder for the avatar uploads so
>>>>> they're not commingled with other upload files ...
>>>>>
>>>>> http://web2py.com/books/default/chapter/29/07/forms-and-validators?search=upload#SQLFORM-and-uploads
>>>>>
>>>>> On Thursday, March 24, 2016 at 3:03:41 PM UTC-4, Ron Chatterjee wrote:
>>>>>>
>>>>>> I am sorry, I was having some problem downloading the latest version
>>>>>> so everything is good. Quick question Michael, how does someone change 
>>>>>> the
>>>>>> profile picture? There is a avatar field?
>>>>>>
>>>>>> On Thursday, March 24, 2016 at 11:56:27 AM UTC-4, Michael Beller
>>>>>> wrote:
>>>>>>>
>>>>>>> The appconfig in 2.13 has a problem with strings separated by
>>>>>>> comma's in the appconfig.ini file.  Starter app uses 2.14.1
>>>>>>>
>>>>>>> You can either install 2.14.1 or just change ...
>>>>>>>
>>>>>>> line 34 in initialize.py:
>>>>>>> for group in myconf.get('admin_user.auth_groups'):
>>>>>>>
>>>>>>> could replace with
>>>>>>> for group in ['Admin', 'Customer Service', 'Operations']:
>>>>>>>
>>>>>>> or just change the function to create the Admin group which is all
>>>>>>> that's needed.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Thu, Mar 24, 2016 at 11:20 AM, Ron Chatterjee <
>>>>>>> achatte...@gmail.com> wrote:
>>>>>>>
>>>>>>>> Not sure its ready to be posted. I just downloaded the app and I
>>>>>>>> don't see any initialization. My experience...it seems have some issues
>>>>>>>> still (see the attached pic) . When I tried to register, I get this 
>>>>>>>> error:
>>>>>>>>
>>>>>>>>
>>>>>>>> Traceback *(*most recent call last
>>>>>>>> *):   *File "…\web2py\gluon\restricted.py"*, *line 227*, in *
>>>>>>>> restricted
>>>>>>>> *exec *ccode *in *environment
>>>>>>>>   File" …applications/starter/controllers/default.py"
>>>>>>>> <http://127.0.0.1:8000/admin/default/edit/starter/controllers/default.py>*,
>>>>>>>> *line 91*, in <*module
>>>>>>>> *>   *File "…web2py\gluon\globals.py"*, *line 412
>>>>>>>> *, in  self.*_caller *= lambda *f*: *f
>>>>>>>> *()   *File …/starter/controllers/default.py"
>

[web2py] Re: Changing color of field

2016-04-21 Thread Michael Beller
There are a couple of ways to do this.  I've found it easier to just add to 
my models rather than use javascript ...

If you have a date field in your model ...

Field('deadline', 'date', default=request.now + (week * 4), label=T(
'Deadline')),

you can add a represent that generates a span ...

db.task.deadline.represent = lambda v, row: \
SPAN(prettydate(v), _class='overdue' if v and v < datetime.date.today() 
else None)

then in your css just add the style you want, something like this ...

/* Deadline styles */
.overdue {background-color: red; color:white; padding:5px;}


On Thursday, April 21, 2016 at 9:08:23 AM UTC-4, Md Anam Raihan wrote:
>
> I am creating task management app and i want to change color of field if 
> deadline is completed then how to do it using javascript also i am facing 
> problem in extracting datetime from my field??
>

-- 
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] what's the best approach for view and update forms for multiple tables?

2016-04-21 Thread Michael Beller
I think process().accepted and validate are the same for .factory() since 
there is no dbio.  Without either, the form vars wasn't populating the form 
(it works with both .validate() and .process() but not with neither).

The update row below updates the investor table after validation (which is 
the investor row retrieved at the beginning of the function used to 
populate the form).

On Thursday, April 21, 2016 at 2:18:24 PM UTC-4, Richard wrote:
>
> Also not sure what investor contains here :
>
>  if form.validate():
> investor.update_record(**db.investor._filter_fields(form.vars))
>
> Is it a row or the db table (db.investor)??
>
> If it is a row, I am not sure if your issue wouldn't come from the way you 
> use update_record() as it make a row update hit the database... So, maybe 
> you try to update another record than the one you think you are updating...
>
> try :
>
> db(db.investor.id == 
> form.vars.investor_id_field_name).update(...filter_fields...)
>
> You need a way to specify the record you are updating...
>
> On Thu, Apr 21, 2016 at 2:12 PM, Richard Vézina <ml.richa...@gmail.com 
> > wrote:
>
>> I am not sure what the purpose of this :
>>
>>for f in db.investor.fields:
>> form.vars[f] = investor[f]
>> for f in db.auth_user.fields:
>> form.vars[f] = user[f]
>>
>>
>> And why not using
>>
>>   
>>
>> if form.process().accepted:
>>
>>
>> Richard
>>
>> On Thu, Apr 21, 2016 at 2:05 PM, Richard Vézina <ml.richa...@gmail.com 
>> > wrote:
>>
>>> I am not sure, but .factory() should accept readonly=True for read 
>>> form...
>>>
>>> Are you sure you have not any fields with the same name in both tables?
>>>
>>> On Thu, Apr 21, 2016 at 2:00 PM, Richard Vézina <ml.richa...@gmail.com 
>>> > wrote:
>>>
>>>> Michael,
>>>>
>>>> About displaying value use default = when you create input field it 
>>>> should be all what you need...
>>>>
>>>> About the other problem I don't get it... You should be able to update 
>>>> a record email/username as long as the new value is unique...
>>>>
>>>> Richard
>>>>
>>>> On Wed, Apr 20, 2016 at 11:43 PM, Michael Beller <mjbe...@gmail.com 
>>>> > wrote:
>>>>
>>>>> Thanks Richard, I should have provided more details.
>>>>>
>>>>> When I tried to create a form using SQLFORM.factory for two tables 
>>>>> (including auth_user), I would get an error that the auth_user email and 
>>>>> username existed even if I wasn't updating those fields.  It appears that 
>>>>> the validator to assure those fields are unique does not exclude the 
>>>>> current values.  I was able to fix this by adding these before calling 
>>>>> SQLFORM.factory:
>>>>>
>>>>> emails = db(db.auth_user.email != user.email)
>>>>> db.auth_user.email.requires = IS_NOT_IN_DB(emails, 
>>>>> 'auth_user.email')
>>>>> usernames = db(db.auth_user.username != user.username)
>>>>> db.auth_user.username.requires = IS_NOT_IN_DB(usernames, 
>>>>> 'auth_user.username')
>>>>>
>>>>> My entire function to create an edit form for two tables:
>>>>>
>>>>> def edit():
>>>>> 
>>>>> investor = db.investor(request.args(0)) or redirect(URL('index'))
>>>>> user = db.auth_user(investor.auth_user)
>>>>>
>>>>> emails = db(db.auth_user.email != user.email)
>>>>> db.auth_user.email.requires = IS_NOT_IN_DB(emails, 
>>>>> 'auth_user.email')
>>>>> usernames = db(db.auth_user.username != user.username)
>>>>> db.auth_user.username.requires = IS_NOT_IN_DB(usernames, 
>>>>> 'auth_user.username')
>>>>>
>>>>> db.auth_user.password.writable = False
>>>>> db.investor.auth_user.readable = False
>>>>> db.investor.auth_user.writable = False
>>>>>
>>>>> form = SQLFORM.factory(db.auth_user, db.investor)
>>>>>
>>>>> for f in db.investor.fields:
>>>>> form.vars[f] = investor[f]
>>>>> for f in db.auth_user.fields:
>>>>> form.vars[f] = user[f]
>>>>>
>>>>> if form.validate():
>>>

Re: [web2py] what's the best approach for view and update forms for multiple tables?

2016-04-21 Thread Michael Beller
you're right - I probably could have just iterated through each field and 
set the default before calling .factory() with readonly - I didn't try 
that.  The method I came up with is very simple so I'm ok with it now.

for the email/username, .factory() tries to validate the fields even if 
they don't change and it includes all existing values, including the 
current row, so the validation fails.  I avoid that by specifying the list 
of values for the 'not_in_db' validator to exclude the current row.


On Thursday, April 21, 2016 at 2:05:30 PM UTC-4, Richard wrote:
>
> I am not sure, but .factory() should accept readonly=True for read form...
>
> Are you sure you have not any fields with the same name in both tables?
>
> On Thu, Apr 21, 2016 at 2:00 PM, Richard Vézina <ml.richa...@gmail.com 
> > wrote:
>
>> Michael,
>>
>> About displaying value use default = when you create input field it 
>> should be all what you need...
>>
>> About the other problem I don't get it... You should be able to update a 
>> record email/username as long as the new value is unique...
>>
>> Richard
>>
>> On Wed, Apr 20, 2016 at 11:43 PM, Michael Beller <mjbe...@gmail.com 
>> > wrote:
>>
>>> Thanks Richard, I should have provided more details.
>>>
>>> When I tried to create a form using SQLFORM.factory for two tables 
>>> (including auth_user), I would get an error that the auth_user email and 
>>> username existed even if I wasn't updating those fields.  It appears that 
>>> the validator to assure those fields are unique does not exclude the 
>>> current values.  I was able to fix this by adding these before calling 
>>> SQLFORM.factory:
>>>
>>> emails = db(db.auth_user.email != user.email)
>>> db.auth_user.email.requires = IS_NOT_IN_DB(emails, 'auth_user.email'
>>> )
>>> usernames = db(db.auth_user.username != user.username)
>>> db.auth_user.username.requires = IS_NOT_IN_DB(usernames, 
>>> 'auth_user.username')
>>>
>>> My entire function to create an edit form for two tables:
>>>
>>> def edit():
>>> 
>>> investor = db.investor(request.args(0)) or redirect(URL('index'))
>>> user = db.auth_user(investor.auth_user)
>>>
>>> emails = db(db.auth_user.email != user.email)
>>> db.auth_user.email.requires = IS_NOT_IN_DB(emails, 'auth_user.email'
>>> )
>>> usernames = db(db.auth_user.username != user.username)
>>> db.auth_user.username.requires = IS_NOT_IN_DB(usernames, 
>>> 'auth_user.username')
>>>
>>> db.auth_user.password.writable = False
>>> db.investor.auth_user.readable = False
>>> db.investor.auth_user.writable = False
>>>
>>> form = SQLFORM.factory(db.auth_user, db.investor)
>>>
>>> for f in db.investor.fields:
>>> form.vars[f] = investor[f]
>>> for f in db.auth_user.fields:
>>> form.vars[f] = user[f]
>>>
>>> if form.validate():
>>> investor.update_record(**db.investor._filter_fields(form.vars))
>>> user.update_record(**db.auth_user._filter_fields(form.vars))
>>> session.flash = '%s updated!' % table._singular
>>> redirect(URL(request.controller, 'list'))
>>> elif form.errors:
>>> response.flash = 'Please correct the errors'
>>>
>>> response.view = 'template/edit.html'
>>> return dict(item_name=table._singular, form=form)
>>>
>>> Now I'm working on a readonly form but the readonly option for 
>>> SQLFORM.factory doesn't display the values from form.vars so I may just 
>>> generate the form manually.
>>>
>>> On Wednesday, April 20, 2016 at 3:58:37 PM UTC-4, Richard wrote:
>>>>
>>>> Hello Michael,
>>>>
>>>> I am not sure to understand what you are trying to acheive exactly and 
>>>> what is causing issue...
>>>>
>>>> On Wed, Apr 20, 2016 at 2:18 PM, Michael Beller <mjbe...@gmail.com> 
>>>> wrote:
>>>>
>>>>>
>>>>> The approach in the book for one form for multiple tables works well 
>>>>> for create forms:
>>>>>
>>>>> http://web2py.com/books/default/chapter/29/07/forms-and-validators#One-form-for-multiple-tables
>>>>>
>>>>> I have not found a good method for view or update forms.
>>>>>
>>>>> I have a model:
>>

[web2py] Re: How to integrate SendGrid in Web2py ?

2016-04-21 Thread Michael Beller
The starter app has a 'message.py' controller that has functions for 
creating, receiving, and replying to messages (in addition to listing, 
viewing).

The starter app code uses mailgun but it's very similar to sendgrid.  You 
need to setup a webhook in your sendgrid or mailgun account to post the 
inbound message to your app and then the controller function 
(receive_mailgun_message in the starter app) adds it to the message table.

On Thursday, April 21, 2016 at 2:09:21 PM UTC-4, billmac...@gmail.com wrote:
>
> Thank you guys. Michel, 
>
> message.set_from('myweb2pyapp.com')
>
> If someone response to the email, how do I retrieve it? I need to log into 
> my sandgrid account I am guessing. Not sure why sessage.set_form is my app 
> name.com
>
>
>
>
> On Thursday, April 21, 2016 at 2:00:00 PM UTC-4, Michael Beller wrote:
>>
>> You can use the sendgrid smtp server or their api.
>>
>> https://sendgrid.com/blog/which-protocol-should-i-use-to-send-email-smtp-or-rest/
>>
>> Here is my logic for using their api (I also use mailgun with I like 
>> also):
>>
>> def send_email_via_sendgrid(email_to, email_subject, email_body):
>> # https://github.com/sendgrid/sendgrid-python
>>
>> import sendgrid
>> from sendgrid import SendGridError, SendGridClientError, 
>> SendGridServerError
>>
>> sg = sendgrid.SendGridClient('', '> sendgrid pwd>', raise_errors=True)
>>
>> message = sendgrid.Mail()
>> message.add_to(email_to)
>> message.set_subject(email_subject)
>> message.set_html(email_body)
>> #message.set_text('Body')
>> message.set_from('Your Name <us...@myweb2pyapp.com>')
>> #status, msg = sg.send(message)
>>
>> try:
>> sg.send(message)
>> # raise SendGridClientError
>> except SendGridClientError:
>> pass
>> except SendGridServerError:
>> pass
>> finally:
>> return_code = response.status
>> return locals()
>>
>>
>> On Wednesday, April 13, 2016 at 12:48:13 PM UTC-4, Krishna Bavandlapally 
>> wrote:
>>>
>>> Thank you Leonel Câmara.
>>>
>>> It worked.
>>>
>>> mail.settings.server = 'smtp.sendgrid.net:587'
>>> mail.settings.sender = xxx...@mail.com
>>> mail.settings.login = 'sendgrid_username:sendgrid_password'
>>> mail.settings.tls = True
>>>
>>>
>>>
>>> On Wednesday, 13 April 2016 14:29:16 UTC+5:30, Krishna Bavandlapally 
>>> wrote:
>>>>
>>>> How to integrate (default mailing) SendGrid in Web2py ?
>>>>
>>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: How to integrate SendGrid in Web2py ?

2016-04-21 Thread Michael Beller
Hi Ron,

I'm implementing an 'outlook' like interface for some messaging at the 
moment which includes two way messages with attachments.  The early parts 
are incorporated in my scaffold app 
at https://mjbeller.pythonanywhere.com/starter

The 'outlook' like interface that you can use is included like this:
https://almsaeedstudio.com/themes/AdminLTE/pages/mailbox/mailbox.html

(my starter app does not include the nice looking mailbox page yet, just a 
simple list of messages tied to the message icon in the header which 
includes an unread count)

I'll push some updates to starter for messages in the next few days (but 
probably not the full integration with the mailbox.html yet, just the 
simple datatables list of messages already in the repo)

On Wednesday, April 13, 2016 at 11:42:35 AM UTC-4, Ron Chatterjee wrote:
>
> On that note. Leonel, how do we create inbox using web2py that looks 
> similar to outlook? So, when someone write a blog post and other replies or 
> for chat application to say, we can use that outlook looking interface to 
> present the data. Can someone reply to the mail we send with 
> us...@myweb2pyapp.com ?
>
>
>
> On Wednesday, April 13, 2016 at 6:32:17 AM UTC-4, Leonel Câmara wrote:
>>
>> If you're asking this, I'm just going to tell you the most obvious way. 
>> Just use their SMTP server. I've never used sendgrid with web2py but the 
>> config would be something like this:
>>
>> mail.settings.server = 'smtp.sendgrid.net:587'
>> mail.settings.login = 'sendgrid_username:sengrid_password'
>> mail.settings.tls = True
>>
>

-- 
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: How to integrate SendGrid in Web2py ?

2016-04-21 Thread Michael Beller
You can use the sendgrid smtp server or their api.
https://sendgrid.com/blog/which-protocol-should-i-use-to-send-email-smtp-or-rest/

Here is my logic for using their api (I also use mailgun with I like also):

def send_email_via_sendgrid(email_to, email_subject, email_body):
# https://github.com/sendgrid/sendgrid-python

import sendgrid
from sendgrid import SendGridError, SendGridClientError, 
SendGridServerError

sg = sendgrid.SendGridClient('', '', raise_errors=True)

message = sendgrid.Mail()
message.add_to(email_to)
message.set_subject(email_subject)
message.set_html(email_body)
#message.set_text('Body')
message.set_from('Your Name ')
#status, msg = sg.send(message)

try:
sg.send(message)
# raise SendGridClientError
except SendGridClientError:
pass
except SendGridServerError:
pass
finally:
return_code = response.status
return locals()


On Wednesday, April 13, 2016 at 12:48:13 PM UTC-4, Krishna Bavandlapally 
wrote:
>
> Thank you Leonel Câmara.
>
> It worked.
>
> mail.settings.server = 'smtp.sendgrid.net:587'
> mail.settings.sender = xxx...@mail.com 
> mail.settings.login = 'sendgrid_username:sendgrid_password'
> mail.settings.tls = True
>
>
>
> On Wednesday, 13 April 2016 14:29:16 UTC+5:30, Krishna Bavandlapally wrote:
>>
>> How to integrate (default mailing) SendGrid in Web2py ?
>>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] what's the best approach for view and update forms for multiple tables?

2016-04-21 Thread Michael Beller
Thanks but that would prevent username and email from updating.  I want 
them editable on the form but sqlform.factory validates as if it's an 
insert form and not an update form (I was going to see if I could find the 
logic to change that but haven't had time).

My solution just changes the validation to make sure they are unique not 
including the current value.

I've also used the following for the readonly form:

def view():

db.investor.auth_user.readable = False
db.investor.auth_user.writable = False

investor = db.investor(request.args(0)) or redirect(URL('index'))
user = db.auth_user(investor.auth_user)

investor_form = SQLFORM(db.investor, investor, showid=False, readonly=
True, comments=False)
user_form = SQLFORM(db.auth_user, user, showid=False, readonly=True, 
comments=False)

form = user_form + investor_form

return dict(item_name=table._singular, form=form, item=investor)




On Thursday, April 21, 2016 at 9:36:46 AM UTC-4, Richard wrote:
>
> What if you use this inside _filter_fields() instead of form.vars
> **{k: v for k, v in form.vars.iteritems() if k not in ('username', 
> 'email')}
>
> ?
>
> On Wed, Apr 20, 2016 at 11:43 PM, Michael Beller <mjbe...@gmail.com 
> > wrote:
>
>> Thanks Richard, I should have provided more details.
>>
>> When I tried to create a form using SQLFORM.factory for two tables 
>> (including auth_user), I would get an error that the auth_user email and 
>> username existed even if I wasn't updating those fields.  It appears that 
>> the validator to assure those fields are unique does not exclude the 
>> current values.  I was able to fix this by adding these before calling 
>> SQLFORM.factory:
>>
>> emails = db(db.auth_user.email != user.email)
>> db.auth_user.email.requires = IS_NOT_IN_DB(emails, 'auth_user.email')
>> usernames = db(db.auth_user.username != user.username)
>> db.auth_user.username.requires = IS_NOT_IN_DB(usernames, 
>> 'auth_user.username')
>>
>> My entire function to create an edit form for two tables:
>>
>> def edit():
>> 
>> investor = db.investor(request.args(0)) or redirect(URL('index'))
>> user = db.auth_user(investor.auth_user)
>>
>> emails = db(db.auth_user.email != user.email)
>> db.auth_user.email.requires = IS_NOT_IN_DB(emails, 'auth_user.email')
>> usernames = db(db.auth_user.username != user.username)
>> db.auth_user.username.requires = IS_NOT_IN_DB(usernames, 
>> 'auth_user.username')
>>
>> db.auth_user.password.writable = False
>> db.investor.auth_user.readable = False
>> db.investor.auth_user.writable = False
>>
>> form = SQLFORM.factory(db.auth_user, db.investor)
>>
>> for f in db.investor.fields:
>> form.vars[f] = investor[f]
>> for f in db.auth_user.fields:
>> form.vars[f] = user[f]
>>
>> if form.validate():
>> investor.update_record(**db.investor._filter_fields(form.vars))
>> user.update_record(**db.auth_user._filter_fields(form.vars))
>> session.flash = '%s updated!' % table._singular
>> redirect(URL(request.controller, 'list'))
>> elif form.errors:
>> response.flash = 'Please correct the errors'
>>
>> response.view = 'template/edit.html'
>> return dict(item_name=table._singular, form=form)
>>
>> Now I'm working on a readonly form but the readonly option for 
>> SQLFORM.factory doesn't display the values from form.vars so I may just 
>> generate the form manually.
>>
>> On Wednesday, April 20, 2016 at 3:58:37 PM UTC-4, Richard wrote:
>>>
>>> Hello Michael,
>>>
>>> I am not sure to understand what you are trying to acheive exactly and 
>>> what is causing issue...
>>>
>>> On Wed, Apr 20, 2016 at 2:18 PM, Michael Beller <mjbe...@gmail.com> 
>>> wrote:
>>>
>>>>
>>>> The approach in the book for one form for multiple tables works well 
>>>> for create forms:
>>>>
>>>> http://web2py.com/books/default/chapter/29/07/forms-and-validators#One-form-for-multiple-tables
>>>>
>>>> I have not found a good method for view or update forms.
>>>>
>>>> I have a model:
>>>>
>>>> db.define_table('buyer', Field('auth_user', 'reference auth_user', ...)
>>>> db.define_table('seller', Field('auth_user', 'reference auth_user', ...)
>>>>
>>>> Each buyer is associated with one user and each seller is associated 
>>>> with one user.  I'd like to have one form to 

[web2py] Re: Not web2py related but want an advice.

2016-04-21 Thread Michael Beller
imho, taking advantage of courses in college to broaden and deepen your 
understanding of computer science (and areas outside computer science) is 
very worthwhile.

it's hard to predict where your career will lead and what "web development" 
will be in 5, 10, 15, years and beyond.  "web development" at Twitter is 
also a very different experience than "web development" for a startup.


On Thursday, April 21, 2016 at 4:36:21 AM UTC-4, Emmanuel Dsouza wrote:
>
> So my college is offering me to do a parallel programming and CUDA course. 
> I am inclined towards making a career in web development. Should i go for 
> this course? Does it have any good scope in web development too or should I 
> invest time learning web development itself nicely.

-- 
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: How to ensure each row in the db table having distinct value of a partcular field?

2016-04-20 Thread Michael Beller
unique=True assures the value is unique at the database level but does not 
add a form validator.

In addition to unique=True, you can add a validator like this:

db.person.username.requires = IS_NOT_IN_DB(db, 'person.username')

from the book:
http://web2py.com/books/default/chapter/29/07/forms-and-validators#IS_NOT_IN_DB



On Tuesday, April 19, 2016 at 2:32:15 AM UTC-4, mfarees...@gmail.com wrote:
>
> Field('username', unique=True)
>

-- 
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] what's the best approach for view and update forms for multiple tables?

2016-04-20 Thread Michael Beller
Thanks Richard, I should have provided more details.

When I tried to create a form using SQLFORM.factory for two tables 
(including auth_user), I would get an error that the auth_user email and 
username existed even if I wasn't updating those fields.  It appears that 
the validator to assure those fields are unique does not exclude the 
current values.  I was able to fix this by adding these before calling 
SQLFORM.factory:

emails = db(db.auth_user.email != user.email)
db.auth_user.email.requires = IS_NOT_IN_DB(emails, 'auth_user.email')
usernames = db(db.auth_user.username != user.username)
db.auth_user.username.requires = IS_NOT_IN_DB(usernames, 
'auth_user.username')

My entire function to create an edit form for two tables:

def edit():

investor = db.investor(request.args(0)) or redirect(URL('index'))
user = db.auth_user(investor.auth_user)

emails = db(db.auth_user.email != user.email)
db.auth_user.email.requires = IS_NOT_IN_DB(emails, 'auth_user.email')
usernames = db(db.auth_user.username != user.username)
db.auth_user.username.requires = IS_NOT_IN_DB(usernames, 
'auth_user.username')

db.auth_user.password.writable = False
db.investor.auth_user.readable = False
db.investor.auth_user.writable = False

form = SQLFORM.factory(db.auth_user, db.investor)

for f in db.investor.fields:
form.vars[f] = investor[f]
for f in db.auth_user.fields:
form.vars[f] = user[f]

if form.validate():
investor.update_record(**db.investor._filter_fields(form.vars))
user.update_record(**db.auth_user._filter_fields(form.vars))
session.flash = '%s updated!' % table._singular
redirect(URL(request.controller, 'list'))
elif form.errors:
response.flash = 'Please correct the errors'

response.view = 'template/edit.html'
return dict(item_name=table._singular, form=form)

Now I'm working on a readonly form but the readonly option for 
SQLFORM.factory doesn't display the values from form.vars so I may just 
generate the form manually.

On Wednesday, April 20, 2016 at 3:58:37 PM UTC-4, Richard wrote:
>
> Hello Michael,
>
> I am not sure to understand what you are trying to acheive exactly and 
> what is causing issue...
>
> On Wed, Apr 20, 2016 at 2:18 PM, Michael Beller <mjbe...@gmail.com 
> > wrote:
>
>>
>> The approach in the book for one form for multiple tables works well for 
>> create forms:
>>
>> http://web2py.com/books/default/chapter/29/07/forms-and-validators#One-form-for-multiple-tables
>>
>> I have not found a good method for view or update forms.
>>
>> I have a model:
>>
>> db.define_table('buyer', Field('auth_user', 'reference auth_user', ...)
>> db.define_table('seller', Field('auth_user', 'reference auth_user', ...)
>>
>> Each buyer is associated with one user and each seller is associated with 
>> one user.  I'd like to have one form to view and edit each buyer and seller 
>> that includes their user profile.
>>
>> I've tried variations of
>>
>> https://groups.google.com/forum/#!searchin/web2py/sqlform.factory$20edit/web2py/fvzIHyN7eP4/ZixpDiTl1GUJ
>> and
>> https://groups.google.com/forum/#!topic/web2py/hpH7a3Qz3Wg
>>
>> Has anybody found a good solution?
>>
>> -- 
>> 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.
>>
>
>

-- 
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: relation "auth_user" already exists

2016-04-20 Thread Michael Beller
It sounds like you need to update the .tables files to match your database 
and models.

I believe you need to set both migrate=True and fake_migrate_all=True for 
the fake migrate to regenerate the .tables files.

Here's the logic in the book:
http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer?search=fake#Migration-control-summary

Have you tried setting both migrate and fake_migrate_all to True?

On Wednesday, April 20, 2016 at 4:34:50 PM UTC-4, Gael Princivalle wrote:
>
> Hello.
>
> I'm still having some pain with DAL connection strings and migrations.
>
> In one application my DAL connection string is like that:
> DAL('postgres://username:password@localhost:5432/postg_db', check_reserved
> =['all'], pool_size=1, entity_quoting=True, bigint_id=True, migrate=False, 
> fake_migrate_all=False)
>
> The application works well, but in the databases folder I have only tables 
> form ckeditor and scheduler.
> If I set fake_migrate_all=True and run the application tables are not 
> recreated.
> If I set migrate=True a ticket says me that relation "auth_user" already 
> exists.
> So I'm unable to make modifications to this db.
>
> My reference for migration is this Niphlod post but in this case I don't 
> know how to found a solution:
> 1. Put your models exactly has the database tables are.
> 2. Do a fake migrate.
> 3. Remove fake migrate and set migrate=True 
> 4. Do the changes you need in your model.
>
> What happens if you set migrate=False in the table definition ? the check 
> between the model in db.py and the .table file is skipped, and web2py 
> assumes that on the db the table reflect exactly what there is in the 
> model
>
> What happens if you set fake_migrate=True in the table definition ? 
> web2py assumes that on the db the table reflect exactly what there is in 
> the model, the .table files are recreated
>
> What happens if you set fake_migrate_all=True in the DAL ? all .table 
> files are recreated, and web2py assumes that on the db the db tables are 
> reflecting the model.
>  
> What happens if you set migrate=False in the DAL? whatever table has no a 
> specific "migrate" parameter, the migrate=False is applied to every table
>
> This kind of errors can happen only if you messed with this logic, e.g.
> db.define_table('test', Field('test1'), migrate=True) #web2py create the 
> test table with the columns id and test1
>
> then
> db.define_table('test', Field('test1'), Field('test2'), migrate=False, 
> fake_migrate=True) # web2py assumes that you created manually on the db 
> the column test2, and updates the .table file
>
> then
> db.define_table('test', Field('test1'), Field('test2')) # web2py sees no 
> change between the .table file and the model, but if there's not the column 
> on the db, when you try to use it you'll get the "no such column" error
>
> then you delete the 'test' .table file manually, then
> db.define_table('test', Field('test1'), Field('test2'), migrate=True) #web2py 
> assumes that the 'test' table is not on the db, because the corresponding 
> .table file is not there, so it tries to create it, and you get the error 
> "table 'test' already exists on the db"
>
> or, you delete the 'test' .table file manually, and drop the table 
> manually on the db then
> db.define_table('test', Field('test1'), migrate=False) #web2py assumes 
> that the table is already there, and when you try to use it you get the 
> error "table 'test' does not exist"
>
>
> Someone knows how can I resolve it ?
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: How can I pre populate a option column of a form?

2016-04-20 Thread Michael Beller
before you call SQLFORM, insert:
db.pratiche.stato_pratica.default = 'aperta'



On Wednesday, April 20, 2016 at 6:05:06 PM UTC-4, Andrea Marin wrote:
>
> Hi I have this type of form in my model file:
>
> db.define_table('pratiche',
> Field('nome', requires=IS_NOT_EMPTY()),
> Field('descrizione', 'text', requires=IS_NOT_EMPTY()),
> Field('tipo_allegato', requires=IS_IN_SET(['mandato', 
> 'comparsa preliminare', 'relazione ctu', 'parcella'])),
> Field('doc_filename'),
> Field('doc', 'upload'),
> Field('stato_pratica', requires=IS_IN_SET(['aperta', 
> 'attesa', 'chiusa'])),
> auth.signature)
>
>
> I want to setup a default value for field stato_pratica to 'aperta' every 
> time a user create a new record
> This is my controller function to create a new record
>
> def create():
> form = SQLFORM(db.pratiche).process()
> form.vars.stato_pratica = 'aperta'
> form.add_button('Back', URL('index'))
> if form.accepted:
> session.flash = T('Posted')
> redirect(URL('index'))
> elif form.errors:
> session.flash = T('Il form ha degli errori')
> return locals()
>
> I try to set form.values.stato_pratica = 'aperta' but it not works.
>
> Thanks.
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] what's the best approach for view and update forms for multiple tables?

2016-04-20 Thread Michael Beller

The approach in the book for one form for multiple tables works well for 
create forms:
http://web2py.com/books/default/chapter/29/07/forms-and-validators#One-form-for-multiple-tables

I have not found a good method for view or update forms.

I have a model:

db.define_table('buyer', Field('auth_user', 'reference auth_user', ...)
db.define_table('seller', Field('auth_user', 'reference auth_user', ...)

Each buyer is associated with one user and each seller is associated with 
one user.  I'd like to have one form to view and edit each buyer and seller 
that includes their user profile.

I've tried variations of
https://groups.google.com/forum/#!searchin/web2py/sqlform.factory$20edit/web2py/fvzIHyN7eP4/ZixpDiTl1GUJ
and
https://groups.google.com/forum/#!topic/web2py/hpH7a3Qz3Wg

Has anybody found a good solution?

-- 
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: Load component in a ?

2016-03-26 Thread Michael Beller
You may be able to use jquery unwrap, wrap, or replace

For example, I want to load a component and not generate the wrapping DIV 
so I added a unique id to the top element in my view.load file and this 
inline at the bottom:

  $("#unique-id").unwrap();


I think you may be able to use replace also.

On Thursday, March 24, 2016 at 12:51:33 PM UTC-4, webm...@trytha.com wrote:
>
> I want my component to load in a span() instead of the default 
> div(class="data-w2p_remote").  Anyone know the best way to do this?
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: What are the platforms for free web hosting of web2py apps?

2016-03-24 Thread Michael Beller
I don't know about PHP but if you need a separate install of web2py for 
each app (which is what I do), each new web app costs $2/month.  In several 
cases, I run multiple apps within one instance of web2py (the only 
disadvantage is the URL but that's oftentimes fine for some enterprise 
apps).

I have several pythonanywhere accounts but the one I use for many of my 
small apps costs $12.25 per month for 4 web apps and 2 web workers each. 
 One of those web apps supports several web2py applications under one 
instance (this is also how I manage user testing environments to separate 
them from production environments).

It's also possible to create separate free pythonanywhere accounts for each 
low volume app (I used to do that but paying $2/month just makes it easier 
to manage under one account).

For low volume apps, GAE is also great - I run several apps (really just 
simple sites) on GAE for free (but I don't think that supports PHP either).

On Thursday, March 24, 2016 at 9:35:42 AM UTC-4, Carlos Cesar Caballero 
wrote:
>
> Hi Michael, thanks for your suggestion, pythonanywhere is really good, but 
> it do not meet two requirements that I need, the first is that I have some 
> php apps, and the second is that I have many low traffic sites, making the 
> pythonanywhere plan too expensive.
>
> Greetings.
>
> El miércoles, 23 de marzo de 2016, 21:54:47 (UTC-4), Michael Beller 
> escribió:
>>
>> +1 for pythonanywhere.com 
>>
>> based in UK if that meets your non-USA requirement
>> awesome support
>> completely scalable
>> runs on AWS infrastructure (they've essentially built a layer on top of 
>> AWS that's make it trivial to manage)
>>
>> On Tuesday, March 22, 2016 at 8:47:12 AM UTC-4, Carlos Cesar Caballero 
>> wrote:
>>>
>>> Hi, have you some experience with forpsi.com? I am looking for reliable 
>>> non USA providers.
>>>
>>> Greetings.
>>>
>>> El lunes, 14 de marzo de 2016, 8:28:13 (UTC-4), Mirek Zvolský escribió:
>>>>
>>>> allwaysdata.com, but has only 10M place (about 6M after you install 
>>>> web2py-min), good ssh, cron, no problem to install everything.
>>>> forpsi.com paid, but only 2$/month for full VM
>>>>
>>>>
>>>>
>>>> Dne neděle 21. února 2016 7:38:46 UTC+1 Rgb Aston napsal(a):
>>>>>
>>>>> Which one's the best to go for?
>>>>>
>>>>

-- 
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] new Starter app (alternative to Welcome app)

2016-03-24 Thread Michael Beller
No Avatar field yet!  It's hardcoded in the template.  It should be easy to 
add a custom field to the auth_user table following these instructions:
http://web2py.com/books/default/chapter/29/09/access-control?search=auth_user#Customizing-Auth

Then you can upload an avatar using the user profile page.

I haven't done this with images but it should be straight forward (it's on 
my todo list!)

You can also designate a dedicated folder for the avatar uploads so they're 
not commingled with other upload files ...
http://web2py.com/books/default/chapter/29/07/forms-and-validators?search=upload#SQLFORM-and-uploads

On Thursday, March 24, 2016 at 3:03:41 PM UTC-4, Ron Chatterjee wrote:
>
> I am sorry, I was having some problem downloading the latest version so 
> everything is good. Quick question Michael, how does someone change the 
> profile picture? There is a avatar field?
>
> On Thursday, March 24, 2016 at 11:56:27 AM UTC-4, Michael Beller wrote:
>>
>> The appconfig in 2.13 has a problem with strings separated by comma's in 
>> the appconfig.ini file.  Starter app uses 2.14.1
>>
>> You can either install 2.14.1 or just change ...
>>
>> line 34 in initialize.py:
>> for group in myconf.get('admin_user.auth_groups'):
>>
>> could replace with
>> for group in ['Admin', 'Customer Service', 'Operations']:
>>
>> or just change the function to create the Admin group which is all that's 
>> needed.
>>
>>
>>
>> On Thu, Mar 24, 2016 at 11:20 AM, Ron Chatterjee <achatte...@gmail.com> 
>> wrote:
>>
>>> Not sure its ready to be posted. I just downloaded the app and I don't 
>>> see any initialization. My experience...it seems have some issues still 
>>> (see the attached pic) . When I tried to register, I get this error:
>>>
>>>
>>> Traceback *(*most recent call last
>>> *):   *File "…\web2py\gluon\restricted.py"*, *line 227*, in *restricted
>>> *exec *ccode *in *environment
>>>   File" …applications/starter/controllers/default.py" 
>>> <http://127.0.0.1:8000/admin/default/edit/starter/controllers/default.py>*, 
>>> *line 91*, in <*module
>>> *>   *File "…web2py\gluon\globals.py"*, *line 412
>>> *, in  self.*_caller *= lambda *f*: *f
>>> *()   *File …/starter/controllers/default.py" 
>>> <http://127.0.0.1:8000/admin/default/edit/starter/controllers/default.py>*, 
>>> *line 70*, in *user
>>> *return *dict*(*form*=*auth
>>> *())   *File "…web2py\gluon\tools.py"*, *line 1923*, in *__call__
>>> *return *getattr*(self, *args*[*0
>>> *])()   *File "…\tools.py"*, *line 3375*, in *register
>>> *self.*login_user*(*user
>>> *)   *File "…web2py\gluon\tools.py"*, *line 2630*, in *login_user
>>> user *= *Row*(*user
>>> *)   *File "…\helpers\classes.py"*, *line 18*, in *__init__
>>> *return self.*__dict__*.*__init__*(**args*, ***kwargs
>>> *) *TypeError*: *'NoneType' object *is not *iterable
>>>
>>> Using 2.13.4 (which has a flash bar rash that just don't go away). 
>>>
>>>
>>>
>>> On Thursday, March 24, 2016 at 10:38:35 AM UTC-4, Michael Beller wrote:
>>>>
>>>> I commonly create a user (usually my email) and an Admin group and then 
>>>> add myself to the Admin group.  I have logic in the Starter app based on 
>>>> the Admin group.  I usually have other groups such as Operations and 
>>>> Customer Service (I tend to build enterprise 'line of business' apps).  
>>>> Since I frequently clean out the database during initial development, I 
>>>> just created an initialization function that automatically adds an initial 
>>>> set of test users, groups, and memberships so I don't have to do it 
>>>> manually,   The Initialization function also calls a function that 
>>>> automatically populates tables with test data (using the Populate 
>>>> function) 
>>>> that is helpful for quick demos during prototyping and user demos.  You 
>>>> can 
>>>> modify the routines to meet your needs - it's just something I always end 
>>>> up creating so I put it in my scaffold app.
>>>>
>>>> On Thu, Mar 24, 2016 at 9:13 AM, <rajjm...@gmail.com> wrote:
>>>>
>>>>> This may be little preliminary but what you mean by "Admin user and 
>>>>> auth_groups" setup and how? I don't recall anything to set up with the 
>>>>&

Re: [web2py] new Starter app (alternative to Welcome app)

2016-03-24 Thread Michael Beller
The appconfig in 2.13 has a problem with strings separated by comma's in
the appconfig.ini file.  Starter app uses 2.14.1

You can either install 2.14.1 or just change ...

line 34 in initialize.py:
for group in myconf.get('admin_user.auth_groups'):

could replace with
for group in ['Admin', 'Customer Service', 'Operations']:

or just change the function to create the Admin group which is all that's
needed.



On Thu, Mar 24, 2016 at 11:20 AM, Ron Chatterjee <achatterjee...@gmail.com>
wrote:

> Not sure its ready to be posted. I just downloaded the app and I don't see
> any initialization. My experience...it seems have some issues still (see
> the attached pic) . When I tried to register, I get this error:
>
>
> Traceback *(*most recent call last
> *):   *File "…\web2py\gluon\restricted.py"*, *line 227*, in *restricted
> *exec *ccode *in *environment
>   File" …applications/starter/controllers/default.py"
> <http://127.0.0.1:8000/admin/default/edit/starter/controllers/default.py>*,
> *line 91*, in <*module
> *>   *File "…web2py\gluon\globals.py"*, *line 412
> *, in  self.*_caller *= lambda *f*: *f
> *()   *File …/starter/controllers/default.py"
> <http://127.0.0.1:8000/admin/default/edit/starter/controllers/default.py>*,
> *line 70*, in *user
> *return *dict*(*form*=*auth
> *())   *File "…web2py\gluon\tools.py"*, *line 1923*, in *__call__
> *return *getattr*(self, *args*[*0
> *])()   *File "…\tools.py"*, *line 3375*, in *register
> *self.*login_user*(*user
> *)   *File "…web2py\gluon\tools.py"*, *line 2630*, in *login_user
> user *= *Row*(*user
> *)   *File "…\helpers\classes.py"*, *line 18*, in *__init__
> *return self.*__dict__*.*__init__*(**args*, ***kwargs
> *) *TypeError*: *'NoneType' object *is not *iterable
>
> Using 2.13.4 (which has a flash bar rash that just don't go away).
>
>
>
> On Thursday, March 24, 2016 at 10:38:35 AM UTC-4, Michael Beller wrote:
>>
>> I commonly create a user (usually my email) and an Admin group and then
>> add myself to the Admin group.  I have logic in the Starter app based on
>> the Admin group.  I usually have other groups such as Operations and
>> Customer Service (I tend to build enterprise 'line of business' apps).
>> Since I frequently clean out the database during initial development, I
>> just created an initialization function that automatically adds an initial
>> set of test users, groups, and memberships so I don't have to do it
>> manually,   The Initialization function also calls a function that
>> automatically populates tables with test data (using the Populate function)
>> that is helpful for quick demos during prototyping and user demos.  You can
>> modify the routines to meet your needs - it's just something I always end
>> up creating so I put it in my scaffold app.
>>
>> On Thu, Mar 24, 2016 at 9:13 AM, <rajjm...@gmail.com> wrote:
>>
>>> This may be little preliminary but what you mean by "Admin user and
>>> auth_groups" setup and how? I don't recall anything to set up with the
>>> welcome app. It worked the first time straight out of the box.
>>>
>>>
>>> On Thursday, March 24, 2016 at 8:56:22 AM UTC-4, Ron Chatterjee wrote:
>>>>
>>>> I am looking at this link:
>>>>
>>>> https://almsaeedstudio.com/themes/AdminLTE/documentation/index.html.
>>>> Is that widget/plugin that comes with that bootstrap? Michael, you familiar
>>>> with that?
>>>>
>>>> It has something call direct chat.
>>>>
>>>> On Thursday, March 24, 2016 at 12:23:08 AM UTC-4, Michael Beller wrote:
>>>>>
>>>>> I plan to! When ready, I'd like to try and apply these styles
>>>>> https://almsaeedstudio.com/themes/AdminLTE/pages/forms/general.html
>>>>> to the new form.py and perhaps
>>>>> https://almsaeedstudio.com/themes/AdminLTE/pages/tables/data.html
>>>>> to the new grid.py
>>>>>
>>>>> On Wednesday, March 23, 2016 at 10:22:32 PM UTC-4, Massimo Di Pierro
>>>>> wrote:
>>>>>>
>>>>>> I am linking this from the new examples app. I assume you will be
>>>>>> maintaining it. for a while. :-)
>>>>>> On Wednesday, 23 March 2016 19:38:22 UTC-5, Michael Beller wrote:
>>>>>>>
>>>>>>> Are you using 2.14.1 beta?
>>>>>>>
>>>>>>> I would try to get it running without changes before making

Re: [web2py] new Starter app (alternative to Welcome app)

2016-03-24 Thread Michael Beller
I commonly create a user (usually my email) and an Admin group and then add
myself to the Admin group.  I have logic in the Starter app based on the
Admin group.  I usually have other groups such as Operations and Customer
Service (I tend to build enterprise 'line of business' apps).  Since I
frequently clean out the database during initial development, I just
created an initialization function that automatically adds an initial set
of test users, groups, and memberships so I don't have to do it manually,
The Initialization function also calls a function that automatically
populates tables with test data (using the Populate function) that is
helpful for quick demos during prototyping and user demos.  You can modify
the routines to meet your needs - it's just something I always end up
creating so I put it in my scaffold app.

On Thu, Mar 24, 2016 at 9:13 AM, <rajjmatt...@gmail.com> wrote:

> This may be little preliminary but what you mean by "Admin user and
> auth_groups" setup and how? I don't recall anything to set up with the
> welcome app. It worked the first time straight out of the box.
>
>
> On Thursday, March 24, 2016 at 8:56:22 AM UTC-4, Ron Chatterjee wrote:
>>
>> I am looking at this link:
>>
>> https://almsaeedstudio.com/themes/AdminLTE/documentation/index.html. Is
>> that widget/plugin that comes with that bootstrap? Michael, you familiar
>> with that?
>>
>> It has something call direct chat.
>>
>> On Thursday, March 24, 2016 at 12:23:08 AM UTC-4, Michael Beller wrote:
>>>
>>> I plan to! When ready, I'd like to try and apply these styles
>>> https://almsaeedstudio.com/themes/AdminLTE/pages/forms/general.html
>>> to the new form.py and perhaps
>>> https://almsaeedstudio.com/themes/AdminLTE/pages/tables/data.html
>>> to the new grid.py
>>>
>>> On Wednesday, March 23, 2016 at 10:22:32 PM UTC-4, Massimo Di Pierro
>>> wrote:
>>>>
>>>> I am linking this from the new examples app. I assume you will be
>>>> maintaining it. for a while. :-)
>>>> On Wednesday, 23 March 2016 19:38:22 UTC-5, Michael Beller wrote:
>>>>>
>>>>> Are you using 2.14.1 beta?
>>>>>
>>>>> I would try to get it running without changes before making changes
>>>>> (unless you have a need to get it running on an old version of web2py).  
>>>>> As
>>>>> Massimo pointed out, it's not necessarily backward compatible but other
>>>>> than removing host_names (which I already did in the repo) I don't see why
>>>>> it wouldn't work on an older version (I also had to remove formstyle from
>>>>> appconfig to support an older version).
>>>>>
>>>>> I just installed a clean version using
>>>>> git clone https://github.com/mjbeller/web2py-starter.git starter
>>>>> into 2.14.1 beta (actually current master) and then accessed
>>>>> /initialize/adminuser
>>>>> <http://127.0.0.1:8000/starter2/initialize/adminuser>
>>>>> to setup Admin user and auth_groups and everything worked fine.
>>>>>
>>>>> I'm still getting an odd error on 2.13.x which I can't figure out but
>>>>> I'm content to move forward with just 2.14.1
>>>>>
>>>>> On Wednesday, March 23, 2016 at 8:02:51 PM UTC-4, Ron Chatterjee wrote:
>>>>>>
>>>>>> Got it. As always, thank you Massimo.
>>>>>>
>>>>>> I changed in db1.py
>>>>>>
>>>>>> auth.define_tables(username=True, signature=True)
>>>>>>
>>>>>> to
>>>>>> auth.define_tables(username=False, signature=True)
>>>>>>
>>>>>> But in  the log in it still ask me for user name.
>>>>>>
>>>>>> Also I get an error when I try to register.
>>>>>>
>>>>>> pydal\helpers\classes.py", line 18, in __init__
>>>>>> return self.__dict__.__init__(*args, **kwargs)
>>>>>> TypeError: 'NoneType' object is not iterable
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Wednesday, March 23, 2016 at 7:32:18 PM UTC-4, Massimo Di Pierro
>>>>>> wrote:
>>>>>>>
>>>>>>> You cannot do that. You have an app created with web2py 2.14.1 beta
>>>>>>> and run it with an older version of web2py. myconf.get is not defined.
>>>>>>> We only offer backward compatibility, not for

Re: [web2py] new Starter app (alternative to Welcome app)

2016-03-24 Thread Michael Beller
Yes - the AdminLTE template/theme is based on Bootstrap and includes many
front-end plugins/components (like Datatables.net, Full Calendar, etc.).
It includes layouts and widgets for displaying chat sessions, charts,
tables, etc. all with a common theme and layout.

On Thu, Mar 24, 2016 at 8:56 AM, Ron Chatterjee <achatterjee...@gmail.com>
wrote:

> I am looking at this link:
>
> https://almsaeedstudio.com/themes/AdminLTE/documentation/index.html. Is
> that widget/plugin that comes with that bootstrap? Michael, you familiar
> with that?
>
> It has something call direct chat.
>
> On Thursday, March 24, 2016 at 12:23:08 AM UTC-4, Michael Beller wrote:
>>
>> I plan to! When ready, I'd like to try and apply these styles
>> https://almsaeedstudio.com/themes/AdminLTE/pages/forms/general.html
>> to the new form.py and perhaps
>> https://almsaeedstudio.com/themes/AdminLTE/pages/tables/data.html
>> to the new grid.py
>>
>> On Wednesday, March 23, 2016 at 10:22:32 PM UTC-4, Massimo Di Pierro
>> wrote:
>>>
>>> I am linking this from the new examples app. I assume you will be
>>> maintaining it. for a while. :-)
>>> On Wednesday, 23 March 2016 19:38:22 UTC-5, Michael Beller wrote:
>>>>
>>>> Are you using 2.14.1 beta?
>>>>
>>>> I would try to get it running without changes before making changes
>>>> (unless you have a need to get it running on an old version of web2py).  As
>>>> Massimo pointed out, it's not necessarily backward compatible but other
>>>> than removing host_names (which I already did in the repo) I don't see why
>>>> it wouldn't work on an older version (I also had to remove formstyle from
>>>> appconfig to support an older version).
>>>>
>>>> I just installed a clean version using
>>>> git clone https://github.com/mjbeller/web2py-starter.git starter
>>>> into 2.14.1 beta (actually current master) and then accessed
>>>> /initialize/adminuser
>>>> <http://127.0.0.1:8000/starter2/initialize/adminuser>
>>>> to setup Admin user and auth_groups and everything worked fine.
>>>>
>>>> I'm still getting an odd error on 2.13.x which I can't figure out but
>>>> I'm content to move forward with just 2.14.1
>>>>
>>>> On Wednesday, March 23, 2016 at 8:02:51 PM UTC-4, Ron Chatterjee wrote:
>>>>>
>>>>> Got it. As always, thank you Massimo.
>>>>>
>>>>> I changed in db1.py
>>>>>
>>>>> auth.define_tables(username=True, signature=True)
>>>>>
>>>>> to
>>>>> auth.define_tables(username=False, signature=True)
>>>>>
>>>>> But in  the log in it still ask me for user name.
>>>>>
>>>>> Also I get an error when I try to register.
>>>>>
>>>>> pydal\helpers\classes.py", line 18, in __init__
>>>>> return self.__dict__.__init__(*args, **kwargs)
>>>>> TypeError: 'NoneType' object is not iterable
>>>>>
>>>>>
>>>>>
>>>>> On Wednesday, March 23, 2016 at 7:32:18 PM UTC-4, Massimo Di Pierro
>>>>> wrote:
>>>>>>
>>>>>> You cannot do that. You have an app created with web2py 2.14.1 beta
>>>>>> and run it with an older version of web2py. myconf.get is not defined.
>>>>>> We only offer backward compatibility, not forward compatibility.
>>>>>>
>>>>>> Massimo
>>>>>>
>>>>>> On Wednesday, 23 March 2016 18:12:58 UTC-5, Ron Chatterjee wrote:
>>>>>>>
>>>>>>> I copied the config file from private and changed this to db1.py.
>>>>>>>
>>>>>>> auth = Auth(db, host_names=myconf.get('host.name'))
>>>>>>>
>>>>>>> I still don't get the app running. Any suggestions?
>>>>>>>
>>>>>>> web2py version running: 2.12.3
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Wednesday, March 23, 2016 at 6:36:34 PM UTC-4, Dave S wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> On Wednesday, March 23, 2016 at 3:01:24 PM UTC-7, Literate Aspects
>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>> Hi Rimas,
>>>>>>>>>
&

Re: [web2py] new Starter app (alternative to Welcome app)

2016-03-23 Thread Michael Beller
I plan to! When ready, I'd like to try and apply these styles
https://almsaeedstudio.com/themes/AdminLTE/pages/forms/general.html 
to the new form.py and perhaps
https://almsaeedstudio.com/themes/AdminLTE/pages/tables/data.html
to the new grid.py

On Wednesday, March 23, 2016 at 10:22:32 PM UTC-4, Massimo Di Pierro wrote:
>
> I am linking this from the new examples app. I assume you will be 
> maintaining it. for a while. :-)
> On Wednesday, 23 March 2016 19:38:22 UTC-5, Michael Beller wrote:
>>
>> Are you using 2.14.1 beta?
>>
>> I would try to get it running without changes before making changes 
>> (unless you have a need to get it running on an old version of web2py).  As 
>> Massimo pointed out, it's not necessarily backward compatible but other 
>> than removing host_names (which I already did in the repo) I don't see why 
>> it wouldn't work on an older version (I also had to remove formstyle from 
>> appconfig to support an older version).
>>
>> I just installed a clean version using 
>> git clone https://github.com/mjbeller/web2py-starter.git starter
>> into 2.14.1 beta (actually current master) and then accessed
>> /initialize/adminuser 
>> <http://127.0.0.1:8000/starter2/initialize/adminuser> 
>> to setup Admin user and auth_groups and everything worked fine.
>>
>> I'm still getting an odd error on 2.13.x which I can't figure out but I'm 
>> content to move forward with just 2.14.1
>>
>> On Wednesday, March 23, 2016 at 8:02:51 PM UTC-4, Ron Chatterjee wrote:
>>>
>>> Got it. As always, thank you Massimo. 
>>>
>>> I changed in db1.py
>>>
>>> auth.define_tables(username=True, signature=True)
>>>
>>> to 
>>> auth.define_tables(username=False, signature=True)
>>>
>>> But in  the log in it still ask me for user name. 
>>>
>>> Also I get an error when I try to register.
>>>
>>> pydal\helpers\classes.py", line 18, in __init__
>>> return self.__dict__.__init__(*args, **kwargs)
>>> TypeError: 'NoneType' object is not iterable
>>>
>>>
>>>
>>> On Wednesday, March 23, 2016 at 7:32:18 PM UTC-4, Massimo Di Pierro 
>>> wrote:
>>>>
>>>> You cannot do that. You have an app created with web2py 2.14.1 beta and 
>>>> run it with an older version of web2py. myconf.get is not defined.
>>>> We only offer backward compatibility, not forward compatibility.
>>>>
>>>> Massimo
>>>>
>>>> On Wednesday, 23 March 2016 18:12:58 UTC-5, Ron Chatterjee wrote:
>>>>>
>>>>> I copied the config file from private and changed this to db1.py.
>>>>>
>>>>> auth = Auth(db, host_names=myconf.get('host.name'))
>>>>>
>>>>> I still don't get the app running. Any suggestions?
>>>>>
>>>>> web2py version running: 2.12.3
>>>>>
>>>>>
>>>>>
>>>>> On Wednesday, March 23, 2016 at 6:36:34 PM UTC-4, Dave S wrote:
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Wednesday, March 23, 2016 at 3:01:24 PM UTC-7, Literate Aspects 
>>>>>> wrote:
>>>>>>>
>>>>>>> Hi Rimas,
>>>>>>>
>>>>>>> I thank you for the kind thoughts, but I simply don't have that 
>>>>>>> luxury.  I read and I listen to the video tutorials, IF they matched 
>>>>>>> the 
>>>>>>> current live app, then following the step by step instructions would be 
>>>>>>> straight forward, but the live app does not match the instructions, so 
>>>>>>> at 
>>>>>>> each step, one has to FIGURE out an unknown.
>>>>>>>
>>>>>>>
>>>>>> The only difference I recognized in the screen shots was that the 
>>>>>> book had 1 more line in the header comment.  The code lines you showed 
>>>>>> seemed to match.  But recognize that the code included in the Welcome 
>>>>>> app 
>>>>>> (which is the code that gets used if you pressed the "Make new App" 
>>>>>> button 
>>>>>> on the Web2Py "console" page) can get changed every release; the book 
>>>>>> tends 
>>>>>> not to change as often.
>>>>>>
>>>>>> Some of these changes are simplification, some are taking advan

[web2py] Re: What are the platforms for free web hosting of web2py apps?

2016-03-23 Thread Michael Beller
+1 for pythonanywhere.com 

based in UK if that meets your non-USA requirement
awesome support
completely scalable
runs on AWS infrastructure (they've essentially built a layer on top of AWS 
that's make it trivial to manage)

On Tuesday, March 22, 2016 at 8:47:12 AM UTC-4, Carlos Cesar Caballero 
wrote:
>
> Hi, have you some experience with forpsi.com? I am looking for reliable 
> non USA providers.
>
> Greetings.
>
> El lunes, 14 de marzo de 2016, 8:28:13 (UTC-4), Mirek Zvolský escribió:
>>
>> allwaysdata.com, but has only 10M place (about 6M after you install 
>> web2py-min), good ssh, cron, no problem to install everything.
>> forpsi.com paid, but only 2$/month for full VM
>>
>>
>>
>> Dne neděle 21. února 2016 7:38:46 UTC+1 Rgb Aston napsal(a):
>>>
>>> Which one's the best to go for?
>>>
>>

-- 
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: Auth_user add username field

2016-03-23 Thread Michael Beller
yes - I think something like this could/should work:

db.auth_user.first_name.readable = False



On Wednesday, March 23, 2016 at 8:49:42 PM UTC-4, Jerry Liu wrote:
>
> Thanks! It worked!
>
> I also want to hide First and Last Name fields. At least, I don't want 
> them to be shown on the registration page. Any ideas?
>
> On Wednesday, March 23, 2016 at 5:43:14 PM UTC-7, Michael Beller wrote:
>>
>> no changes should be required to any controller or view.  Everything is 
>> handled by the line:
>> return dict(form=auth())
>>
>> in the default controller (in combination with the default/user.html).
>>
>> The line in db.py just tells auth whether to use a username or email.
>>
>> On Wednesday, March 23, 2016 at 8:16:42 PM UTC-4, Jerry Liu wrote:
>>>
>>> Not sure if I understood, you mean I still have to make changes on View 
>>> and Controller, right?
>>> because adding this line doesn't change anything on login and 
>>> registration views.
>>>
>>> On Wednesday, March 23, 2016 at 4:12:49 PM UTC-7, Michael Beller wrote:
>>>>
>>>> It's easier than that ... just change username=True in db.py, all the 
>>>> web2py components (e.g., log in form, auth_user table, log in menu, etc.) 
>>>> will now support username ...
>>>>
>>>> auth.define_tables(username=True, signature=True)
>>>>
>>>>
>>>>
>>>> On Wednesday, March 23, 2016 at 5:46:38 PM UTC-4, Jerry Liu wrote:
>>>>>
>>>>> Hello, all
>>>>>
>>>>> I want to add a *username* field to auth_user table. I figured out I 
>>>>> can use the following line of code to do so, but how can I use *username 
>>>>> *instead of *email *in login and registration process?
>>>>>
>>>>> auth.settings.extra_fields[auth.settings.table_user_name] = [ Field]
>>>>>
>>>>>
>>>>>

-- 
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: Auth_user add username field

2016-03-23 Thread Michael Beller
no changes should be required to any controller or view.  Everything is 
handled by the line:
return dict(form=auth())

in the default controller (in combination with the default/user.html).

The line in db.py just tells auth whether to use a username or email.

On Wednesday, March 23, 2016 at 8:16:42 PM UTC-4, Jerry Liu wrote:
>
> Not sure if I understood, you mean I still have to make changes on View 
> and Controller, right?
> because adding this line doesn't change anything on login and registration 
> views.
>
> On Wednesday, March 23, 2016 at 4:12:49 PM UTC-7, Michael Beller wrote:
>>
>> It's easier than that ... just change username=True in db.py, all the 
>> web2py components (e.g., log in form, auth_user table, log in menu, etc.) 
>> will now support username ...
>>
>> auth.define_tables(username=True, signature=True)
>>
>>
>>
>> On Wednesday, March 23, 2016 at 5:46:38 PM UTC-4, Jerry Liu wrote:
>>>
>>> Hello, all
>>>
>>> I want to add a *username* field to auth_user table. I figured out I 
>>> can use the following line of code to do so, but how can I use *username 
>>> *instead of *email *in login and registration process?
>>>
>>> auth.settings.extra_fields[auth.settings.table_user_name] = [ Field]
>>>
>>>
>>>

-- 
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] new Starter app (alternative to Welcome app)

2016-03-23 Thread Michael Beller
Are you using 2.14.1 beta?

I would try to get it running without changes before making changes (unless 
you have a need to get it running on an old version of web2py).  As Massimo 
pointed out, it's not necessarily backward compatible but other than 
removing host_names (which I already did in the repo) I don't see why it 
wouldn't work on an older version (I also had to remove formstyle from 
appconfig to support an older version).

I just installed a clean version using 
git clone https://github.com/mjbeller/web2py-starter.git starter
into 2.14.1 beta (actually current master) and then accessed
/initialize/adminuser  
to setup Admin user and auth_groups and everything worked fine.

I'm still getting an odd error on 2.13.x which I can't figure out but I'm 
content to move forward with just 2.14.1

On Wednesday, March 23, 2016 at 8:02:51 PM UTC-4, Ron Chatterjee wrote:
>
> Got it. As always, thank you Massimo. 
>
> I changed in db1.py
>
> auth.define_tables(username=True, signature=True)
>
> to 
> auth.define_tables(username=False, signature=True)
>
> But in  the log in it still ask me for user name. 
>
> Also I get an error when I try to register.
>
> pydal\helpers\classes.py", line 18, in __init__
> return self.__dict__.__init__(*args, **kwargs)
> TypeError: 'NoneType' object is not iterable
>
>
>
> On Wednesday, March 23, 2016 at 7:32:18 PM UTC-4, Massimo Di Pierro wrote:
>>
>> You cannot do that. You have an app created with web2py 2.14.1 beta and 
>> run it with an older version of web2py. myconf.get is not defined.
>> We only offer backward compatibility, not forward compatibility.
>>
>> Massimo
>>
>> On Wednesday, 23 March 2016 18:12:58 UTC-5, Ron Chatterjee wrote:
>>>
>>> I copied the config file from private and changed this to db1.py.
>>>
>>> auth = Auth(db, host_names=myconf.get('host.name'))
>>>
>>> I still don't get the app running. Any suggestions?
>>>
>>> web2py version running: 2.12.3
>>>
>>>
>>>
>>> On Wednesday, March 23, 2016 at 6:36:34 PM UTC-4, Dave S wrote:



 On Wednesday, March 23, 2016 at 3:01:24 PM UTC-7, Literate Aspects 
 wrote:
>
> Hi Rimas,
>
> I thank you for the kind thoughts, but I simply don't have that 
> luxury.  I read and I listen to the video tutorials, IF they matched the 
> current live app, then following the step by step instructions would be 
> straight forward, but the live app does not match the instructions, so at 
> each step, one has to FIGURE out an unknown.
>
>
 The only difference I recognized in the screen shots was that the book 
 had 1 more line in the header comment.  The code lines you showed seemed 
 to 
 match.  But recognize that the code included in the Welcome app (which is 
 the code that gets used if you pressed the "Make new App" button on the 
 Web2Py "console" page) can get changed every release; the book tends not 
 to 
 change as often.

 Some of these changes are simplification, some are taking advantage of 
 new features, and some are corrections.

 Going back to one of your earlier questions:

 def index(): return "Hello from MyApp"

 differs from 

 def index(): return dict(message="Hello from MyApp")

 in a basic Python way ... the first returns a string, the second 
 returns a dictionary object, where the key "message" has the value "Hello 
 from MyApp:, which is a string.  The generic views that come with Web2Py 
 know how to render a string.  They also know how to render values 
 retrieved 
 from a dictionary.  Just about everything else is a special case of those 
 2 
 basic capabilities.

 The BEAUTIFY() helper Rimas mentioned is something that gets executed 
 on the server (in rendering the views) to generate HTML that shows what's 
 in the object given as it's argument.  If that argument is a dictionary 
 like the above, it will render a short table showing the key ("message") 
 and its value ("Hello From MyApp").

 Chapter 2 covers some Python basics, and general Python tutorials and 
 books are available elsewhere.  If you're totally new to programming, than 
 you may want to spend some time on those.  If you're used to C or C# or 
 Java, Chapter 2 may be enough to get you started.

 Good luck!

 /dps





-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] new Starter app (alternative to Welcome app)

2016-03-23 Thread Michael Beller
I changed auth = Auth(db, host_names=myconf.get('host.name'))
to auth = Auth(db) for backwards compatibility (I think host_names will be 
introduced in the upcoming release)

That should fix that problem.

Are you having another problem?  I'm actually having a problem with the old 
pydal in old versions and can't find the problem - but it's working with 
current 2.14.1

Could you try using the current Version 
2.14.1-beta+timestamp.2016.03.23.16.47.51 ?  That's what I developed 
against.

Would love to find the problem supporting old versions though!


On Wednesday, March 23, 2016 at 7:12:58 PM UTC-4, Ron Chatterjee wrote:
>
> I copied the config file from private and changed this to db1.py.
>
> auth = Auth(db, host_names=myconf.get('host.name'))
>
> I still don't get the app running. Any suggestions?
>
> web2py version running: 2.12.3
>
>
>
> On Wednesday, March 23, 2016 at 6:36:34 PM UTC-4, Dave S wrote:
>>
>>
>>
>> On Wednesday, March 23, 2016 at 3:01:24 PM UTC-7, Literate Aspects wrote:
>>>
>>> Hi Rimas,
>>>
>>> I thank you for the kind thoughts, but I simply don't have that luxury.  
>>> I read and I listen to the video tutorials, IF they matched the current 
>>> live app, then following the step by step instructions would be straight 
>>> forward, but the live app does not match the instructions, so at each step, 
>>> one has to FIGURE out an unknown.
>>>
>>>
>> The only difference I recognized in the screen shots was that the book 
>> had 1 more line in the header comment.  The code lines you showed seemed to 
>> match.  But recognize that the code included in the Welcome app (which is 
>> the code that gets used if you pressed the "Make new App" button on the 
>> Web2Py "console" page) can get changed every release; the book tends not to 
>> change as often.
>>
>> Some of these changes are simplification, some are taking advantage of 
>> new features, and some are corrections.
>>
>> Going back to one of your earlier questions:
>>
>> def index(): return "Hello from MyApp"
>>
>> differs from 
>>
>> def index(): return dict(message="Hello from MyApp")
>>
>> in a basic Python way ... the first returns a string, the second returns 
>> a dictionary object, where the key "message" has the value "Hello from 
>> MyApp:, which is a string.  The generic views that come with Web2Py know 
>> how to render a string.  They also know how to render values retrieved from 
>> a dictionary.  Just about everything else is a special case of those 2 
>> basic capabilities.
>>
>> The BEAUTIFY() helper Rimas mentioned is something that gets executed on 
>> the server (in rendering the views) to generate HTML that shows what's in 
>> the object given as it's argument.  If that argument is a dictionary like 
>> the above, it will render a short table showing the key ("message") and its 
>> value ("Hello From MyApp").
>>
>> Chapter 2 covers some Python basics, and general Python tutorials and 
>> books are available elsewhere.  If you're totally new to programming, than 
>> you may want to spend some time on those.  If you're used to C or C# or 
>> Java, Chapter 2 may be enough to get you started.
>>
>> Good luck!
>>
>> /dps
>>
>>
>>
>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Auth_user add username field

2016-03-23 Thread Michael Beller
It's easier than that ... just change username=True in db.py, all the 
web2py components (e.g., log in form, auth_user table, log in menu, etc.) 
will now support username ...

auth.define_tables(username=True, signature=True)



On Wednesday, March 23, 2016 at 5:46:38 PM UTC-4, Jerry Liu wrote:
>
> Hello, all
>
> I want to add a *username* field to auth_user table. I figured out I can 
> use the following line of code to do so, but how can I use *username *instead 
> of *email *in login and registration process?
>
> auth.settings.extra_fields[auth.settings.table_user_name] = [ Field]
>
>
>

-- 
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] new Starter app (alternative to Welcome app)

2016-03-23 Thread Michael Beller
Hi Ramos,

I found the problem.

using appconfig for formstyle doesn't work in older versions (it appears 
that it doesn't recognize the underscore).

I hardcoded the formstyle in db1.py and updated the repo

You can refresh from the repo (there's been some other small enhancements) 
or in models/db1.py change this
response.formstyle = myconf.get('forms.formstyle')

to this
response.formstyle = 'bootstrap3_inline'

that should work in older web2py versions

On Wednesday, March 23, 2016 at 2:27:04 PM UTC-4, Ramos wrote:
>
> 2.12.13
>
> 2016-03-23 17:15 GMT+00:00 Michael Beller <mjbe...@gmail.com 
> >:
>
>> That may be a problem with an earlier version of web2py.  I'm testing now 
>> on trunk, i.e., the master branch of web2py.  I noticed this earlier but 
>> haven't been able to see what's changed in master vs. previous versions.  
>> Anybody know?
>>
>> What version of web2py are you using?
>>
>> I should probably move Starter to the stable release.
>>
>> On Wednesday, March 23, 2016 at 1:08:10 PM UTC-4, Ramos wrote:
>>>
>>> error in login/register
>>> [image: Imagem inline 1]
>>>
>>> 2016-03-23 17:07 GMT+00:00 António Ramos <ramst...@gmail.com>:
>>>
>>>> i cannot log in or register...
>>>>
>>>> 2016-03-23 12:13 GMT+00:00 Michael Beller <mjbe...@gmail.com>:
>>>>
>>>>> I just added the appconfig.ini to the repo since that will cause 
>>>>> confusion.  It contained the item for host_names supported by the current 
>>>>> web2py in trunk.
>>>>>
>>>>> auth = Auth(db, host_names=myconf.get('host.name'))
>>>>>
>>>>> Since I'm not sure what that is for, I just changed it back to:
>>>>>
>>>>> auth = Auth(db)
>>>>>
>>>>> in /models/db1.py
>>>>>
>>>>> Update your appconfig.ini to include the host_names entry (the 
>>>>> appconfig.ini in the repo on github contains the entry)
>>>>> OR
>>>>> Remove the host_names parameter from the call to Auth on line 58 
>>>>> in /models/db1.py
>>>>>
>>>>> That should get your local copy working (and eliminate the confusion 
>>>>> for future downloads or clones)
>>>>>
>>>>> On Wednesday, March 23, 2016 at 7:47:37 AM UTC-4, Ramos wrote:
>>>>>>
>>>>>> I already copied appconfig.ini to private
>>>>>>
>>>>>> but next error...
>>>>>>
>>>>>> [image: Imagem inline 1]
>>>>>> then i changed auth above to just
>>>>>> auth=auth(db)
>>>>>>
>>>>>> and now i could open the app but when i go to login or sign up i get 
>>>>>> another error
>>>>>>
>>>>>> [image: Imagem inline 2]
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> 2016-03-23 11:41 GMT+00:00 Massimiliano <mbel...@gmail.com>:
>>>>>>
>>>>>>> Just copy
>>>>>>>
>>>>>>> appconfic.ini from welcome/private to starter/private
>>>>>>>
>>>>>>> On Wednesday, March 23, 2016 at 11:19:23 AM UTC+1, Ramos wrote:
>>>>>>>>
>>>>>>>> Nice but i get an error installing it as "starter" application
>>>>>>>> any help ?
>>>>>>>>
>>>>>>>> [image: Imagem inline 1]
>>>>>>>>
>>>>>>>> 2016-03-23 9:40 GMT+00:00 Massimiliano <mbel...@gmail.com>:
>>>>>>>>
>>>>>>>>> Very very nice. 
>>>>>>>>>
>>>>>>>>> Thank you for sharing
>>>>>>>>>
>>>>>>>>> On Wed, Mar 23, 2016 at 3:17 AM, Michael Beller <mjbe...@gmail.com
>>>>>>>>> > wrote:
>>>>>>>>>
>>>>>>>>>> I created a new 'starter' app for the types of data and process 
>>>>>>>>>> management apps I tend to build.
>>>>>>>>>>
>>>>>>>>>> I used https://almsaeedstudio.com/preview as the template and 
>>>>>>>>>> I'm hosting a preview at 
>>>>>>>>>> https://mjbeller.pythonanywhere.com/starter.
>>

Re: [web2py] new Starter app (alternative to Welcome app)

2016-03-23 Thread Michael Beller
That may be a problem with an earlier version of web2py.  I'm testing now 
on trunk, i.e., the master branch of web2py.  I noticed this earlier but 
haven't been able to see what's changed in master vs. previous versions. 
 Anybody know?

What version of web2py are you using?

I should probably move Starter to the stable release.

On Wednesday, March 23, 2016 at 1:08:10 PM UTC-4, Ramos wrote:
>
> error in login/register
> [image: Imagem inline 1]
>
> 2016-03-23 17:07 GMT+00:00 António Ramos <ramst...@gmail.com 
> >:
>
>> i cannot log in or register...
>>
>> 2016-03-23 12:13 GMT+00:00 Michael Beller <mjbe...@gmail.com 
>> >:
>>
>>> I just added the appconfig.ini to the repo since that will cause 
>>> confusion.  It contained the item for host_names supported by the current 
>>> web2py in trunk.
>>>
>>> auth = Auth(db, host_names=myconf.get('host.name'))
>>>
>>> Since I'm not sure what that is for, I just changed it back to:
>>>
>>> auth = Auth(db)
>>>
>>> in /models/db1.py
>>>
>>> Update your appconfig.ini to include the host_names entry (the 
>>> appconfig.ini in the repo on github contains the entry)
>>> OR
>>> Remove the host_names parameter from the call to Auth on line 58 
>>> in /models/db1.py
>>>
>>> That should get your local copy working (and eliminate the confusion for 
>>> future downloads or clones)
>>>
>>> On Wednesday, March 23, 2016 at 7:47:37 AM UTC-4, Ramos wrote:
>>>>
>>>> I already copied appconfig.ini to private
>>>>
>>>> but next error...
>>>>
>>>> [image: Imagem inline 1]
>>>> then i changed auth above to just
>>>> auth=auth(db)
>>>>
>>>> and now i could open the app but when i go to login or sign up i get 
>>>> another error
>>>>
>>>> [image: Imagem inline 2]
>>>>
>>>>
>>>>
>>>>
>>>> 2016-03-23 11:41 GMT+00:00 Massimiliano <mbel...@gmail.com>:
>>>>
>>>>> Just copy
>>>>>
>>>>> appconfic.ini from welcome/private to starter/private
>>>>>
>>>>> On Wednesday, March 23, 2016 at 11:19:23 AM UTC+1, Ramos wrote:
>>>>>>
>>>>>> Nice but i get an error installing it as "starter" application
>>>>>> any help ?
>>>>>>
>>>>>> [image: Imagem inline 1]
>>>>>>
>>>>>> 2016-03-23 9:40 GMT+00:00 Massimiliano <mbel...@gmail.com>:
>>>>>>
>>>>>>> Very very nice. 
>>>>>>>
>>>>>>> Thank you for sharing
>>>>>>>
>>>>>>> On Wed, Mar 23, 2016 at 3:17 AM, Michael Beller <mjbe...@gmail.com> 
>>>>>>> wrote:
>>>>>>>
>>>>>>>> I created a new 'starter' app for the types of data and process 
>>>>>>>> management apps I tend to build.
>>>>>>>>
>>>>>>>> I used https://almsaeedstudio.com/preview as the template and I'm 
>>>>>>>> hosting a preview at https://mjbeller.pythonanywhere.com/starter.
>>>>>>>>
>>>>>>>> I'd welcome any feedback but also wanted to share the code at 
>>>>>>>> https://github.com/mjbeller/web2py-starter for anybody that may 
>>>>>>>> want to explore.
>>>>>>>>
>>>>>>>> I started with the goal to create a new web2py app without using 
>>>>>>>> the Welcome app to help me learn a little more about web2py.  I found 
>>>>>>>> myself slowly adding more and more code (primarily CSS and JS) from 
>>>>>>>> the 
>>>>>>>> Welcome app to support some features such as Smartgrids.  I'd like to 
>>>>>>>> evolve Starter to support the upcoming form.py and grid.py that the 
>>>>>>>> core 
>>>>>>>> team is evaluating and developing.
>>>>>>>>
>>>>>>>> -- 
>>>>>>>> Resources:
>>>>>>>> - http://web2py.com
>>>>>>>> - http://web2py.com/book (Documentation)
>>>>>>>> - http://github.com/web2py/web2py (Source code)
>>>>>>>> - https://code.google.com/p/web2py/issues/list (Repor

Re: [web2py] learning curve?

2016-03-23 Thread Michael Beller
Those should appear after you log in (but are hidden for guests).

Were you logged in?

On Wednesday, March 23, 2016 at 9:25:20 AM UTC-4, billmac...@gmail.com 
wrote:
>
> Hi Michael,
>
> I looked at the preview of the starter app. However I am not seeing the 
> dashboard icons (like attached). Is it something I need to configure in the 
> app or there are some specific setups?
>
> Bill.
>
> On Wednesday, March 23, 2016 at 8:16:23 AM UTC-4, Michael Beller wrote:
>>
>> Hi Jon,
>>
>> I just posted my sample app, called Starter, that uses:
>> https://almsaeedstudio.com/preview
>>
>> You can read about it here:
>> https://groups.google.com/forum/#!topic/web2py/Md-OTq-hi-U%5B1-25%5D
>>
>> and download it here:
>> https://github.com/mjbeller/web2py-starter
>>
>> On Monday, March 21, 2016 at 8:37:52 PM UTC-4, Literate Aspects wrote:
>>>
>>> Hi Thomas,
>>>
>>> Is there anything like: http://is.gd/pzcxYe a UI framework?
>>>
>>> Jon
>>>
>>> On Tuesday, February 9, 2016 at 12:49:54 AM UTC-8, Thomas Bellembois 
>>> wrote:
>>>>
>>>> Hi Jon,
>>>>
>>>> I have spent a long time studying the different Python Web frameworks 
>>>> to develop a small chemical products management application and I have 
>>>> choosen Web2py mainly because of its fast learning curve (and also the 
>>>> active community).
>>>> The official documentation is a really good point to start. 
>>>>
>>>> Start with few pages to play with the model-controller-view structure 
>>>> and see.
>>>>
>>>> Regards,
>>>>
>>>> Thomas
>>>>
>>>> On 09/02/2016 01:25, Literate Aspects wrote:
>>>>
>>>> I tried django ... to discover HUGE learning curve
>>>> I tried Qt ... to discover moderate learning curve
>>>>
>>>> I can amateur code in VBA and want to transfer that same code function 
>>>> to a webapp with database.
>>>>
>>>> My question, how many hours or days or months would it take to develop 
>>>> a simple application that controls a web page to enter data into?
>>>>
>>>> Jon
>>>> -- 
>>>> 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.
>>>>
>>>>
>>>>

-- 
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] learning curve?

2016-03-23 Thread Michael Beller
Hi Jon,

I just posted my sample app, called Starter, that uses:
https://almsaeedstudio.com/preview

You can read about it here:
https://groups.google.com/forum/#!topic/web2py/Md-OTq-hi-U%5B1-25%5D

and download it here:
https://github.com/mjbeller/web2py-starter

On Monday, March 21, 2016 at 8:37:52 PM UTC-4, Literate Aspects wrote:
>
> Hi Thomas,
>
> Is there anything like: http://is.gd/pzcxYe a UI framework?
>
> Jon
>
> On Tuesday, February 9, 2016 at 12:49:54 AM UTC-8, Thomas Bellembois wrote:
>>
>> Hi Jon,
>>
>> I have spent a long time studying the different Python Web frameworks to 
>> develop a small chemical products management application and I have choosen 
>> Web2py mainly because of its fast learning curve (and also the active 
>> community).
>> The official documentation is a really good point to start. 
>>
>> Start with few pages to play with the model-controller-view structure and 
>> see.
>>
>> Regards,
>>
>> Thomas
>>
>> On 09/02/2016 01:25, Literate Aspects wrote:
>>
>> I tried django ... to discover HUGE learning curve
>> I tried Qt ... to discover moderate learning curve
>>
>> I can amateur code in VBA and want to transfer that same code function to 
>> a webapp with database.
>>
>> My question, how many hours or days or months would it take to develop a 
>> simple application that controls a web page to enter data into?
>>
>> Jon
>> -- 
>> 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.
>>
>>
>>

-- 
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] new Starter app (alternative to Welcome app)

2016-03-23 Thread Michael Beller
I just added the appconfig.ini to the repo since that will cause confusion. 
 It contained the item for host_names supported by the current web2py in 
trunk.

auth = Auth(db, host_names=myconf.get('host.name'))

Since I'm not sure what that is for, I just changed it back to:

auth = Auth(db)

in /models/db1.py

Update your appconfig.ini to include the host_names entry (the 
appconfig.ini in the repo on github contains the entry)
OR
Remove the host_names parameter from the call to Auth on line 58 
in /models/db1.py

That should get your local copy working (and eliminate the confusion for 
future downloads or clones)

On Wednesday, March 23, 2016 at 7:47:37 AM UTC-4, Ramos wrote:
>
> I already copied appconfig.ini to private
>
> but next error...
>
> [image: Imagem inline 1]
> then i changed auth above to just
> auth=auth(db)
>
> and now i could open the app but when i go to login or sign up i get 
> another error
>
> [image: Imagem inline 2]
>
>
>
>
> 2016-03-23 11:41 GMT+00:00 Massimiliano <mbel...@gmail.com >:
>
>> Just copy
>>
>> appconfic.ini from welcome/private to starter/private
>>
>> On Wednesday, March 23, 2016 at 11:19:23 AM UTC+1, Ramos wrote:
>>>
>>> Nice but i get an error installing it as "starter" application
>>> any help ?
>>>
>>> [image: Imagem inline 1]
>>>
>>> 2016-03-23 9:40 GMT+00:00 Massimiliano <mbel...@gmail.com>:
>>>
>>>> Very very nice. 
>>>>
>>>> Thank you for sharing
>>>>
>>>> On Wed, Mar 23, 2016 at 3:17 AM, Michael Beller <mjbe...@gmail.com> 
>>>> wrote:
>>>>
>>>>> I created a new 'starter' app for the types of data and process 
>>>>> management apps I tend to build.
>>>>>
>>>>> I used https://almsaeedstudio.com/preview as the template and I'm 
>>>>> hosting a preview at https://mjbeller.pythonanywhere.com/starter.
>>>>>
>>>>> I'd welcome any feedback but also wanted to share the code at 
>>>>> https://github.com/mjbeller/web2py-starter for anybody that may want 
>>>>> to explore.
>>>>>
>>>>> I started with the goal to create a new web2py app without using the 
>>>>> Welcome app to help me learn a little more about web2py.  I found myself 
>>>>> slowly adding more and more code (primarily CSS and JS) from the Welcome 
>>>>> app to support some features such as Smartgrids.  I'd like to evolve 
>>>>> Starter to support the upcoming form.py and grid.py that the core team is 
>>>>> evaluating and developing.
>>>>>
>>>>> -- 
>>>>> 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.
>>>>>
>>>>
>>>>
>>>>
>>>> -- 
>>>> Massimiliano
>>>>
>>>> -- 
>>>> 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.
>>>>
>>>
>>> -- 
>> 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.
>>
>
>

-- 
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] new Starter app (alternative to Welcome app)

2016-03-22 Thread Michael Beller
Thank you!  All due credit to almsaeedstudio.com 
<https://almsaeedstudio.com/preview> for the HTML/CSS/JS template.  I 
modified the template to match the web2py standards and the starter app now 
includes all the capabilities.  I've created a menu item helper to create 
menu items and also included Anthony's appadmin/manage by default for 
administrators.  I'm still using the web2py styling for forms and 
smartgrids (but I use a pattern in the Starter app in the controllers using 
Datatables.net which you can see with the sample Dogs and Persons models). 
 I'd like to create the web2py native form and grid styling but I think it 
may make sense to wait for the new form.py and grid.py that I think Massimo 
is creating for the upcoming release.

One other nice feature - open the site on a mobile phone and it renders 
very nicely with the menus sliding in from the left and right.  I did just 
notice the web2py user login menu doesn't render correctly on my phone so I 
need to fix that.

On Wednesday, March 23, 2016 at 12:31:35 AM UTC-4, Richard wrote:
>
> Michael, 
>
> The preview is really "fucking" nice!!
>
> It that what your starter app is capable really?
>
> Richard
>
> On Tue, Mar 22, 2016 at 10:17 PM, Michael Beller <mjbe...@gmail.com 
> > wrote:
>
>> I created a new 'starter' app for the types of data and process 
>> management apps I tend to build.
>>
>> I used https://almsaeedstudio.com/preview as the template and I'm 
>> hosting a preview at https://mjbeller.pythonanywhere.com/starter.
>>
>> I'd welcome any feedback but also wanted to share the code at 
>> https://github.com/mjbeller/web2py-starter for anybody that may want to 
>> explore.
>>
>> I started with the goal to create a new web2py app without using the 
>> Welcome app to help me learn a little more about web2py.  I found myself 
>> slowly adding more and more code (primarily CSS and JS) from the Welcome 
>> app to support some features such as Smartgrids.  I'd like to evolve 
>> Starter to support the upcoming form.py and grid.py that the core team is 
>> evaluating and developing.
>>
>> -- 
>> 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.
>>
>
>

-- 
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] new Starter app (alternative to Welcome app)

2016-03-22 Thread Michael Beller
I created a new 'starter' app for the types of data and process management 
apps I tend to build.

I used https://almsaeedstudio.com/preview as the template and I'm hosting a 
preview at https://mjbeller.pythonanywhere.com/starter.

I'd welcome any feedback but also wanted to share the code 
at https://github.com/mjbeller/web2py-starter for anybody that may want to 
explore.

I started with the goal to create a new web2py app without using the 
Welcome app to help me learn a little more about web2py.  I found myself 
slowly adding more and more code (primarily CSS and JS) from the Welcome 
app to support some features such as Smartgrids.  I'd like to evolve 
Starter to support the upcoming form.py and grid.py that the core team is 
evaluating and developing.

-- 
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] PyCharm license for web2py dev - who wants?

2015-10-12 Thread Michael Beller
+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/d/optout.


[web2py] Tags and Tag Class (list:reference or many-to-many)

2015-08-17 Thread Michael Beller
I like this approach but I'm getting an error:
type 'exceptions.TypeError' unbound method formatter() must be called 
with Validator instance as first argument (got list instance instead)

Is there a sample app or update with this Tag approach?

On Friday, January 17, 2014 at 1:12:00 PM UTC-5, Massimo Di Pierro wrote:

 list:reference is faster for finding referenced fields
 many-to-many are faster for finding referencing fields.

 Usually categories are nested. I assume you want tags instead of 
 categories (it is more general). I usually use both approaches and 
 de-normalize it. 

 Below there is class Tag (which is a little complex but can be used out of 
 the box) and some example of usage:

 class Tag(object):
 class Validator(object):
 def __call__(self,values):
 if isinstance(values,str):
 values = values.split(',')
 tags = [IS_SLUG.urlify(x) for x in values]
 tags = [x.lower() for x in tags if x]
 return (tags, None)
 def formatter(self,values):
 return ', '.join(values) if values else ''
 @staticmethod
 def represent(v,r=None):
 return SPAN(*(SPAN(t,_class='tag') for t in v)) if v else ''

 @staticmethod
 def after_insert(fields, record_id, field2):
 if 'tags' in fields:
 for tag in fields.tags:
 d = {'name':tag, field2.name:record_id}
 field2.table.insert(**d)

 @staticmethod
 def after_update(dbset,fields,field1,field2):
 if 'tags' in fields:
 subquery = dbset._select(field1.table.id)
 field2._db(field2.belongs(subquery)).delete()
 for tag in fields.tags:
 d = {'name':tag, field2.name:record_id}
 field2.table.insert(**d)

 @staticmethod
 def connect(field1,name=tag):
 db = field1._db
 table = 
 db.define_table(name,Field('name'),Field(field1.name,'reference 
 thing'))
 field2 = table[field1.name]
 field1.requires = Tag.Validator
 field1.widget = SQLFORM.widgets.string.widget
 field1.represent = Tag.represent
 field1.table._after_insert.append(lambda f,u: 
 Tag.after_insert(f,u,field2))
 field1.table._after_update.append(lambda f,u: 
 Tag.after_insert(f,u,field1,field2))

 @staticmethod
 def has_all(field1,tags,name=tag,mode=and):
 db = field1._db
 table = db[name]
 if isinstance(tags,str):
 tags = [tags]
 queries = []
 for tag in tags:
 queries.append(field1.table.id.belongs(db(table.name
 ==tag)._select(table[field1.name])))
 if mode=='and':
 return reduce(lambda a,b:ab, queries)
 else:
 return reduce(lambda a,b:a|b, queries)

 @staticmethod
 def has_any(field1,tags,name=tag):
 return Tag.has_all(field1,tags,name=name,mode=or)

 ### example of usage

 db.define_table('thing', Field('name'), Field('tags','list:string'))
 Tag.connect(db.thing.tags)

 db.thing.insert(name='table', tags=['round','blue'])
 print db(Tag.has_all(db.thing.tags,['round'])).select(db.thing.ALL)
 print db(Tag.has_all(db.thing.tags,['blue'])).select(db.thing.ALL)
 print db(Tag.has_all(db.thing.tags,['red'])).select(db.thing.ALL)
 print db(Tag.has_all(db.thing.tags,['blue', 'round'])).select(db.thing.ALL)
 print db(Tag.has_any(db.thing.tags,['red','round'])).select(db.thing.ALL)

 On Friday, 17 January 2014 03:21:52 UTC-6, Najtsirk wrote:

 Hi,

 I have a dilemma about *list:reference, multiple=True vs. many-to-many 
 with intermediate table.*

 I have Projects which haveto be in several categories. 

 Is it better to use list:reference (to list categories from the 
 categories table) or many-to-many? Which is faster in queries?

 Thanks for the answers.



-- 
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: Field validatio with multiple columns

2015-08-13 Thread Michael Beller
I really like the approach crayzeewulf used here:
http://stackoverflow.com/questions/9683604/composite-key-in-web2py/9685846#9685846


On Wednesday, August 12, 2015 at 11:17:45 PM UTC-4, JC wrote:

 Hello,
 I´ve the following model:

 db.define_table('bsc_input',
 Field('id_p_indicator', db.p_indicator, label=T(
 'Indicator'), notnull=True),
 Field('current_month', 'integer', label=T('Month'), 
 notnull=True),
 Field('current_year', 'integer', label=T('Year'), notnull=
 True),
 Field('current_value', 'float', label=T('Value'), notnull=
 True))  

   and I want to setup a validation  so that I´m sure the combination of  '
 id_p_indicator', 'current_month' and 'current_year' are unique.

 How can I do it ?

 Thanks

 JC


-- 
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: error with list:reference table

2015-08-13 Thread Michael Beller
That prevents the error but it does not render the references using the 
list:reference table _format method, they still appear as a list of id's, 
e.g., [4L, 15L, 9L]

On Thursday, August 13, 2015 at 7:13:56 PM UTC-4, Val K wrote:

 I try 'list:reference table' and it doesn't  work at all ! (even  
 DB-admin!)   (2.12.1-stable+timestamp.2015.08.07.07.22.06  (Running on 
 Rocket 1.2.6, Python 2.7.9)) - run from source on Win7x32
 I got:
 type 'exceptions.TypeError' isinstance() arg 2 must be a class, type, or 
 tuple of classes and typesCode listing

 263.
 264.
 265.
 266.
 267.
 268.

 269.
 270.
 271.
 272.

 if not value:
 return None
 from ..adapters import GoogleDatastoreAdapter
 refs = None
 db, id = self.ref._db, self.ref._id
 if isinstance(db._adapter, GoogleDatastoreAdapter):

 def count(values):
 return db(id.belongs(values)).select(id)
 rx = range(0, len(value), 30)
 refs = reduce(lambda a, b: a  b, [count(value[i:i+30])


 I think it's a little bug, because there is *conditional import* 
 GoogleDatastoreAdapter (only if gae) in the __init__.py of adapters 
 package. Otherwise GoogleDatastoreAdapter = None!
 .../adapters/__init__.py:

 ...

 #: load google adapters if needed
 if gae is not None:
 from .google_adapters import GoogleDatastoreAdapter, GoogleSQLAdapter
 # discouraged, for backward compatibility
 ADAPTERS['gae'] = GoogleDatastoreAdapter
 # add gae adapters
 ADAPTERS['google:datastore'] = GoogleDatastoreAdapter
 ADAPTERS['google:datastore+ndb'] = GoogleDatastoreAdapter
 ADAPTERS['google:sql'] = GoogleSQLAdapter
 else:
 #: make the import available for BaseAdapter
 GoogleDatastoreAdapter = None

 #: make the import available for BaseAdapter - I don't find such import 
 in base.py

 Probably must be:
  if GoogleDatastoreAdapter and isinstance(db._adapter, 
 GoogleDatastoreAdapter):
 I've  corrected it and try - it works but row.render whatever  doesn't:

 type 'exceptions.AttributeError' 'long' object has no attribute 'id'
  it's another small bug in *\helpers\methods.py*   (class *_repr_ref_list*) 
 : 

   else:
 refs = db(id.belongs(value)).select(id)
 return refs and ', '.join(
 _fieldformat(self.ref, x.id) for x in value) or ''


 must be just x (not x.id):

   else:
 refs = db(id.belongs(value)).select(id)
 return refs and ', '.join(
 _fieldformat(self.ref, x) for x in value) or ''


 I've tried it - works





 On Thursday, August 13, 2015 at 6:44:45 AM UTC+3, Michael Beller wrote:

 The error occurs when I use the render() function, e.g., teachers = db(
 db.teacher.id0).select().render(0)

 The render() function works fine without the list:reference fields but 
 fails with the list:reference fields.

 On Wednesday, August 12, 2015 at 11:23:44 PM UTC-4, Massimo Di Pierro 
 wrote:

 It is only when printed in CSV that it represents with the |. It is all 
 fine:

 In [1]: db.define_table(

...: 'school',

...: Field('Name'),

...: format='%(Name)s',

...: migrate=True

...: )

 Out[1]: Table school (id,Name)


 In [2]: 


 In [2]: db.define_table(

...: 'teacher',

...: Field('Name'),

...: Field('schools', 'list:reference school', label='School 
 Villages'),

...: format='%(Name)s',

...: migrate=True

...: )

 Out[2]: Table teacher (id,Name,schools)


 In [3]: 


 In [3]: db.school.insert(Name=a)

 Out[3]: 1L


 In [4]: db.school.insert(Name=b)

 Out[4]: 2L


 In [5]: db.school.insert(Name=c)

 Out[5]: 3L


 In [6]: db.teacher.insert(Name=xxx, schools=[1,2,3])

 Out[6]: 1L


 In [7]: teachers = db(db.teacher.id0).select()


 In [8]: print teachers

 teacher.id,teacher.Name,teacher.schools

 1,xxx,|1|2|3|



 In [9]: print teachers[0].schools

 [1L, 2L, 3L]

 On Wednesday, 12 August 2015 07:55:50 UTC-5, Michael Beller wrote:

 db.define_table(
 'school',
 Field('Name'),
 format='%(Name)s',
 migrate=True
 )

 db.define_table(
 'teacher',
 Field('Name'),
 Field('schools', 'list:reference school', label='School 
 Villages'),
 format='%(Name)s',
 migrate=True
 )

 teachers = db(db.teacher.id0).select().render(0)

 Without the render(), it a Row with the piped school id's, e.g., 
 51,sally,|53|52|

 On Wednesday, August 12, 2015 at 1:50:20 AM UTC-4, Massimo Di Pierro 
 wrote:

 Can you show us minimalist code to reproduce the problem?

 On Tuesday, 11 August 2015 23:03:24 UTC-5, Michael Beller wrote:

 I was using web2py 2.10.4 and encountered the error using 
 list:reference:
 type 'exceptions.TypeError' isinstance() arg 2 must be a class, 
 type, or tuple of classes and types

 I then upgraded to 2.12.2 and applied this fix 
 https://github.com/web2py/pydal

[web2py] Re: error with list:reference table

2015-08-12 Thread Michael Beller
The error occurs when I use the render() function, e.g., teachers = db(
db.teacher.id0).select().render(0)

The render() function works fine without the list:reference fields but 
fails with the list:reference fields.

On Wednesday, August 12, 2015 at 11:23:44 PM UTC-4, Massimo Di Pierro wrote:

 It is only when printed in CSV that it represents with the |. It is all 
 fine:

 In [1]: db.define_table(

...: 'school',

...: Field('Name'),

...: format='%(Name)s',

...: migrate=True

...: )

 Out[1]: Table school (id,Name)


 In [2]: 


 In [2]: db.define_table(

...: 'teacher',

...: Field('Name'),

...: Field('schools', 'list:reference school', label='School 
 Villages'),

...: format='%(Name)s',

...: migrate=True

...: )

 Out[2]: Table teacher (id,Name,schools)


 In [3]: 


 In [3]: db.school.insert(Name=a)

 Out[3]: 1L


 In [4]: db.school.insert(Name=b)

 Out[4]: 2L


 In [5]: db.school.insert(Name=c)

 Out[5]: 3L


 In [6]: db.teacher.insert(Name=xxx, schools=[1,2,3])

 Out[6]: 1L


 In [7]: teachers = db(db.teacher.id0).select()


 In [8]: print teachers

 teacher.id,teacher.Name,teacher.schools

 1,xxx,|1|2|3|



 In [9]: print teachers[0].schools

 [1L, 2L, 3L]

 On Wednesday, 12 August 2015 07:55:50 UTC-5, Michael Beller wrote:

 db.define_table(
 'school',
 Field('Name'),
 format='%(Name)s',
 migrate=True
 )

 db.define_table(
 'teacher',
 Field('Name'),
 Field('schools', 'list:reference school', label='School 
 Villages'),
 format='%(Name)s',
 migrate=True
 )

 teachers = db(db.teacher.id0).select().render(0)

 Without the render(), it a Row with the piped school id's, e.g., 
 51,sally,|53|52|

 On Wednesday, August 12, 2015 at 1:50:20 AM UTC-4, Massimo Di Pierro 
 wrote:

 Can you show us minimalist code to reproduce the problem?

 On Tuesday, 11 August 2015 23:03:24 UTC-5, Michael Beller wrote:

 I was using web2py 2.10.4 and encountered the error using 
 list:reference:
 type 'exceptions.TypeError' isinstance() arg 2 must be a class, type, 
 or tuple of classes and types

 I then upgraded to 2.12.2 and applied this fix 
 https://github.com/web2py/pydal/commit/2172b776b9c41884717902e68900b41c105e0364#diff-114ce07f361177e0669ec9a374ef7d6a
  
 that others referenced in the forums having the same problem.

 Now I'm getting this error:
 type 'exceptions.AttributeError' 'long' object has no attribute 'id'

 The error occurs in the render() function when applied to a query.

 File 
 /Users/MichaelBeller/Dev/w2p-enriched/gluon/packages/dal/pydal/helpers/methods.py,
  line 279, in __call__
 _fieldformat(self.ref, x.id) for x in value) or ''
 File 
 /Users/MichaelBeller/Dev/w2p-enriched/gluon/packages/dal/pydal/helpers/methods.py,
  line 279, in genexpr
 _fieldformat(self.ref, x.id) for x in value) or ''
 AttributeError: 'long' object has no attribute 'id'

 Does anybody else have this problem?

 Thanks.



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: error with list:reference table

2015-08-12 Thread Michael Beller
db.define_table(
'school',
Field('Name'),
format='%(Name)s',
migrate=True
)

db.define_table(
'teacher',
Field('Name'),
Field('schools', 'list:reference school', label='School Villages'),
format='%(Name)s',
migrate=True
)

teachers = db(db.teacher.id0).select().render(0)

Without the render(), it a Row with the piped school id's, e.g., 
51,sally,|53|52|

On Wednesday, August 12, 2015 at 1:50:20 AM UTC-4, Massimo Di Pierro wrote:

 Can you show us minimalist code to reproduce the problem?

 On Tuesday, 11 August 2015 23:03:24 UTC-5, Michael Beller wrote:

 I was using web2py 2.10.4 and encountered the error using list:reference:
 type 'exceptions.TypeError' isinstance() arg 2 must be a class, type, 
 or tuple of classes and types

 I then upgraded to 2.12.2 and applied this fix 
 https://github.com/web2py/pydal/commit/2172b776b9c41884717902e68900b41c105e0364#diff-114ce07f361177e0669ec9a374ef7d6a
  
 that others referenced in the forums having the same problem.

 Now I'm getting this error:
 type 'exceptions.AttributeError' 'long' object has no attribute 'id'

 The error occurs in the render() function when applied to a query.

 File 
 /Users/MichaelBeller/Dev/w2p-enriched/gluon/packages/dal/pydal/helpers/methods.py,
  line 279, in __call__
 _fieldformat(self.ref, x.id) for x in value) or ''
 File 
 /Users/MichaelBeller/Dev/w2p-enriched/gluon/packages/dal/pydal/helpers/methods.py,
  line 279, in genexpr
 _fieldformat(self.ref, x.id) for x in value) or ''
 AttributeError: 'long' object has no attribute 'id'

 Does anybody else have this problem?

 Thanks.



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] error with list:reference table

2015-08-11 Thread Michael Beller
I was using web2py 2.10.4 and encountered the error using list:reference:
type 'exceptions.TypeError' isinstance() arg 2 must be a class, type, or 
tuple of classes and types

I then upgraded to 2.12.2 and applied this fix 
https://github.com/web2py/pydal/commit/2172b776b9c41884717902e68900b41c105e0364#diff-114ce07f361177e0669ec9a374ef7d6a
 
that others referenced in the forums having the same problem.

Now I'm getting this error:
type 'exceptions.AttributeError' 'long' object has no attribute 'id'

  File 
/Users/MichaelBeller/Dev/w2p-enriched/gluon/packages/dal/pydal/helpers/methods.py,
 line 279, in __call__
_fieldformat(self.ref, x.id) for x in value) or ''
  File 
/Users/MichaelBeller/Dev/w2p-enriched/gluon/packages/dal/pydal/helpers/methods.py,
 line 279, in genexpr
_fieldformat(self.ref, x.id) for x in value) or ''
AttributeError: 'long' object has no attribute 'id'

Does anybody else have this problem?

Thanks.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Is the server or client processing Python in the controller?

2015-07-07 Thread Michael Beller
The book has a good overview how a web application works:
http://www.web2py.com/books/default/chapter/29/01/introduction#Model-View-Controller

A browser only processes HTML, CSS, and Javascript. The w2p controller 
processes a view and generates the html, css, and javascript required to 
send to the browser via the http response.

On Tuesday, July 7, 2015 at 5:40:39 PM UTC-4, Phillip wrote:

 I assume python embedded into a view would be processed by the 
 server. This would be useful to know to given the difficulty to say what 
 CPU costs may be. If all is by default processed by the server, would 
 delegating this processing to the client be viable? 


 Any ideas appreciated


-- 
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: Where to call python code for processing (embedded as JS or in controllers)?

2015-07-07 Thread Michael Beller
Why do you want to prevent the server from doing the python processing?

I don't know what you mean by instead of embedding as JS

On Tuesday, July 7, 2015 at 5:40:39 PM UTC-4, Phillip wrote:

 I am having trouble finding anything definitive here. Please help if you 
 have any input, even if short.


 My goal is to prevent the server from doing the python processing. 


 Is this incorrect?: 

 If running the python in the controller function (instead of embedding as 
 JS), the server will do the processing


 Since python functions need to be used in the view for client processing, 
 is there an elegant way to call the python methods in the page? Could you 
 give me an example of a good way to do this with a large script? i.e. 
 returning methods or scripts from the controller, using AJax, etc.

  Am I on the right track?


 Thanks,


 Phillip K


-- 
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: dynamic query on web2py

2015-06-27 Thread Michael Beller
Could you order by a virtual field where the virtual field is a lambda 
returning a random number?
http://www.web2py.com/books/default/chapter/35/06/the-database-abstraction-layer#New-style-virtual-fields--experimental-


On Saturday, June 27, 2015 at 8:28:09 AM UTC-4, 黄祥 wrote:

 yeah, something like that, but i don't know how to do an orderby with 
 random option in web2py. any idea how to achieve it in web2py?

 thanks and best regards,
 stifan


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: bootstrap layout adaption

2015-06-27 Thread Michael Beller
I think it would be fairly straightforward. For any grid you would just 
pass the data using a rows object to the view and create the required 
structure in the template. For any form you have a couple of options but if 
you wanted to use the validators in SQLFORM I think you would set the CSS 
classes as needed in the controller before passing the form to the view.

For the folder structure, just simply move the required components to the 
appropriate folder. You could also just use the folder structure for SB 
Admin 2 and set the response view manually in your controller which is just 
one line of code.

On Friday, June 26, 2015 at 2:23:06 AM UTC-4, Manuele wrote:

 Can anyone tell me if it could be easy to adapt this[1] bootstrap layout 
 in order to be used for a web2py application? 
 The best would be to create a plugin I guess... but the folder structure 
 seams not to fit to web2py standards... 
 Any suggest will be appreciated :) 

 Thank you very mutch 

 Best regards 

 Manuele 

 [1] https://github.com/IronSummitMedia/startbootstrap-sb-admin-2 


-- 
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] Re: sending email

2015-06-24 Thread Michael Beller
If you have two factor auth enabled in gmail you need to authorize app and 
generate unique password

-- 
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] set of rows as input to smart grid

2015-06-24 Thread Michael Beller
You can pass a list of fields using the 'fields' arg of smartgrid

-- 
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: web2pyslices down

2015-05-09 Thread Michael Beller
In the meantime ... http://web2pyslices.pythonanywhere.com/

-- 
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: where are Massimo's lesson sources?

2015-02-22 Thread Michael Beller
Not sure which applications you're referring to but many are here:
https://github.com/mdipierro/web2py-appliances

On Sunday, February 22, 2015 at 3:07:16 AM UTC-8, da...@mail.hebrew.edu 
wrote:

 Hi,
 I'm watching Massimo's lessons, and was wondering if there are sources for
 the applications he is teaching

 thanks,
   danny



-- 
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: how to use groupby and sum() in query or grid?

2015-02-19 Thread Michael Beller
Thank you but I get the following error with that approach:
type 'exceptions.TypeError' list indices must be integers, not Expression

However, I did get this to work:
t = db.items
q = t.id0
usum = t.sales.sum()

usum.tablename = 'items'
usum.readable = True
usum.represent = False
usum.formatter = lambda value:value
usum.label = T('Sales')
usum.table = t

grid = SQLFORM.grid(q,
fields=[t.country, t.state, usum],
groupby=t.country|t.state,
orderby=[t.country, t.state],
)

list = []
list.append(['country','state','sales'])
for row in db(t).select(t.country, t.state, usum, 
groupby=t.country|t.state):
list.append([row.items.country, row.items.state, row[usum]])


On Thursday, February 19, 2015 at 12:29:19 AM UTC-8, 黄祥 wrote:

 please try :
 sum_items = db.items.sales.sum()
 db().select(sum_items, groupby = db.items.country)[sum_items]

 best regards,
 stifan


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] how to use groupby and sum() in query or grid?

2015-02-18 Thread Michael Beller
Given:

db.define_table('items',
Field('country'),
Field('state'),
Field(''product'),
Field(sales', 'integer')

Can you show total sales by country and state?

I can groupby in a grid using groupby=db.items.country|db.items.state but I 
can't find how to include the db.items.sales.sum()

I've been playing with this hack:
https://groups.google.com/forum/#!searchin/web2py/using$20groupby$20and$20sum$20in$20query%7Csort:date/web2py/2dMx-UHbmVs/dAz_V3NWOH4J

I can also just use a query and format the table myself (I don't strictly 
need a 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/d/optout.


[web2py] Re: Best and simpler approach to Inline editing / deleting / appending (jqGrid, Jeditable,etc)

2015-02-09 Thread Michael Beller
I've started using http://www.datatables.net/ primarily for the great 
search and responsive behavior.  I've read about the inline support but 
haven't tried it yet but it looks very good.

The other option that looks very good is http://handsontable.com/ but I've 
only read through the documentation.

On Saturday, February 7, 2015 at 11:00:45 PM UTC-5, clara wrote:

 Hello,

 I know this has been asked before, there are Web2py Slices (some of which 
 seem to be outdated), questions posted here on the subject but somehow it 
 is not clear to me which path I should take to implement a grid with inline 
 editable fields, appendable/deletable records. I am looking to some 
 compact solution which I am not sure it exist that would have the 
 functionality of current *SQLFORM.smartgrid*  but in addition to it: 
 inline editable fields and deletable/appendable records.

 I will greatly appreciate any input on this. 

 Best regards,

 Clara





  


-- 
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: Create new website off entry in database

2014-10-13 Thread Michael Beller
Massimo created a series of videos for a course he taught that included 
some really helpful tutorials and examples.  In one of the videos, he built 
a complete app for Surveys - including the ability to build a list of 
questions, poll for answers, and other features.  I think you'll find the 
answers and some ideas to help you with your app in the video.

I started to build an index of the topics covered by the videos to help me 
go back and review. Unfortunately, I only thought of doing this after I 
watched all 5 videos but I've started to update the index every time I go 
back to find a topic.  The index is only partially complete but does have 
an entry for the Survey app along with the time in the video so you can go 
directly to the spot with the Survey tutorial.

Here's the index:

https://docs.google.com/spreadsheet/ccc?key=0AskUxMwC3JzwdDNYRGtSZ3NTSTVEQ1g1QnBfR0FMa1E

Please feel free to update the index if you watch more of the videos.

On Monday, October 13, 2014 12:20:33 PM UTC-4, LoveWeb2py wrote:

 I currently have this setup in my view:

{{for question in all_questions:}}
 {{if question['difficulty']=='Hard':}}
 li class=paddeda 
 href={{=question['id']}}{{=question['title']}}/a/li
 {{pass}}
 {{else:}}
 {{pass}}

 I want to be able to click on the link and load the question related to 
 the database id in another div. To help with my question from earlier... 
 what is the best way to achieve this?

 On Monday, October 13, 2014 9:58:57 AM UTC-4, LoveWeb2py wrote:

 Hello,

 I'm trying to create an application to help my teacher ask students 
 questions but I'm not quite sure how to structure the MVC. 

 Let's say I have 10 entries in the SQL database and my sql database looks 
 something like this:

 db.define_table('teacher_questions',
 Field('id','integer'),
 Field('title','string'),
 Field('question','string'),
 Field('answer','string'),
 Field('hint','string'),
 Field('comments','string'),
 migrate=False)

 I could do a for loop to return all of the questions, but how could I 
 make a link which points to specific questions. I also want the teacher to 
 be able to add a new question and the list of questions will update 
 automatically. In the page that pops up I want to have an input field which 
 will take the students question and compare it against the answer in the 
 database. If it is right it will use bootstrap success and say correct. If 
 it is wrong it will use the bootstrap error. Is there an app that is 
 already created or a model of a web page I could look at for guidance? I've 
 been struggling with this concept for about a week now which is why I'm 
 reaching out to the experts

 Any help is greatly appreciated...



-- 
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: Create new website off entry in database

2014-10-13 Thread Michael Beller
Massimo put together a series of 5 videos available on YouTube for a class 
he taught that are really helpful. In one of the videos, he walked through 
a tuturial for building a survey app with questions and answers (and other 
features).

You may find it helpful with your app.

I watched all 5 videos but decided afterwards that I should have kept 
notes, like an index or table of contents, for the videos which would have 
been helpful to go back and review specific topics.

I started to create this index afterwards but it's far from complete. 
 However, it does have an entry with the specific video and time within the 
video to help you get to the specific spot.

Here it is: 
https://docs.google.com/spreadsheet/ccc?key=0AskUxMwC3JzwdDNYRGtSZ3NTSTVEQ1g1QnBfR0FMa1E

If you watch more of the video, feel free to add to the index so maybe 
we'll have it become a complete index of all videos available.

On Monday, October 13, 2014 12:20:33 PM UTC-4, LoveWeb2py wrote:

 I currently have this setup in my view:

{{for question in all_questions:}}
 {{if question['difficulty']=='Hard':}}
 li class=paddeda 
 href={{=question['id']}}{{=question['title']}}/a/li
 {{pass}}
 {{else:}}
 {{pass}}

 I want to be able to click on the link and load the question related to 
 the database id in another div. To help with my question from earlier... 
 what is the best way to achieve this?

 On Monday, October 13, 2014 9:58:57 AM UTC-4, LoveWeb2py wrote:

 Hello,

 I'm trying to create an application to help my teacher ask students 
 questions but I'm not quite sure how to structure the MVC. 

 Let's say I have 10 entries in the SQL database and my sql database looks 
 something like this:

 db.define_table('teacher_questions',
 Field('id','integer'),
 Field('title','string'),
 Field('question','string'),
 Field('answer','string'),
 Field('hint','string'),
 Field('comments','string'),
 migrate=False)

 I could do a for loop to return all of the questions, but how could I 
 make a link which points to specific questions. I also want the teacher to 
 be able to add a new question and the list of questions will update 
 automatically. In the page that pops up I want to have an input field which 
 will take the students question and compare it against the answer in the 
 database. If it is right it will use bootstrap success and say correct. If 
 it is wrong it will use the bootstrap error. Is there an app that is 
 already created or a model of a web page I could look at for guidance? I've 
 been struggling with this concept for about a week now which is why I'm 
 reaching out to the experts

 Any help is greatly appreciated...



-- 
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: Total newbie, advice on storing scans

2014-08-21 Thread Michael Beller
Web2py has an 'upload' field type that helps you manage file uploads. 
 Upload is a little bit of a misnomer because you can select the file 
path to store the file (or an existing path) and the blob is not stored in 
the database.

You can read more here:
http://web2py.com/books/default/chapter/29/07/forms-and-validators?search=upload#SQLFORM-and-uploads

There are several good Bootstrap and Jquery plugins that you can use to 
view a lightbox type of layout of your scanned images with the ability to 
zoom on an image rather than download and then open the file which I think 
would be best for your archival type of solution.  Here's just one example:
http://www.bootply.com/71401

There are many discussions on the web2py upload feature in this forum and 
some 'slices' that you may find helpful such as:
http://www.web2pyslices.com/slice/show/1504/manual-uploads

Hope that helps.

Mike

On Wednesday, August 20, 2014 4:03:39 PM UTC-4, Gary Cowell wrote:

 Hi

 I'm writing a web app for my home server to allow me to scan and store 
 images of official correspondence, so I can shred the paper and recycle it. 
  A document archive.

 I have the scanner components written [using pyinsane]

 I have an idea of the models required, tables to hold the sender, date, 
 page number, header ref, header date, received date etc.

 What I want to know is how best to handle the scanning and image storing.

 I don't really [I don't think] want to store the images in the database, 
 be that sqlite or pgsql [or do I?]

 At the moment my python scanner scans the image, and stores it in a 
 directory which is a NFS mount on my NAS. 

 My web2py application would have to read this image and present it for 
 confirmation, checking before storing the index entry, and the path to the 
 image into the database.

 So, firstly, how best to present the scanned image to the user for 
 acceptance, can I do this from an arbitrary location [guessing not], I do 
 have a PIL image in memory, so can I present that in web2py, if I can't 
 link an IMG= to the arbitrary disk location

 Sorry if my questions sound vague, I'm just getting to grips with web2py [ 
 used it a whole 3 days! ]

 Thanks for any pointers. Including NO! YOU FOOL! DON'T DO IT!


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: Strange ajax problem

2014-08-15 Thread Michael Beller
Don't be sorry!  Thanks but I don't see any views in the package - I see
your two functions at the bottom of the default controller but no
corresponding views.  Did I miss them?


On Fri, Aug 15, 2014 at 8:25 AM, Leonel Câmara leonelcam...@gmail.com
wrote:

 I'm sorry I wasn't testing any of this. Have a working example attached.


  --
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list (Report Issues)
 ---
 You received this message because you are subscribed to a topic in the
 Google Groups web2py-users group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/web2py/BfKNToXlKds/unsubscribe.
 To unsubscribe from this group and all its topics, send an email to
 web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Strange ajax problem

2014-08-15 Thread Michael Beller
Perfect - I can't thank you enough!

I saw the code in index right after I sent my other message, I was looking 
for display_page.

Not sure what I did wrong last night (probably just a case of staring at 
code too long) but I see how you added the $.web2py.enableElement.

I just went back and read the OP and I think this is the answer to all the 
problems mentioned.  Your explanation along the way was also very helpful.

Thanks again!

On Friday, August 15, 2014 8:44:39 AM UTC-4, Leonel Câmara wrote:

 I used default/index.html, return_data doesn't need a view as it uses 
 generic.json


-- 
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: Strange ajax problem

2014-08-14 Thread Michael Beller
Thanks Cliff and Niphlod,

I've used ajax several times and think I understand the process.  My 
problem now involves using a form inside a bootstrap modal and using ajax 
to submit the form.  What I meant by web2py intercepting the event was 
that web2py.js registers an event handler for the submit which interferes 
with the modal submit handler.  web2py.js adds the 'disabled' class but 
does not detect the succesful ajax response and then remove the class.

Per Niphlod's request, I've recreated the problem using a minimum of code 
that I've pasted below.  This codes works if I remove web2py.js and fails 
if I leave it.  To recreate, click the button to open the model and then 
click submit on the modal.  You can see the button becomes disabled (even 
if you close and reopen it remains disabled).  In other testing, I also had 
web2py add 'display='none' ' to the target but the code below doesn't do 
that.

Thanks again for your help.

Controller Actions:
def display_page():
   return dict(foo='bar')
def return_data():
data= {'foo':'text processed: %s' % request.vars.formdata}
   return data

View:
{{extend 'layout.html'}}

script
$(document).ready(function() {
$('#note-btn').click(function() {
$('#note-modal').modal({
show: true
   });
   });
$('#note-form').submit(function(e) {
e.preventDefault();
$form= $(this);
$.post('{{=URL('default', 'return_data.json')}}',
   {formdata: $form.serialize()},
   function(data) {$('#form-feedback').html(data.foo);}
   );
   });
});
/script

a href=# id=note-btnOpen modal/a

div id=note-modal class=modal fade tabindex=-1 role=dialog
   div class=modal-dialog
   div class=modal-content
   form class=form-horizontal id=note-form
   div class=modal-header
   button type=button class=close data-dismiss=modal
   span aria-hidden=truetimes;/spanspan class=
sr-onlyClose/span
/button
   h4 class=modal-titleEnter Notes/h4
div class='bg-success text-center' 
id='form-feedback'/div
   /div
div class=modal-body
div class=form-group
div
textarea class=form-control id=note-text 
name=note_text/textarea
   /div
/div
   /div
div class=modal-footer
a class=btn btn-default data-dismiss=modalClose/a

   button type=submit class=btn btn-primarySave Notes
/button
/div
   /form
/div!-- /.modal-content --
   /div!-- /.modal-dialog --
/div!-- /.modal --


On Wednesday, August 13, 2014 11:31:39 PM UTC-4, Cliff Kachinske wrote:

 Here's how I do it and I assume Web2py does something similar when it, for 
 example, resets the Working caption on buttons.

 The Javascript/Jquery whatever in the client changes the state of the 
 button. I do it before sending the ajax post. I don't know how Web2py does 
 it.

 It doesn't matter whether it's JQuery's ajax or Web2py's ajax. The syntax 
 is a little different between the two, but the overall process is the same. 
 The client sends a request that gets routed to a function. The function 
 returns a response.

 In that response you would include, assuming JQuery has been loaded on the 
 page, something like 
 $('#somentity_on_page').whatever_attribute_needs_changing('new state of 
 the attribute');

 Web2py isn't intercepting anything. You push a button, click a link, 
 whatever, the browser sends a request. The request goes to your web server, 
 be it Rocket, Apache, Nginx, any other. The web server sends the request to 
 Web2py because the server is set up that way. Web2py then processes the 
 request and returns a response. 

 Excuse me if I'm interpreting incorrectly, but your questions suggest a 
 certain misunderstanding about what's going on. Chapters 1, 3 and 4 of the 
 Web2py manual provide a pretty good overview of how this all works. If I 
 recall correctly, Wikipedia has some reasonably good articles about http, 
 http requests and http responses.

 On Wednesday, August 13, 2014 6:51:59 PM UTC-4, Michael Beller wrote:

 Thanks ...

 Niphlod - I'll try to create a minimal app to reproduce.

 Cliff - are you suggesting to use the web2py ajax function rather 
 the jQuery post?

 I'm also trying to understand why web2py is intercepting the event and 
 why it doesn't think the response is succesful which I assume is why the 
 button is not re-enabled.

 On Wednesday, August 13, 2014 5:18:42 PM UTC-4, Cliff Kachinske wrote:

 get rid of the target in your ajax call and use ':eval' instead.

 Then reset the button in your response.

 On Sunday, May 4, 2014 9:33:05 AM UTC-4, John Drake wrote:

 I've created a simple ajax form to update a post database.  For some 
 strange reason when I post a new message, the button greys out

[web2py] Re: Strange ajax problem

2014-08-14 Thread Michael Beller
Thanks Limedrop and Cliff,

I found something that appears to work but I don't understand why.  I 
re-read the web2py book and noticed in: 
http://www.web2py.com/books/default/chapter/29/11/jquery-and-ajax#Ajax-form-submission
that the following line was added at the end of the submit handling 
function:

return false;

I added that line and web2py.js no longer adds the 'disabled' class.

I also tried this with a normal form like the example in the book with the 
same results, i.e., this doesn't appear related to the modal but the 
ajax form.

I'm not that proficient with javascript and even less adept with the 
debugging and tracing tools so I'm not able to understand the flow and 
logic.

I'd like to better understand but it appears returning false from the 
submit handler that processes the ajax call solves the problem.  One item 
to note is that this solves the disabled problem but the button does not 
show working ... like a normal web2py submit button.

On Thursday, August 14, 2014 5:42:31 PM UTC-4, Cliff Kachinske wrote:

 Aha, I get what you're doing now. Maybe the simple answer is don't use a 
 submit button. Try something like 

 input type=button class=submit-button id=
 something_created_server_side

 You may have to mess around with the css a bit to get the vertical 
 alignment and height right. This will work around the client side handlers. 


 On Thursday, August 14, 2014 4:20:05 PM UTC-4, Michael Beller wrote:

 Thanks Cliff and Niphlod,

 I've used ajax several times and think I understand the process.  My 
 problem now involves using a form inside a bootstrap modal and using ajax 
 to submit the form.  What I meant by web2py intercepting the event was 
 that web2py.js registers an event handler for the submit which interferes 
 with the modal submit handler.  web2py.js adds the 'disabled' class but 
 does not detect the succesful ajax response and then remove the class.

 Per Niphlod's request, I've recreated the problem using a minimum of code 
 that I've pasted below.  This codes works if I remove web2py.js and fails 
 if I leave it.  To recreate, click the button to open the model and then 
 click submit on the modal.  You can see the button becomes disabled (even 
 if you close and reopen it remains disabled).  In other testing, I also had 
 web2py add 'display='none' ' to the target but the code below doesn't do 
 that.

 Thanks again for your help.

 Controller Actions:
 def display_page():
return dict(foo='bar')
 def return_data():
 data= {'foo':'text processed: %s' % request.vars.formdata}
return data

 View:
 {{extend 'layout.html'}}

 script
 $(document).ready(function() {
 $('#note-btn').click(function() {
 $('#note-modal').modal({
 show: true
});
});
 $('#note-form').submit(function(e) {
 e.preventDefault();
 $form= $(this);
 $.post('{{=URL('default', 'return_data.json')}}',
{formdata: $form.serialize()},
function(data) {$('#form-feedback').html(data.foo);}
);
});
 });
 /script

 a href=# id=note-btnOpen modal/a

 div id=note-modal class=modal fade tabindex=-1 role=dialog
div class=modal-dialog
div class=modal-content
form class=form-horizontal id=note-form
div class=modal-header
button type=button class=close data-dismiss=
 modal
span aria-hidden=truetimes;/spanspan class
 =sr-onlyClose/span
 /button
h4 class=modal-titleEnter Notes/h4
 div class='bg-success text-center' 
 id='form-feedback'/div
/div
 div class=modal-body
 div class=form-group
 div
 textarea class=form-control id=note-text 
 name=note_text/textarea
/div
 /div
/div
 div class=modal-footer
 a class=btn btn-default 
 data-dismiss=modalClose/a
button type=submit class=btn btn-primarySave 
 Notes/button
 /div
/form
 /div!-- /.modal-content --
/div!-- /.modal-dialog --
 /div!-- /.modal --


 On Wednesday, August 13, 2014 11:31:39 PM UTC-4, Cliff Kachinske wrote:

 Here's how I do it and I assume Web2py does something similar when it, 
 for example, resets the Working caption on buttons.

 The Javascript/Jquery whatever in the client changes the state of the 
 button. I do it before sending the ajax post. I don't know how Web2py does 
 it.

 It doesn't matter whether it's JQuery's ajax or Web2py's ajax. The 
 syntax is a little different between the two, but the overall process is 
 the same. The client sends a request that gets routed to a function. The 
 function returns a response.

 In that response you would include, assuming JQuery has been loaded on 
 the page, something like 
 $('#somentity_on_page

[web2py] Re: Strange ajax problem

2014-08-14 Thread Michael Beller
Thanks Leonel - awesome explanation.  I looked through your code that you 
posted to load forms in modals and handle file uploads - I need to study 
more.

One question - you say below you're using web2py's ajax convenience 
function which doesn't care about what it's doing - I'm actually not using 
the web2py ajax function but rather the jQuery post function.  Did you mean 
to say jQuery's post function which doesn't care vs. the web2py ajax 
function which would then hand the disabling/enabling of form elements?



On Thursday, August 14, 2014 9:56:20 PM UTC-4, Leonel Câmara wrote:

 In a jquery event handler returning false is the same as calling 
 event.preventDefault and event.stopPropagation that's why you don't get the 
 Working... anymore, you are stopping web2py.js handlers for submission from 
 being processed. Namely this one:

   $(doc).on('submit', 'form', function () {
 var submit_button = $(this).find(web2py.formInputClickSelector);
 web2py.disableElement(submit_button);
   });

 Which is what disables the button and puts the Working... there. 

 The reason you're having problems is that you're using web2py's ajax 
 convenience function which doesn't care about what it's doing, it just 
 cares about submitting form inputs. So it never sets the form handlers 
 which re-enable the buttons.

 One thing you can do is disable the element yourself in your submit 
 handler using $.web2py.disableElement

 And then have something like:

 $(document).on('ajax:complete', '#myForm', function (e) {
 $.web2py.enableFormElements($(this));
   });



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Strange ajax problem

2014-08-14 Thread Michael Beller
Thanks Leonel,

I tried both options but couldn't get them to work - or at least I haven't 
found the right combination.

I also created a simple ajax form using the example in the book to apply 
your two recommendations.  I could only get it to work with the 'return 
false' statement but that would not disable the button to prevent double 
submission.  If I remove the 'return false' statement, the button shows 
'working ...' but the target is not updated.

I'm still trying to learn what's happening so thanks for your explanations.

{{extend 'layout.html'}}

div id=target/div

form id=myform
 input name=your_message id=your_message /
 input type=submit /
/form

script
jQuery('#myform').submit(function() {
ajax('{{=URL('new_post')}}',
['your_message'], 'target');
//return false;
});
/script


On Thursday, August 14, 2014 10:54:19 PM UTC-4, Leonel Câmara wrote:

 Using your jquery post code or web2py's ajax function would give you the 
 same problem with the button that you're preventing with return false.

 Basically, if you want you can just remove return false from your submit 
 handler and add this to your javascript:

 $(document).on('ajax:complete', '#myForm', function (e) {
 $.web2py.enableFormElements($(this));
   });

 replacing myForm with your form's id and have it working.

 Another option is to not put that javascript and simulate a trapped form 
 by setting data-w2p_target which will make web2py.js form_handlers fire as 
 they will think it's a trapped form:

 form class=form-horizontal id=note-form data-w2p_target


 I think either option will work (I'm not testing this). So:
 1. Remove return false
 2. Either add the javascript or the data-w2p_target attribute to the form.
 3. ???
 4. Profit!



-- 
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: Strange ajax problem

2014-08-13 Thread Michael Beller
I just encountered the same problem.  I'm using a Bootstrap Modal form and 
encountering the same problem - the form sends and receives data via AJAX 
but then adds the 'disabled' class to the button.

I found this logic in web2py.js but I'm not clear on what's happening and 
why:

// Form input elements disabled during form submission
disableSelector: 'input, button, textarea, select',
// Form input elements re-enabled after form submission
enableSelector: 'input:disabled, button:disabled, textarea:disabled, 
select:disabled',

Have either of you found a solution?

On Sunday, August 3, 2014 2:53:50 PM UTC-4, Reza Amindarbari wrote:

 Did you figure out what was wrong? I faced the same issue. Everything 
 works fine when I take out the ajax function.

 On Sunday, May 4, 2014 9:33:05 AM UTC-4, John Drake wrote:

 I've created a simple ajax form to update a post database.  For some 
 strange reason when I post a new message, the button greys out.

 Here is the model:

 db.define_table('t_post',
 Field('f_post', type='text',
   label=T('Post')),
 auth.signature,
 format='%(f_post)s')

 Here are my controller functions.

 def ajax_post():
 posts = crud.select(db.t_post, fields=['f_post'], query = 
 db.t_post.created_by == auth.user,
headers={'t_post.f_post': 'Post'}, orderby = 
 ~db.t_post.created_on)
 search = crud.search(db.t_post)
 return dict(posts=posts, search=search)

 def new_post():
 postdata = request.vars.post
 db.t_post.insert(f_post = postdata)
 posts = crud.select(db.t_post, fields=['f_post'], query = 
 db.t_post.created_by == auth.user,
headers={'t_post.f_post': 'Post'}, orderby = 
 ~db.t_post.created_on)
 return posts

 Here is the model:

 {{extend 'layout.html'}}
 h1This is the default/ajax_post.html template/h1
 form onsubmit=return false
 divPost : input name=post//div
 divbutton onclick=ajax('new_post', ['post'],'results')Post 
 Message/button/div
 /form
 div id=results
 {{=posts}}
 /div
 div
 {{=search[0]}}
 /div

 At first I used an input field with type submit for the submit button.  
 When that happened, it would 
 grey out and the value would set to Working.  At least now button 
 text doesn't change, but it
 it still grey's out.  Inspecting the element in Firefox I get:

 button value=Working... class=btn disabled onclick=ajax('new_post', 
 ['post'],'results')Post Message/button

 Why?  I didn't ask it to change the button's class to disabled.  And it 
 stays greyed even though
 the results have returned and my results div has been properly 
 updated.  I can still click on
 the button, but it just appears disabled. 



-- 
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: Strange ajax problem

2014-08-13 Thread Michael Beller
Thanks Niphlod,

I'm not using inline JS or explicitly using web2py.js.

I'm using a Bootstrap Modal pretty much verbatim from the Bootstrap 
examples.  It appears that web2py js is capturing the submit and disabling 
the button but not detecting the response and enabling the submit - is that 
correct? should I not use the Bootstrap js?

Here's my function:
$('#note-form').submit(function(e) {
e.preventDefault();
$form= $(this);
$.post(/app/controller/action.json,
   {formdata: $form.serialize(),
note_id: $('#note-id').val(),
note_text: $('#note-text').val()
   },
   function(data) {
   $('#form-feedback').html(data.notes).fadeIn(500);
   $form[0].reset();
   }
   );
   });


On Wednesday, August 13, 2014 4:29:47 PM UTC-4, Niphlod wrote:

 the logic behind is suppressing double submission. web2py disables the 
 submit button when you click on it until a proper response is returned. 
 Don't EVER use inline javascript, and don't use web2py.js internal 
 functions without proper knowledge of the inner workings :-P  

 On Wednesday, August 13, 2014 8:52:25 PM UTC+2, Michael Beller wrote:

 I just encountered the same problem.  I'm using a Bootstrap Modal form 
 and encountering the same problem - the form sends and receives data via 
 AJAX but then adds the 'disabled' class to the button.

 I found this logic in web2py.js but I'm not clear on what's happening and 
 why:

 // Form input elements disabled during form submission
 disableSelector: 'input, button, textarea, select',
// Form input elements re-enabled after form submission
 enableSelector: 'input:disabled, button:disabled, textarea:disabled, 
 select:disabled',

 Have either of you found a solution?

 On Sunday, August 3, 2014 2:53:50 PM UTC-4, Reza Amindarbari wrote:

 Did you figure out what was wrong? I faced the same issue. Everything 
 works fine when I take out the ajax function.

 On Sunday, May 4, 2014 9:33:05 AM UTC-4, John Drake wrote:

 I've created a simple ajax form to update a post database.  For some 
 strange reason when I post a new message, the button greys out.

 Here is the model:

 db.define_table('t_post',
 Field('f_post', type='text',
   label=T('Post')),
 auth.signature,
 format='%(f_post)s')

 Here are my controller functions.

 def ajax_post():
 posts = crud.select(db.t_post, fields=['f_post'], query = 
 db.t_post.created_by == auth.user,
headers={'t_post.f_post': 'Post'}, orderby = 
 ~db.t_post.created_on)
 search = crud.search(db.t_post)
 return dict(posts=posts, search=search)

 def new_post():
 postdata = request.vars.post
 db.t_post.insert(f_post = postdata)
 posts = crud.select(db.t_post, fields=['f_post'], query = 
 db.t_post.created_by == auth.user,
headers={'t_post.f_post': 'Post'}, orderby = 
 ~db.t_post.created_on)
 return posts

 Here is the model:

 {{extend 'layout.html'}}
 h1This is the default/ajax_post.html template/h1
 form onsubmit=return false
 divPost : input name=post//div
 divbutton onclick=ajax('new_post', ['post'],'results')Post 
 Message/button/div
 /form
 div id=results
 {{=posts}}
 /div
 div
 {{=search[0]}}
 /div

 At first I used an input field with type submit for the submit 
 button.  When that happened, it would 
 grey out and the value would set to Working.  At least now button 
 text doesn't change, but it
 it still grey's out.  Inspecting the element in Firefox I get:

 button value=Working... class=btn disabled 
 onclick=ajax('new_post', ['post'],'results')Post Message/button

 Why?  I didn't ask it to change the button's class to disabled.  And it 
 stays greyed even though
 the results have returned and my results div has been properly 
 updated.  I can still click on
 the button, but it just appears disabled. 



-- 
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: Strange ajax problem

2014-08-13 Thread Michael Beller
Thanks ...

Niphlod - I'll try to create a minimal app to reproduce.

Cliff - are you suggesting to use the web2py ajax function rather 
the jQuery post?

I'm also trying to understand why web2py is intercepting the event and why 
it doesn't think the response is succesful which I assume is why the button 
is not re-enabled.

On Wednesday, August 13, 2014 5:18:42 PM UTC-4, Cliff Kachinske wrote:

 get rid of the target in your ajax call and use ':eval' instead.

 Then reset the button in your response.

 On Sunday, May 4, 2014 9:33:05 AM UTC-4, John Drake wrote:

 I've created a simple ajax form to update a post database.  For some 
 strange reason when I post a new message, the button greys out.

 Here is the model:

 db.define_table('t_post',
 Field('f_post', type='text',
   label=T('Post')),
 auth.signature,
 format='%(f_post)s')

 Here are my controller functions.

 def ajax_post():
 posts = crud.select(db.t_post, fields=['f_post'], query = 
 db.t_post.created_by == auth.user,
headers={'t_post.f_post': 'Post'}, orderby = 
 ~db.t_post.created_on)
 search = crud.search(db.t_post)
 return dict(posts=posts, search=search)

 def new_post():
 postdata = request.vars.post
 db.t_post.insert(f_post = postdata)
 posts = crud.select(db.t_post, fields=['f_post'], query = 
 db.t_post.created_by == auth.user,
headers={'t_post.f_post': 'Post'}, orderby = 
 ~db.t_post.created_on)
 return posts

 Here is the model:

 {{extend 'layout.html'}}
 h1This is the default/ajax_post.html template/h1
 form onsubmit=return false
 divPost : input name=post//div
 divbutton onclick=ajax('new_post', ['post'],'results')Post 
 Message/button/div
 /form
 div id=results
 {{=posts}}
 /div
 div
 {{=search[0]}}
 /div

 At first I used an input field with type submit for the submit button.  
 When that happened, it would 
 grey out and the value would set to Working.  At least now button 
 text doesn't change, but it
 it still grey's out.  Inspecting the element in Firefox I get:

 button value=Working... class=btn disabled onclick=ajax('new_post', 
 ['post'],'results')Post Message/button

 Why?  I didn't ask it to change the button's class to disabled.  And it 
 stays greyed even though
 the results have returned and my results div has been properly 
 updated.  I can still click on
 the button, but it just appears disabled. 



-- 
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] How do you display created_by and modified_by names and not id's when using lazy tables?

2014-08-06 Thread Michael Beller
When I set lazy_tables=True in the DAL, all my signatures fields show the 
user_id and not the user name.

I also set db.auth_user._format = '%(last_name)s' which I thought would 
force the auth_user definition with lazy tables but my signatures still 
show id's.

Any thoughts on what I'm missing?

Also, if I use lazy_tables=False and still set db.auth_user._format = 
'%(last_name)s' the created_by and modified_by fields in view forms still 
shows the full name which I can override 
with auth.signature.created_by.represent = lambda id: db.auth_user._format 
% db.auth_user[id].  Is that the best way?

-- 
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: list all users with membership of a group

2014-06-18 Thread Michael Beller
 

This will give you a list of user id's:

db(db.auth_membership.group_id==3).select(db.auth_membership.user_id)

This will give you all the user information for each user:

db(db.auth_membership.group_id==3).select(db.auth_user.ALL, 
left=db.auth_membership.on(db.auth_user.id == db.auth_membership.user_id))

On Wednesday, June 18, 2014 4:32:33 AM UTC-4, BlueShadow wrote:

 Hi folks,
 I want to display all members of auth_group.id 3
 but for some reason I got a blokade and can't get it to work.
 thanks for your help.


-- 
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] Bug with upload widget when using digitally signed URL's?

2014-06-15 Thread Michael Beller
I'm trying to secure file downloads.  I use user_signature=True for an 
action that generates an edit form that includes an upload field.  The 
upload widget generates a download link but the link appends the file name 
arg after the signature var.

I'm using:
crud.settings.download_url = URL('dcoument', 'download', 
args=document.customer, user_signature=True)

I'm then using:
form = crud.update(...)

This creates a download link like
/document/download/51?_signature=signature/filename
instead of
/document/download/51/filename?_signature=signature

On a related topic, I'm using that extra arg above to create separate 
folders for each customer (useful for multi tenant) but this breaks 
appadmin uploads and download links.  It would be great to use a lambda for 
the upload folder, something like ...

db.define_table('document',
Field('customer', 'reference customer'),
Field('document', 'upload', autodelete=True, 
uploadfolder=lambda r: (request.folder + 'document/download/' + 
row.customer)),
)

-- 
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] Is there a method to force a user to change their password?

2014-06-13 Thread Michael Beller
Also, what is the password reset key used for?

I see in some posts information about registration key but not 
registration identifier - what is the identifier used for?

if registration_key=='' : user can login 

if registration_key=='blocked' : user account is blocked 

if registration_key=='pending' : user account requires approval 

if registration_key==uuid : user account requires email verification 

-- 
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: Is there a method to force a user to change their password?

2014-06-13 Thread Michael Beller
Thanks Massimo, Is there a method to force a user to change their password, 
e.g., after uploading a list of users?

On Friday, June 13, 2014 1:07:32 PM UTC-4, Massimo Di Pierro wrote:

 Good question. 

 registration_id is used by web2py with federated authentication to map a 
 local user to the federated id. For example the id could be a google id or 
 an openid of a cas is.

 registration_key is a random key assigned to the user when they register 
 if the registration requires verification. It is  user to authenticate user 
 in the verify function until the email is verified. Once the email is 
 verified, the registration_key is set to .
 if the registration requires approval, after email verification, the 
 registration_key is set to pending and the administrator has to manually 
 deleted to approve the user.

 At any point the administrator can set a user registration_key to 
 blocked to prevent the user from logging in.

 The password_reset_key  is the uuid used to identify a user when they ask 
 for a password reset link. the uuid appears in the link and expires when 
 the user resets the password.


 On Friday, 13 June 2014 09:50:48 UTC-5, Michael Beller wrote:

 Also, what is the password reset key used for?

 I see in some posts information about registration key but not 
 registration identifier - what is the identifier used for?

 if registration_key=='' : user can login 

 if registration_key=='blocked' : user account is blocked 

 if registration_key=='pending' : user account requires approval 

 if registration_key==uuid : user account requires email verification 



-- 
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: Uploading with SQLFORM.factory: specifying tablename component of filename

2014-06-05 Thread Michael Beller
web2py renames the file as a security measure to prevent directory 
traversal attacks.  You can read more about it here ...
http://www.web2py.com/books/default/search/29?search=traversal
and here ...
http://en.wikipedia.org/wiki/Directory_traversal_attack

As you point out, web2py stores the new file name in the upload field (that 
field initially contains the cgi.FieldStorage() object for the file itself 
and then it's replaced with the new file name).  Rather than store the 
original file name in that field, you may want to consider storing the 
original file name in a separate field.  You can do this using a compute 
field.

Field('original_file_name', compute=doc_filename)

and then ...

def doc_filename(row):
if request.vars.upload_field_name != None and not isinstance(request.
vars.upload_field_name, str):
return request.vars.upload_field_name.filename

Note that because request.vars. upload_field_name initially contains a 
cgi.FieldStorage() object you can't just use 
if request.vars. upload_field_name and since it is then replaced with the 
filename you need to test for the filename string for edits/updates.

Also note that I found the instructions in the book to store the original 
filename
(
http://www.web2py.com/books/default/chapter/29/07/forms-and-validators?search=original+filename#Storing-the-original-filename
)
was not sufficient to update the original filename for edit/update forms.

I also was able to also store the file size and file type using compute 
fields and these statements:

def doc_filetype(row):
if request.vars.upload_field_name != None and not isinstance(request.
vars.upload_field_name, str):
return request.vars.upload_field_name.filename.split('.')[-1]

def doc_filesize(row):
if request.vars.upload_field_name != None and not isinstance(request.
vars.upload_field_name, str):
return request.env.content_length


On Thursday, June 5, 2014 7:46:32 PM UTC-4, Spokes wrote:

 When you upload a file with SQLFORM factory, the file is assigned a name 
 along the lines of no_table.[something1].[something2] If you've 
 manually written the form validation/accept code, you can change the file 
 name that is stored in the table by changing the form.vars.[name_of_field] 
 variable corresponding to the file. I'm changing the no_table prefix of 
 the filename to the name of the corresponding table, for example. This 
 changes the table entry for the file name, but does not modify the name of 
 the uploaded file itself. 

 How does one modify the name of the file that is uploaded without using 
 SQLFORM.factory's tablename argument? Thank you.


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: How to update the stored original filename for upload field using smartgrid edit form?

2014-06-04 Thread Michael Beller
I used compute fields and it now works fine.  Unless I did something wrong, 
the instructions in the book for storing the original filename only work 
for the initial insert and does not address updating the field that 
contains the original filename during an update.

Here is my final code (I know there are other threads that discuss how to 
store file attributes for upload fields):

def contracts_filename(row):
if request.vars.survey != None and not isinstance(request.vars.survey, 
str):
return request.vars.survey.filename

def contracts_filetype(row):
if request.vars.survey != None and not isinstance(request.vars.survey, 
str):
return request.vars.survey.filename.split('.')[-1]

def contracts_filesize(row):
if request.vars.survey != None and not isinstance(request.vars.survey, 
str):
return request.env.content_length

db.define_table('contracts',
Field('person', 'reference person'),
Field('survey_filename', compute=contracts_filename),
Field('survey_filetype', compute=contracts_filetype),
Field('survey_filesize', 'integer', compute=
contracts_filesize),
Field('survey', 'upload', autodelete=True), # uploadfolder 
== would be nice if this supported lambda's!!
Field('description'),
auth.signature
)

and my controller ...

def index():
grid=SQLFORM.smartgrid(db.person,
   fields=[db.contracts.person, db.contracts.
survey_filename, db.contracts.survey_filesize,
   db.contracts.survey_filetype, db.
contracts.survey, db.contracts.description
   ]
   )
return dict(grid=grid)

Two extra items to note:

   - I don't think the size stored is exactly correct since it's using 
   content-length but this is close enough for my purposes
   - The compute fields do not display in edit forms by default so you must 
   explicitly list them in the smartgrid (or grid, sqlform) fields argument.
   

On Monday, June 2, 2014 9:03:32 AM UTC-4, Michael Beller wrote:

 I'm trying to store the original filename, filetype, and filesize for an 
 upload field using a smartgrid.

 I can add these fields during the insert (by setting the field defaults) 
 but not update the fields if you update the uploaded file.  The edit form 
 does upload the new file but I don't know how to then update the stored 
 attributes.  The upload field, request.vars.survey, initially contains the 
 cgi.FieldStorage object during insert (from the new form).  However, the 
 edit form then contains the string for the new filename in 
 request.vars.survey unless their is a new file submitted.  But I don't know 
 how to update the stored file attributes for the form before the smartgrid 
 processes the updated upload file.

 db.define_table('person',
 Field('first_name'),
 Field('last_name'),
 auth.signature,
 format = '%(first_name)s %(last_name)s'
 )

 db.define_table('contracts',
 Field('person', 'reference person'),
 Field('survey_filename', writable=False),
 Field('survey_filetype', writable=False),
 Field('survey_filesize', 'integer', writable=False),
 Field('survey', 'upload', autodelete=True),
 Field('description'),
 auth.signature
 )

 def index():

 if request.vars.survey != None and not type(request.vars.survey) is 
 str:
 db.contracts.survey_filename.default = request.vars.survey.filename
 db.contracts.survey_filesize.default = request.env.content_length
 db.contracts.survey_filetype.default = 
 request.vars.survey.filename.split('.')[-1]
 
 grid=SQLFORM.smartgrid(db.person)
 return dict(grid=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/d/optout.


[web2py] Re: Scheduler

2014-06-04 Thread Michael Beller
You can't use the web2py scheduler but you can create your own simple 
version.

Here is more information from the python anywhere forum:

https://www.pythonanywhere.com/forums/topic/179/

Basically you can launch web2py periodically, e.g., once an hour or once 
per day, and execute a module that can perform anything you want.  You 
could also process the tasks in the task table and their associated actions.

On Wednesday, June 4, 2014 11:00:06 AM UTC-4, Tom Russell wrote:

 I have implemented the scheduler per the info and examples in Chapter 4 of 
 the book. I am trying to start the workers but my problem is I am not sure 
 how to since my app is hosted on pythonanywhere and according to the book I 
 need to do it from the interface from where you set the ip and port.

 Is there another way to do this?

 Thanks.


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: user roles

2014-06-03 Thread Michael Beller
confirm that you have a logged in user first 

On Tuesday, June 3, 2014 3:00:18 AM UTC-4, Yebach wrote:

 If I use your if statement in my controller, this is the error I get

 type 'exceptions.AttributeError' 'Auth' object has no attribute 
 'user_groups'

 why??


 On Monday, June 2, 2014 3:13:26 PM UTC+2, Michael Beller wrote:

 If the user is logged in, then auth.user_groups contains a dictionary of 
 the user's roles.  You can also use auth.has_membership('role name') to 
 check membership.

 You can search auth.user_groups for a role, e.g.,
 if any (role in ['customer_service', 'admin'] for role in auth.
 user_groups.itervalues()): 

 On Monday, June 2, 2014 8:53:55 AM UTC-4, Yebach wrote:

 Hello

 I am trying to get user's role looking into membership table etc.

 Following all the codes on majority of forums my code does not work. 

 this is my controller 

 from gluon.tools import Auth

 database = request.cookies['mycookie'].value
 db = DAL('postgres://postgres:postg...@195.xxx.yyy.zzz/' + database, 
 migrate=False)
 auth = Auth(db)

 def index():
 if not auth.is_logged_in():

 login_adress= auth.settings.login_url = URL('user','user', 
 args='login') 
 redirect (login_adress)
 
 print auth.user_id ###Works

 print auth.user_group ### result is bound method Auth.user_group of 
 gluon.tools.Auth object at 0x0A307F28
 print auth.has_membership(auth.id_group('Member'),auth.user.id)

 type 'exceptions.AttributeError' 'NoneType' object has no attribute 
 'role'

 Also, If I try with some DAL select sentances none of them work. error 
 is usually

 if code is 
  rows = db(db.auth_user).select()

 or 

 rows = db((db.auth_user.email == 
 auth.user.email)(db.auth_membership.user_id == auth.user_id)(
 db.auth_group.id
 ==db.auth_membership.group_id)).select(db.auth_group.ALL)

 error is 

 type 'exceptions.KeyError' 'auth_user'

 what am I doing wrong here. It is a f#$# simple ask. Get user role so 
 I can get a user a specific view based on that role (btw any suggestions on 
 that would be nice).

 thank you



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: user roles

2014-06-03 Thread Michael Beller
I just tested and reread your original post.

auth.user_groups is a dict containing the id and role for each auth_group 
for the logged in user
auth.user_group is a method of auth

from the book:

auth.user_groups contains a dictionary where each key is the id of a group 
of with the current logged in user is member of, the value is the 
corresponding group role.

auth.user_group(user_id) returns the id of the group uniquely associated 
to the user identified by user_id.

This should work for both logged-in and logged-out users:
if any (role in ['customer_service', 'admin'] for role in auth.user_groups.
itervalues()):



On Tuesday, June 3, 2014 9:02:19 AM UTC-4, Michael Beller wrote:

 confirm that you have a logged in user first 

 On Tuesday, June 3, 2014 3:00:18 AM UTC-4, Yebach wrote:

 If I use your if statement in my controller, this is the error I get

 type 'exceptions.AttributeError' 'Auth' object has no attribute 
 'user_groups'

 why??


 On Monday, June 2, 2014 3:13:26 PM UTC+2, Michael Beller wrote:

 If the user is logged in, then auth.user_groups contains a dictionary 
 of the user's roles.  You can also use auth.has_membership('role name') to 
 check membership.

 You can search auth.user_groups for a role, e.g.,
 if any (role in ['customer_service', 'admin'] for role in auth.
 user_groups.itervalues()): 

 On Monday, June 2, 2014 8:53:55 AM UTC-4, Yebach wrote:

 Hello

 I am trying to get user's role looking into membership table etc.

 Following all the codes on majority of forums my code does not work. 

 this is my controller 

 from gluon.tools import Auth

 database = request.cookies['mycookie'].value
 db = DAL('postgres://postgres:postg...@195.xxx.yyy.zzz/' + database, 
 migrate=False)
 auth = Auth(db)

 def index():
 if not auth.is_logged_in():

 login_adress= auth.settings.login_url = URL('user','user', 
 args='login') 
 redirect (login_adress)
 
 print auth.user_id ###Works

 print auth.user_group ### result is bound method Auth.user_group 
 of gluon.tools.Auth object at 0x0A307F28
 print auth.has_membership(auth.id_group('Member'),auth.user.id)

 type 'exceptions.AttributeError' 'NoneType' object has no attribute 
 'role'

 Also, If I try with some DAL select sentances none of them work. error 
 is usually

 if code is 
  rows = db(db.auth_user).select()

 or 

 rows = db((db.auth_user.email == 
 auth.user.email)(db.auth_membership.user_id == auth.user_id)(
 db.auth_group.id
 ==db.auth_membership.group_id)).select(db.auth_group.ALL)

 error is 

 type 'exceptions.KeyError' 'auth_user'

 what am I doing wrong here. It is a f#$# simple ask. Get user role so 
 I can get a user a specific view based on that role (btw any suggestions 
 on 
 that would be nice).

 thank you



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: How to change SQLFORM smartgrid title

2014-06-03 Thread Michael Beller
I believe smartgrid uses the table _plural attribute for the first item in 
the smarrgrid breadcrumb.  If _plural is not set, it uses the table name 
and a pluralization function to create the name.

You can set the attributes in the define table method, e.g., 
singular=Dog, plural=Dogs

You can also set directly right before you create the smartgrid with:
db.dog._plural = 'dogs'

Many, maybe all, of the attributes are exposed using a leading underscore 
so they won't conflict with field names.

On Tuesday, June 3, 2014 9:52:38 AM UTC-4, LoveWeb2py wrote:

 Noob question -- I searched around and couldn't find an answer on how to 
 change the SQLFORM.smartgrid label which displays the name of the database.

 I know you can set fields in a table by typing label='newName', but how 
 can I change the table name itself so it doesn't display the table name in 
 smartgrid (and its also plural)


-- 
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] web2py function import not working well

2014-06-03 Thread Michael Beller
Some of the code in the functions and classes not displayed in your 
original post may reference web2py globals and environment variables.

I think (I'm still learning web2py also) that running your code in the 
shell then has access to the web2py environment.  Modules do not have 
access automatically (unlike models and controllers and views).  You have 
to explicitly give your module functions and classes access to the web2py 
globals, environment, etc. either by importing them in the module or 
passing them as arguments.

Here's one thread that has some more information:
https://groups.google.com/forum/#!searchin/web2py/modules$20environment/web2py/FIF1JnBjuIY/f8-6QwXPpDkJ

There's also a good slice on web2pyslices that gives an example.

On Tuesday, June 3, 2014 3:30:02 PM UTC-4, Maurice Waka wrote:


 When I work with the same module on python shell, its perfectly printing 
 out. I dont know why it does not print on web2py. Basically I imported it 
 without editing from python shell. Anyway since am new to web2py and 
 python, you could help out
 On Tuesday, June 3, 2014, Derek sp1...@gmail.com javascript: wrote:
  Sorry, but it looks like it's doing what you are asking of it. Perhaps 
 you should comment your code to make sure it's doing what you are thinking 
 it's doing.
  you are instantiating a new filters class, giving it the name 'o', then 
 you get a list of the contents of that class, run them if possible, and 
 then you are instantiating a new filters class, naming it 'result', kinda 
 like 'o' was and then you are returning it. Why? What's the point of 
 doing all that if 'o' is never going to be used? you might as well take 
 that out since you are just returning a new class instance anyway.
 
 
  On Tuesday, June 3, 2014 2:50:48 AM UTC-7, Maurice Waka wrote:
 
  from applications.Folders1.modules.myfolder1.main import main
  from applications.Folders1.modules.myfolder1.list1 import GAMES0
  code.
  if id == name3:
  result = location
  return result
 
  else:
  while True:
  class Filters(object):
  def Filter_cause(self):
  for item in name3.split():
  b = False
  for c in FILTERTYPE:
  b = b | (item.find(c) != -1)
  if b:
  for (func) in GAMES0:
  func()
  o = Filters()
  for stuff in dir(o):
  if 'Filter' in stuff:
  getattr(o, stuff)()
 
  result = Filters()
  return result
 
  GAMES0 contains several python modules being imported. My loop works 
 well up to the return location, section but on looping over the 'def class 
 Filters', I get this message:
 
  applications.Folders1.modules.myfolder1.main.Filters object at 
 0x06D689F0
 
  How can I make it to print out my message from any of the modules
 
  --
  Resources:
  - http://web2py.com
  - http://web2py.com/book (Documentation)
  - http://github.com/web2py/web2py (Source code)
  - https://code.google.com/p/web2py/issues/list (Report Issues)
  ---
  You received this message because you are subscribed to a topic in the 
 Google Groups web2py-users group.
  To unsubscribe from this topic, visit 
 https://groups.google.com/d/topic/web2py/JsESNTvfrHQ/unsubscribe.
  To unsubscribe from this group and all its topics, send an email to 
 web2py+un...@googlegroups.com javascript:.
  For more options, visit https://groups.google.com/d/optout.
 

 -- 
 Dr Maurice Waka, MBCHB.
 Nairobi



-- 
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] How to update the stored original filename for upload field using smartgrid edit form?

2014-06-02 Thread Michael Beller
I'm trying to store the original filename, filetype, and filesize for an 
upload field using a smartgrid.

I can add these fields during the insert (by setting the field defaults) 
but not update the fields if you update the uploaded file.  The edit form 
does upload the new file but I don't know how to then update the stored 
attributes.  The upload field, request.vars.survey, initially contains the 
cgi.FieldStorage object during insert (from the new form).  However, the 
edit form then contains the string for the new filename in 
request.vars.survey unless their is a new file submitted.  But I don't know 
how to update the stored file attributes for the form before the smartgrid 
processes the updated upload file.

db.define_table('person',
Field('first_name'),
Field('last_name'),
auth.signature,
format = '%(first_name)s %(last_name)s'
)

db.define_table('contracts',
Field('person', 'reference person'),
Field('survey_filename', writable=False),
Field('survey_filetype', writable=False),
Field('survey_filesize', 'integer', writable=False),
Field('survey', 'upload', autodelete=True),
Field('description'),
auth.signature
)

def index():

if request.vars.survey != None and not type(request.vars.survey) is str:
db.contracts.survey_filename.default = request.vars.survey.filename
db.contracts.survey_filesize.default = request.env.content_length
db.contracts.survey_filetype.default = 
request.vars.survey.filename.split('.')[-1]

grid=SQLFORM.smartgrid(db.person)
return dict(grid=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/d/optout.


[web2py] Re: user roles

2014-06-02 Thread Michael Beller
If the user is logged in, then auth.user_groups contains a dictionary of 
the user's roles.  You can also use auth.has_membership('role name') to 
check membership.

You can search auth.user_groups for a role, e.g.,
if any (role in ['customer_service', 'admin'] for role in auth.user_groups.
itervalues()): 

On Monday, June 2, 2014 8:53:55 AM UTC-4, Yebach wrote:

 Hello

 I am trying to get user's role looking into membership table etc.

 Following all the codes on majority of forums my code does not work. 

 this is my controller 

 from gluon.tools import Auth

 database = request.cookies['mycookie'].value
 db = DAL('postgres://postgres:postg...@195.xxx.yyy.zzz/' + database, 
 migrate=False)
 auth = Auth(db)

 def index():
 if not auth.is_logged_in():

 login_adress= auth.settings.login_url = URL('user','user', 
 args='login') 
 redirect (login_adress)
 
 print auth.user_id ###Works

 print auth.user_group ### result is bound method Auth.user_group of 
 gluon.tools.Auth object at 0x0A307F28
 print auth.has_membership(auth.id_group('Member'),auth.user.id)

 type 'exceptions.AttributeError' 'NoneType' object has no attribute 
 'role'

 Also, If I try with some DAL select sentances none of them work. error is 
 usually

 if code is 
  rows = db(db.auth_user).select()

 or 

 rows = db((db.auth_user.email == 
 auth.user.email)(db.auth_membership.user_id == auth.user_id)(
 db.auth_group.id==db.auth_membership.group_id)).select(db.auth_group.ALL)

 error is 

 type 'exceptions.KeyError' 'auth_user'

 what am I doing wrong here. It is a f#$# simple ask. Get user role so I 
 can get a user a specific view based on that role (btw any suggestions on 
 that would be nice).

 thank you


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] best method to check for auth membership (with no DB IO)

2014-05-31 Thread Michael Beller
I've been checking for auth membership to control access to menus and 
access to controller functions.  But they all require significant DB IO ...

Decorators:
@auth.requires_membership()

@auth.requires(lambda: auth.has_membership('customer_service') or auth.
has_membership('admin')) # potentially 4 database queries

@auth.requires(lambda: any([auth.has_membership(r) for r in [
'customer_service', 'admin']))

and

Conditions (e..g, to control menu display):
if auth.user and any (auth.has_membership(r) for r in ['customer_service', 
'admin']): # performs potentially 4 database queries

if auth.has_membership('customer_service'): # performs two database queries

All of the above require DB IO (using the lambda's defers the IO but not 
eliminate it).  After seeing the DB IO using db stats, I started exploring 
auth.user_groups and have tested these two option:

@auth.requires(any (role in ['customer_service', 'admin'] for role in auth.
user_groups.itervalues()))

if any (role in ['customer_service', 'admin'] for role in auth.user_groups.
itervalues()):

Is there any reason to not use these?  I understand auth.user_groups is 
cached but can be updated with auth.update_groups() if needed.


-- 
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: how to determine the server (name) ?

2014-05-30 Thread Michael Beller
Depending on your server and hosting environment, request.env.http_host may 
always return '127.0.0.1:8000' when you're using the browser based shell 
(in admin) or running web2py from console.

I found it was more reliable to use request.env.web2py_path which always 
gave a unique path (in the browser shell, while running web2py from the 
shell, and normally) for the server environment.  I use this to detect my 
dev, test, or prod environment.

-- 
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: AppAdmin: CSV import bug

2014-05-20 Thread Michael Beller
I'm also using Excel on a Mac and had the same problem.  However, if I 
select Windows Comma Separated (.csv) option rather than the default 
Comma Separated Values (.csv) in the Save As ... dialog box the import 
through the appadmin interface works.

On Friday, November 22, 2013 5:49:37 AM UTC-5, Andy W wrote:

 Just come across the same problem -  using ver 2.7.4 with 
 pythonanywhere.com

 The issue seems to be with the csv files created by Excel (I am on Mac 
 OSX). I have a simple 2-column list of ISO country codes and nationalities 
 on an Excel spreadsheet. Saving from Excel to CSV creates a file that, when 
 uploading, creates the above error message. If I use OpenOffice to write 
 the CSV file it uploads without an issue.

 On Thursday, August 8, 2013 12:29:31 PM UTC+4, Massimo Di Pierro wrote:

 Hard to say without an example.

 On Thursday, 8 August 2013 00:07:38 UTC-5, DJ wrote:


 Not able to upload data using CSV import tool, get the following error 
  (perhaps, web2py csv import tool needs to read it in using 'rU' option?) -

 Running Version 2.5.1, Python 2.7, MacOSX. Tested it using a csv file 
 exported out using appadmin's Export/Import tool.

 Unable to parse CSV file:

 new-line character seen in unquoted field - do you need to open the file in 
 universal-newline mode?



-- 
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: color cells based on value in SQLFORM

2014-05-12 Thread Michael Beller
I wouldn't recommend using field names, that would not be very flexible. 
 Here's an option:

db.define.table('status',
Field('name'),
Field('highlight_color'))

db.define.table('inventory',
Field('item'),
Field('status', 'reference status'))

Then just populate the status table with your list of statuses and its 
associated highlight color.  Then in your controller and view, create a 
query for the status colors and a corresponding loop in your view to build 
the list of status styles.  Something like this may work ...

{{for x in status_list:}}
{{=x.name.replace(' ','_')}} {background-color: {{=x.color}}; 
padding:5px;}
{{pass}}

to produce this ...

.Not.Started {background-color: yellow; padding:5px;}
.In.Progress {background-color: green; color:white; padding:5px;}
.Completed {background-color: red; color:white; padding:5px;}
.Deferred {background-color: blue; color:white; padding:5px;}



On Monday, May 12, 2014 1:44:29 PM UTC-4, LoveWeb2py wrote:

 Thank you for your reply, Michael  Anthony.

 Michael: I really like this idea. What would my model look like?

 I setup db.define_table('status',
  Field('id','integer'),
  Field('normal','string'),
  Field('warning','string'),
  migrate=False)

 Would I have to populate the fields or can we just use the field names... 
 I want to make it to where the referenced table allows me to choose a color 
 for the selected column of interest (or cell). 
 So if my column looked like this:
 Item | status
 server | 1

 The server cell would be green.Could I do this?



 On Saturday, May 10, 2014 1:26:51 PM UTC-4, Michael Beller wrote:

 I learned this method from one of Massimo's lecture video's:

 At the top of your model file:
 # function to allow models to set status style
 def show_status(status,row=None):
 return SPAN(status.f_name.replace(' ','_'),_class=status.f_name) 
 ifstatus 
 else status

 After your table definition (could be in your controller but I set the 
 represent after my table definition in my model file so it is consistent 
 across all locations in my app):
 db.table_name.status_field_name.represent = show_status

 Note that in my models db.table_name.status_field_name is a reference 
 field to a status table (so you select from a drop down list to select a 
 status) and the name of the status in the status table is f_name.

 In your CSS (I have one CSS static file for my application for 
 application specific styles that I include in layout.html):
 /* Status styles */
 .Not.Started {background-color: yellow; padding:5px;}
 .In.Progress {background-color: green; color:white; padding:5px;}
 .Completed {background-color: red; color:white; padding:5px;}
 .Deferred {background-color: blue; color:white; padding:5px;}

 I think this is nicer than embedding an if statement with 
 hardcoded styles in your code.


 On Friday, May 9, 2014 4:22:45 PM UTC-4, LoveWeb2py wrote:

 Hello,

 I have a spreadsheet of items and I want to track their inventory based 
 on color (similar to an excel spreadsheet).

 I have two columns for example: Item, Item_Status
 The item could be a desk, chair, etc... and for status I have 1 2 or 3.

 If the status is 1 I would like to make the cell color of the desk 
 green, 2 yellow, 3 red.

 so far I have 

 def represent_colored(value):
if value == 1:
return SPAN(value,_style=background-color:green',)
 elif value == 2:
return SPAN(value,_style=background-color:yellow',)
 elif value == 3:
return SPAN(value,_style=background-color:red',)
 else:
return SPAN(value,_style=background-color:orange',)

 def inventory():
db.inventory.items.represent = lambda value, row: 
 represent_colored(value)
grid=SQLFORM.grid(db.inventory, paginate=20)
return dict(grid=grid)

 This works so far, but it only changes the background color of the text 
 in the status column and I want to change the column of the actual item. I 
 also would like to change the entire cell td instead of just the 
 background behind the text.
 Also, I plan on branching the inventory out to multiple columns and I 
 have two questions:

 1) How could I change the entire cell color?
 2) Is making multiple status columns the most efficient and pythonic 
 way to accomplish this.

 You guys are the best!


 Wil




-- 
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: list:reference

2014-05-12 Thread Michael Beller
I haven't used 'list:reference' before, what are the advantages or use 
cases for your approach rather than add a reference field such as 
Field('daily', 'reference daily') on the post table?

On Monday, May 12, 2014 2:06:01 AM UTC-4, Jesse Ferguson wrote:

 I FIgured it out, I was missing the field name when trying to add values i 
 was doing row.update(data)   instead of   row.update(posts=data)


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: best way to load more db tables via ajax

2014-05-12 Thread Michael Beller
The recipe on pagination in the book may provide some ideas:

http://web2py.com/books/default/chapter/29/14/other-recipes?search=pagination#Pagination

You could then put your list that you're trying to concatenate in an 
ajax load.

On Monday, May 12, 2014 8:49:23 AM UTC-4, Trevor Overman wrote:

 What would be the most effective way to load, for example, 25 more 
 database tables via an ajax function on clicking, for example again, a more 
 button?
 What I am trying to do is load the first 25 tables and have this list 
 concatenated for the next 25 in the sorted list. 
 The problem I'm running across is keeping the sorting intact. I know this 
 could be done by selecting the whole database, but I'm wanting to avoid 
 that. 

 def example():
 table_list = db(db.example).select(limitby=(0, 25))
 return dict(table_list=table_list)


 Thanks for the help! 




-- 
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] What is the best method to format datetimes?

2014-05-11 Thread Michael Beller
I'm not sure of all the pros and cons of using the different methods to 
format a datetime field.

A datetime fields gets a default IS_DATETIME validator and uses the 
calendar widget in forms which uses the language translation files to 
format the field.

You can also specify a format parameter, which the book recommends, in the 
validator, e.g., IS_DATETIME(format=T(%m/%d/%Y %H:%M:%S)).  Would you 
ever need this since the field gets the same function by default?

Those appear to behave the same way (although the first allows empty 
fields).

You can also specify a represent function for the Field.

The language translation for the datetime validator works in grids and 
forms.

The represent function only works in the grids (which can be an advantage 
when trying to display the timezone since the widget does not support %Z 
format element).

In my case, it's further complicated by formatting for timezones which can 
be done with:

Field('dt_field', 'datetime', default=request.utcnow,
requires=IS_DATETIME(timezone=pytz.timezone(America/New_York), 
format=('%x %I:%M %p %Z')))

or

db.sometable. dt_field.represent = lambda value, row:

value.replace(tzinfo=pytz.timezone('UTC')).astimezone(pytz.timezone(America/New_York)).strftime('%x
 
%I:%M %p %Z')

What do you think is the preferred method?

Maybe the best method is to use both:

Field('dt_field', 'datetime', default=request.utcnow,
requires=IS_DATETIME(timezone=pytz.timezone(America/New_York))

db.sometable. dt_field.represent = lambda value, row:
value..strftime('%x %I:%M %p %Z')

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


  1   2   >