[web2py] Re: i need the information fetch information from an online database, how can i do it with web2py?

2016-08-23 Thread Dave S


On Tuesday, August 23, 2016 at 3:58:40 AM UTC-7, Mirek Zvolský wrote:
>
> What is it "an online database"?
>
> If it has some API, call that API.
> If it is database accessible via TCP/IP, use DAL() with proper connection 
> string.
>
>
Note that the usual form of API would be a restful interface, so you might 
be sending HTTP requests to the remote, and perhaps you'd use URLLIB 
calls.  A JSON API would probably be handled the same way, but a SOAP 
interface would use the SoapClient from pysimplesoap (included with web2py).

/dps


> Dne sobota 20. srpna 2016 23:11:23 UTC+2 karthik naidu napsal(a):
>>
>> i'm planning to do a gps tracker and i need to get information from an 
>> online database , i want to know the method to do it using 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: Limit string length in DAL

2016-08-23 Thread Ron Chatterjee
Ha! 

requires=[IS_NOT_EMPTY(), IS_LENGTH(64)]

And it works like a champ!

On Monday, August 22, 2016 at 7:12:50 PM UTC-4, Ron Chatterjee wrote:
>
> Its all good. Just checking. Thanks for the help Niphlod.
>
> On Monday, August 22, 2016 at 5:11:17 PM UTC-4, Ron Chatterjee wrote:
>>
>> What I want is allowing user to put limited string but they can't submit 
>> the form with an empty field. 
>>
>> requires = IS_EMPTY_OR([IS_LENGTH(8), IS_NOT_EMPTY()] )
>>
>> That don't work. Obviously not because its conflicting. Right? In one 
>> hand I am saying empty or insert value (8) and then saying can't be empty. 
>> Do we have any other validators that I can try which takes those two 
>> arguments?
>>
>> On Monday, August 22, 2016 at 4:06:03 PM UTC-4, Niphlod wrote:
>>>
>>> to my knowledge, the general rule for validators is that if you have 
>>> multiple requirements, you should pass a list.
>>> That being said, the are "special" validator, like IS_EMPTY_OR, that 
>>> take a validator as an argument.
>>>
>>> Goes without saying (it quite translates well), that 
>>> IS_EMPTY_OR(IS_LENGTH(8)) EITHER accepts nothing or a string shorter than 8 
>>> chars.
>>> Now, the "deal". How would you consider a field in a form that is not 
>>> filled ? None or '' ?
>>>
>>> IS_NOT_EMPTY() prevents an empty input.
>>>
>>> it's not clear what you want, but I guess something got cleared with my 
>>> previous comments.
>>> Also, validators ONLY apply when you use them: forms, 
>>> validate_and_insert(), validate_and_update(), etc. Using validators only is 
>>> perfectly fine if you let the app validate each and every input.
>>> length=123 enforces the underlying column to be of that length, but if 
>>> you want meaningful errors, you need to use validators anyways.  
>>>
>>> On Monday, August 22, 2016 at 5:54:29 PM UTC+2, Ron Chatterjee wrote:

 In other words, if I do this: 

 IS_EMPTY_OR(IS_LENGTH(8))

 It prevents longer length string but the empty field is inserted as 
 None. I want to prevent both.


 On Monday, August 22, 2016 at 10:54:08 AM UTC-4, Ron Chatterjee wrote:
>
> Two question, if you don't mind.
>
> (1) requires = IS_NOT_EMPTY(IS_LENGTH(64)) Or requires = 
> IS_EMPTY_OR(IS_LENGTH(64)) Doesn't work. In other words, if I want to 
> limit 
> the string field entry but also want requires not empty, how to go about 
> it?
>
> (2) for my sql, do I still need length = 64 (or 255 etc)? Its 
> redundant when I define IS_LENGTH(64) or do I need both?
>
>
>
>
> On Monday, August 22, 2016 at 7:49:42 AM UTC-4, Niphlod wrote:
>>
>> requires=IS_LENGTH(64) will limit insertion upon validation. the 
>> "length" attribute gets translated, wherever possibile, to 
>> backend-specific 
>> syntaxes.
>>
>> On Sunday, August 21, 2016 at 4:21:22 AM UTC+2, billy...@gmail.com 
>> wrote:
>>>
>>> How we limit string length in DAL? It seems length = 64 doesn't 
>>> work. 
>>>
>>

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


[web2py] Re: Can gluon.contrib.populate work with self reference?

2016-08-23 Thread Ron Chatterjee
I experienced the same, there seem to be some funny thing going on with 
self referencing. 

On Tuesday, August 23, 2016 at 12:30:40 AM UTC-4, pbreit wrote:
>
> Well, just removing the db.commit() made it work as well except that it 
> doesn't populate the self referencing field.
>
> if db(db.comment).count()<2:
> populate(db.comment, 30)
>
>
> On Monday, August 22, 2016 at 9:09:45 PM UTC-7, pbreit wrote:
>>
>> I fixed by specifying:
>>
>> if db(db.comment).count()<2:
>> import random
>> for i in range(1,20):
>> populate(db.comment, 1, contents={'parent_comment': i})
>> db.commit()
>>
>>
>>
>> On Monday, August 22, 2016 at 8:47:48 PM UTC-7, pbreit wrote:
>>>
>>> Trying to populate:
>>>
>>> db.define_table('comment',
>>> Field('post_id', 'reference post'),
>>> Field('parent_comment', 'reference comment'),
>>> Field('body', 'text', requires=IS_NOT_EMPTY()),
>>> Field('votes', 'integer'),
>>> auth.signature)
>>>
>>>
>>> with:
>>>
>>> if db(db.comment).count()<2:
>>> populate(db.comment, 50)
>>> db.commit()
>>>
>>> but getting "IntegrityError: FOREIGN KEY constraint failed" unless I 
>>> remove 'reference comment'
>>>
>>> Is gluon.contrib.populate able to seed a table with a self reference?
>>>
>>

-- 
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] LDAP authentication and user creation

2016-08-23 Thread Richard Vézina
For checking if user exist in LDAP you will need to write your own logic
and query LDAP... For creating the user you have Admin or you can create a
simple form that only admin can use for instance... There is also a way to
provide admin app access by attributing to user a particular role :
http://web2py.com/books/default/chapter/29/09/access-control?search=role#Application-Management-via-privileged-users-Experimental

Or there were badmin app https://github.com/elcio/badmin, but I am not sure
if it still maintained, I remember having read a post saying it wasn't up
to date.

Good luck.

Richard

On Sat, Aug 20, 2016 at 1:59 PM, Marvix  wrote:

> Hello to all.
> I tried LDAP authentication and all work flawless.
>
> As an user logs in, the relative user entry is created in the web2py user
> table. That's great.
>
> But sometimes it would be usefull to have the user in the table before his
> first login.
>
> So, would be great for some user, says an administrator, to have a form
> where he can insert the username of a generic user, web2py checks if the
> user exists in the LDAP server and then add him in the web2py table.
>
> Is there a way?
>
> I'm creating a sort of inventory application for our company.  So I would
> like, for the administrator of the inventory, to associate a good to a
> collegue that maybe hasn't yet logged in the system.
>
> Thanks, Marvi
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: [web2py] Re: An error occured, please reload the page

2016-08-23 Thread Anthony
Also, what version of web2py are you using, and on what platform/browser?

On Tuesday, August 23, 2016 at 8:24:37 AM UTC-4, Anthony wrote:
>
> On Tuesday, August 23, 2016 at 1:12:38 AM UTC-4, mweissen wrote:
>>
>> Anthony,
>>
>> maybe I did not find the right words to describe the situation:.
>>
>>1. While the error message is visible, I *can *edit the page. 
>>2. The "save"-button is not disabled, but it does nothing. No changes 
>>are stored.
>>3. It is clear, that I have to dismiss the message. 
>>4. Again like 1 and 2: I can edit the page, but I cannot store it.
>>5. Therefore I *have to reload* the page - without a reload it is *not 
>>possible to save* the page again, 
>>6. And now the error message returns so fast, that it is not possible 
>>to edit and store the corrected page. We start again with step 1.
>>
>> In that case, I cannot reproduce your problem. I can definitely continue 
> to edit *and* save changes to the file despite the Ajax error (e.g., I 
> can correct the error so on subsequent page reloads I no longer get the 
> Ajax error message).
>
> What happens when you try to save? Do you see any error message? In the 
> browser developer tools, do you see an Ajax request fired off or any errors 
> in the Javascript console?
>
> Anthony
>

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


Re: [web2py] Re: An error occured, please reload the page

2016-08-23 Thread Anthony
On Tuesday, August 23, 2016 at 1:12:38 AM UTC-4, mweissen wrote:
>
> Anthony,
>
> maybe I did not find the right words to describe the situation:.
>
>1. While the error message is visible, I *can *edit the page. 
>2. The "save"-button is not disabled, but it does nothing. No changes 
>are stored.
>3. It is clear, that I have to dismiss the message. 
>4. Again like 1 and 2: I can edit the page, but I cannot store it.
>5. Therefore I *have to reload* the page - without a reload it is *not 
>possible to save* the page again, 
>6. And now the error message returns so fast, that it is not possible 
>to edit and store the corrected page. We start again with step 1.
>
> In that case, I cannot reproduce your problem. I can definitely continue 
to edit *and* save changes to the file despite the Ajax error (e.g., I can 
correct the error so on subsequent page reloads I no longer get the Ajax 
error message).

What happens when you try to save? Do you see any error message? In the 
browser developer tools, do you see an Ajax request fired off or any errors 
in the Javascript console?

Anthony

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


[web2py] Retrieve custom form input/select value in case of errors

2016-08-23 Thread Gael Princivalle
Hello.

In a custom form when the user submit the form with errors I need to reload 
all user inputs and set the input value.

For example here is an input:
{{=INPUT(_type='text', _name='book_title', _id='book_title')}}

How can I do that ?
As there is available on form errors form.errors.book_title is there 
something like form.value.book_title ?

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

2016-08-23 Thread Gael Princivalle
Thank's Mirek I'll do like that.

Il giorno martedì 23 agosto 2016 12:55:43 UTC+2, Mirek Zvolský ha scritto:
>
> In Web2py you can set this in Field(), in db model or in SQLFORM.factory, 
> via requires=.
> Something like:
>
> requires=[IS_NOT_EMPTY_(), IS_DATETIME(format='%d.%m.%Y %H:%M')]
>
>
> And you can use T('%d.%m.%Y %H:%M') and translate format for different 
> locales.
>
>
>
>
> Dne neděle 21. srpna 2016 15:28:18 UTC+2 Gael Princivalle napsal(a):
>>
>> Hello.
>>
>> I'm trying to use Bootstrap 3 datepicker.
>> http://eonasdan.github.io/bootstrap-datetimepicker/
>>
>> Edward have already use it:
>> https://groups.google.com/d/topic/web2py/ZRS6PN-Ais4/discussion
>>
>> I use it for datetime, the result in the input is like:
>> 03/09/2016 14:00
>> The form returns me an error as it need also the seconds like:
>> 03/09/2016 14:00:00
>>
>> The seconds for this application are not important, it could be a 
>> solution appending :00 to the input.
>>
>> Someone knows how I can resolve it?
>>
>> 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: i need the information fetch information from an online database, how can i do it with web2py?

2016-08-23 Thread Mirek Zvolský
What is it "an online database"?

If it has some API, call that API.
If it is database accessible via TCP/IP, use DAL() with proper connection 
string.





Dne sobota 20. srpna 2016 23:11:23 UTC+2 karthik naidu napsal(a):
>
> i'm planning to do a gps tracker and i need to get information from an 
> online database , i want to know the method to do it using 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: Bootstrap 3 datepicker

2016-08-23 Thread Mirek Zvolský
In Web2py you can set this in Field(), in db model or in SQLFORM.factory, 
via requires=.
Something like:

requires=[IS_NOT_EMPTY_(), IS_DATETIME(format='%d.%m.%Y %H:%M')]


And you can use T('%d.%m.%Y %H:%M') and translate format for different 
locales.




Dne neděle 21. srpna 2016 15:28:18 UTC+2 Gael Princivalle napsal(a):
>
> Hello.
>
> I'm trying to use Bootstrap 3 datepicker.
> http://eonasdan.github.io/bootstrap-datetimepicker/
>
> Edward have already use it:
> https://groups.google.com/d/topic/web2py/ZRS6PN-Ais4/discussion
>
> I use it for datetime, the result in the input is like:
> 03/09/2016 14:00
> The form returns me an error as it need also the seconds like:
> 03/09/2016 14:00:00
>
> The seconds for this application are not important, it could be a solution 
> appending :00 to the input.
>
> Someone knows how I can resolve it?
>
> 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: Getting only the latest "version" in a query of items with versions.

2016-08-23 Thread Niphlod
what you want is the latest version for each item_id . That is the row 
having the greatest version_date if you divide your dataset for each 
item_id.

that is what groupby item_id does. and what max(version_date) does too.

On Tuesday, August 23, 2016 at 11:05:52 AM UTC+2, Encompass solutions wrote:
>
> This document doesn't mention your method or using max()
>
>
> http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#sum-avg-min-max-and-len
>
> Or I don't understand how you would do it.
> Could you provide greater detail on how to build that query?
> BR,
> Jason
>
> On Monday, August 22, 2016 at 10:52:55 AM UTC+3, Encompass solutions wrote:
>>
>> Consider the following pseudo model.
>>
>> item
>>  ->name = "string"
>>
>> version
>>  ->item_id =  item.id
>>  ->version_date = "datetime"
>>
>>
>> While I can easily create a collection of the item with it's versions.
>> all_items = db((db.item.id > 0) & (db.version.item_id == db.item.id
>> )).select(orderby=db.item.name | db.version.version_date)
>>
>> How do get just all items with just the latest version of each item 
>> without having to do this
>> items = []
>> current_id = all_items.first().item.id 
>> for thing in all_items:
>> if thing.item.id != current_id:
>> current_id = thing.item.id
>> items.append(thing)
>>
>> It seems a bit silly and heavy to be doing this especially since my data 
>> could get quite large.  I imaging the database has some way to do this, 
>> just never learned how.
>>
>> Ideas on how this could be done?
>>
>> BR,
>> Jason Brower
>>
>>

-- 
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 make repository on github for windows users?

2016-08-23 Thread Niphlod
you download git for windows and do the same exact thing as in linux

On Tuesday, August 23, 2016 at 6:02:17 AM UTC+2, Dmitri Ermolaev wrote:
>
> What steeps?

-- 
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: Getting only the latest "version" in a query of items with versions.

2016-08-23 Thread Encompass solutions
This document doesn't mention your method or using max()

http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#sum-avg-min-max-and-len

Or I don't understand how you would do it.
Could you provide greater detail on how to build that query?
BR,
Jason

On Monday, August 22, 2016 at 10:52:55 AM UTC+3, Encompass solutions wrote:
>
> Consider the following pseudo model.
>
> item
>  ->name = "string"
>
> version
>  ->item_id =  item.id
>  ->version_date = "datetime"
>
>
> While I can easily create a collection of the item with it's versions.
> all_items = db((db.item.id > 0) & (db.version.item_id == db.item.id
> )).select(orderby=db.item.name | db.version.version_date)
>
> How do get just all items with just the latest version of each item 
> without having to do this
> items = []
> current_id = all_items.first().item.id 
> for thing in all_items:
> if thing.item.id != current_id:
> current_id = thing.item.id
> items.append(thing)
>
> It seems a bit silly and heavy to be doing this especially since my data 
> could get quite large.  I imaging the database has some way to do this, 
> just never learned how.
>
> Ideas on how this could be done?
>
> BR,
> Jason Brower
>
>

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