[web2py] Re: Getting only the latest "version" in a query of items with versions.
I suppose your right, but I was a little thrown, by the: max(variable_here) That was mentioned was not the solution at all, I kept looking for ways to use max as a function. My issue now, is that the group by doesn't like me getting all the tables I want in the return. BR, Jason Brower On Thursday, August 25, 2016 at 8:36:58 AM UTC+3, Dave S wrote: > > > > On Wednesday, August 24, 2016 at 10:29:09 PM UTC-7, Encompass solutions > wrote: >> >> Does this seem sensible? It seems to work with my initial tests. >> >> latest_versions = db( (db.item.id == db.item_version.artifact_id) & >> (db.item_version.id > 0) >> >> ).select(db.item.ALL,db.item_version.version_date.max(), groupby= >> db.item.id) >> >> the .max() feature, at least what I found, was totally undocumented. >> > > Totally? > You mean, there isn't > > http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#sum--avg--min--max-and-len > > > > ? > > We should have an example database as part of the documentation with a >> collection of examples around it so we can all relate better. :/ >> >> > Examples in book, using it on severity of logged events. > > /dps > > >> 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: Getting only the latest "version" in a query of items with versions.
Grr, And now I can't get the db.item_version.ALL without Postgresql panicking about not having the item in the group buy. How do I get the fields in the result set? Do I need to place it in as a belongs or something? latest_versions = db( (db.item.id == db.item_version.artifact_id) & (db.item_version.id > 0) ).select(db.item.ALL, db.item_version.ALL, db.item_version.version_date.max(), groupby=db.item.id) On Thursday, August 25, 2016 at 8:29:09 AM UTC+3, Encompass solutions wrote: > > Does this seem sensible? It seems to work with my initial tests. > > latest_versions = db( (db.item.id == db.item_version.artifact_id) & > (db.item_version.id > 0) > > ).select(db.item.ALL,db.item_version.version_date.max(), groupby= > db.item.id) > > the .max() feature, at least what I found, was totally undocumented. > We should have an example database as part of the documentation with a > collection of examples around it so we can all relate better. :/ > > 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: Getting only the latest "version" in a query of items with versions.
On Wednesday, August 24, 2016 at 10:29:09 PM UTC-7, Encompass solutions wrote: > > Does this seem sensible? It seems to work with my initial tests. > > latest_versions = db( (db.item.id == db.item_version.artifact_id) & > (db.item_version.id > 0) > > ).select(db.item.ALL,db.item_version.version_date.max(), groupby= > db.item.id) > > the .max() feature, at least what I found, was totally undocumented. > Totally? You mean, there isn't http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#sum--avg--min--max-and-len> ? We should have an example database as part of the documentation with a > collection of examples around it so we can all relate better. :/ > > Examples in book, using it on severity of logged events. /dps > 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: Getting only the latest "version" in a query of items with versions.
Does this seem sensible? It seems to work with my initial tests. latest_versions = db( (db.item.id == db.item_version.artifact_id) & (db.item_version.id > 0) ).select(db.item.ALL,db.item_version.version_date.max(), groupby=db.item.id) the .max() feature, at least what I found, was totally undocumented. We should have an example database as part of the documentation with a collection of examples around it so we can all relate better. :/ 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: records-delete/truncate postgres table in appadmin
app_cleanup is the admin function cleanup to clean session, cache, dll (same like on admin page). yes, you can, app_cleanup is a prevention, because i created the function that truncate all tables including auth_user, so while u are logged in and run truncate for all table it will raises an error after it done, said about privilege because the auth user is empty now. 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: records-delete/truncate postgres table in appadmin
what does app_cleanup do? can I truncate only one table and then run this one line clean = app_cleanup(app, request)? 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.
Re: [web2py] Re: How to enclose items within a link?
thanks guys, both ways work great 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: How to enclose items within a link?
On Wednesday, August 24, 2016 at 3:01:57 PM UTC-4, Alex Glaros wrote: > > How to use web2py redirects to enclose an item? > > For example I want this effect: > > > > > > but instead of I want to use web2py redirect {{=A like this below > > {{=A('', _href=URL('default','documentation'))}} > > {{}} > > 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.
Re: [web2py] Re: How to enclose items within a link?
**{'other_attribute_name': 'other_attribute_value', ...}, after the last named attribute Richard On Wed, Aug 24, 2016 at 3:17 PM, Alex Glaros wrote: > I just tried this and solves my immediate problem, but am still curious if > can enclose items with w2p link. > > {{=A(T(''), _href=URL('default','documentation_relationship_type'), > _style="color:green; font-size:200%;margin:10px 0px 10px 0px; > float:right;padding:10px", _class="glyphicon glyphicon-question-sign")}} > > -- > Resources: > - http://web2py.com > - http://web2py.com/book (Documentation) > - http://github.com/web2py/web2py (Source code) > - https://code.google.com/p/web2py/issues/list (Report Issues) > --- > You received this message because you are 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.
[web2py] Re: How to enclose items within a link?
I just tried this and solves my immediate problem, but am still curious if can enclose items with w2p link. {{=A(T(''), _href=URL('default','documentation_relationship_type'), _style="color:green; font-size:200%;margin:10px 0px 10px 0px; float:right;padding:10px", _class="glyphicon glyphicon-question-sign")}} -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are 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 enclose items within a link?
How to use web2py redirects to enclose an item? For example I want this effect: but instead of I want to use web2py redirect {{=A like this below {{=A('', _href=URL('default','documentation'))}} {{}} 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: Retrieving record id after form.process().accepted
form.vars.id On Wednesday, August 24, 2016 at 12:47:53 PM UTC-4, Gael Princivalle wrote: > > Hello. > > How can I retrieve the record id when the form is accepted? I would like > to use it for redirection. > if form.process().accepted: > redirect(URL('default', 'book', vars=dict(book_id=???))) > > 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: Retrieve custom form input/select value in case of errors
Thank you Mirek for that. Like that it works: {{=INPUT(_type='text', _name='book_title', _id='book_title', _value='form.vars.book_title')}} But web2py don't load the default value set in the table (even before it was like that but I've add it with _value. For having a complete solution I must do something like that: {{if form.vars.book_title:}} {{book_title_value = form.vars.book_title}} {{else:}} {{book_title_value = 'My book title'}} {{pass}} {{=INPUT(_type='text', _name='book_title', _id='book_title', _value= book_title_value)}} Il giorno mercoledì 24 agosto 2016 17:20:20 UTC+2, Mirek Zvolský ha scritto: > > form.vars.book_title ? (book, chapter 7) > > > > > Dne úterý 23. srpna 2016 13:47:34 UTC+2 Gael Princivalle napsal(a): >> >> 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] Retrieving record id after form.process().accepted
Hello. How can I retrieve the record id when the form is accepted? I would like to use it for redirection. if form.process().accepted: redirect(URL('default', 'book', vars=dict(book_id=???))) 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: Retrieve custom form input/select value in case of errors
form.vars.book_title ? (book, chapter 7) Dne úterý 23. srpna 2016 13:47:34 UTC+2 Gael Princivalle napsal(a): > > 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.
Re: [web2py] LDAP authentication and user creation
Ok. Thanks! Good to know that doesn't exist something ready. Will try to find the time to study LDAP and the rest! Bye, Marvi 2016-08-23 15:58 GMT+02:00 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. > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are 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.