{Disarmed} Re: {Disarmed} Re: {Disarmed} Re: {Disarmed} [web2py] Re: Get reference format representation on dal callbacks

2017-12-22 Thread Carlos Cesar Caballero Díaz

Thank you so much!!!

Greetings.


El 19/12/17 a las 11:49, Anthony escribió:
On Tuesday, December 19, 2017 at 8:48:15 AM UTC-5, Carlos Cesar 
Caballero wrote:


Hi Massimo, thanks for your answer, basically I need the row
object instead of the set in the after update callback, I have
managed to do this passing the table object to my plugin and
making a query. But there is a way to know the table that belongs
an after update callback without passing explicitly the table object?

Let's say something like:

model:

from mymoduleimport my_after_update_callback

db.mytable._after_update.append(my_after_update_callback)

mymodule:

def my_after_update_callback(s,f): row = get_callback_row()

 table = get_callback_table()



Updates do not involve fetching the updated records from the database, 
so the DAL does not have any Row objects to provide to the callback. 
If you need the updated records, you'll have to fetch them yourself 
within the callback based on the Set:


|
rows =set.select()
|

Regarding the tablename, you can extract it from the Set as well. In 
most cases, something like the following should work:


|
table =set.query.first.table
|

Note, that will be the actual DAL Table object -- if you want the 
name, you can do set.query.first.tablename.


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 *MailScanner ha detectado un intento de fraude 
en la siguiente p�gina web "groups.google.com". /No/ conf�e en esta 
p�gina web:* 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: {Disarmed} Re: {Disarmed} [web2py] Re: Get reference format representation on dal callbacks

2017-12-19 Thread Anthony
On Tuesday, December 19, 2017 at 8:48:15 AM UTC-5, Carlos Cesar Caballero 
wrote:
>
> Hi Massimo, thanks for your answer, basically I need the row object 
> instead of the set in the after update callback, I have managed to do this 
> passing the table object to my plugin and making a query. But there is a 
> way to know the table that belongs an after update callback without passing 
> explicitly the table object?
>
> Let's say something like:
>
> model:
>
> from mymodule import my_after_update_callback
>
> db.mytable._after_update.append(my_after_update_callback)
>
> mymodule:
>
> def my_after_update_callback(s, f):row = get_callback_row()
>
> table = get_callback_table()
>
>
>
Updates do not involve fetching the updated records from the database, so 
the DAL does not have any Row objects to provide to the callback. If you 
need the updated records, you'll have to fetch them yourself within the 
callback based on the Set:

rows = set.select()

Regarding the tablename, you can extract it from the Set as well. In most 
cases, something like the following should work:

table = set.query.first.table

Note, that will be the actual DAL Table object -- if you want the name, you 
can do set.query.first.tablename.

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.


{Disarmed} Re: {Disarmed} [web2py] Re: Get reference format representation on dal callbacks

2017-12-19 Thread Carlos Cesar Caballero Díaz
Hi Massimo, thanks for your answer, basically I need the row object 
instead of the set in the after update callback, I have managed to do 
this passing the table object to my plugin and making a query. But there 
is a way to know the table that belongs an after update callback without 
passing explicitly the table object?


Let's say something like:

model:

from mymoduleimport my_after_update_callback

db.mytable._after_update.append(my_after_update_callback)

mymodule:

def my_after_update_callback(s,f): row = get_callback_row()

table = get_callback_table()


There is another thing:

Related to this, I am working with the experimental haystack plugin for 
whoosh, but I have made some changes (for using the whoosh backend with 
python3 and other things), but I look that the Github project page has 
no updates and there are unattended pull requests. Is the haystack 
plugin dead?


Greetings.

El 16/12/17 a las 16:44, Massimo Di Pierro escribió:
Can you please provide a complete example of what you want using 
pseudocode?


On Wednesday, 6 December 2017 10:31:57 UTC-6, Carlos Cesar Caballero 
wrote:


Hi, I am building a module (plugin) that is using some "after insert"
and "after uptade" dal callbacks. The tables has references
(relations)
and I need to obtain the referenced table string format instead of
it's
id in the callback, and I need it to be generic. How can I achieve
that?

Greetings.

--
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 *MailScanner ha detectado un intento de fraude 
en la siguiente p�gina web "groups.google.com". /No/ conf�e en esta 
p�gina web:* 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.