how to override "select" method?

37 views
Skip to first unread message

Jurgis Pralgauskis

unread,
Mar 9, 2017, 1:33:42 PM3/9/17
to web2py-users
Hi, 

I want to have extra features for select(..)
And the codebase is already quite big -- imo best would be to implement the features transparently...

I guess I could make derivative of Set class
and override __call__ and select (and maybe _select) If I need this only for reading information?

or should I think of making/deriving Adapter (in my case Postgre and maybe Sqlite)?


ps.:
The features I want to have:
 - our system stores translations for names of different items from different tables...  And I  decorate query and args for select(..) on the fly  (src)
 - virtual fields would know what extra  fields/Expressions they need (src)

Jurgis Pralgauskis

unread,
Mar 9, 2017, 2:15:25 PM3/9/17
to web...@googlegroups.com
One more feature: 
 - I want to get  result of select()   .compact=False by default

--
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/c_BMpcUu8Vg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Jurgis Pralgauskis
tel: 8-616 77613;
Don't worry, be happy and make things better ;)
http://galvosukykla.lt

Leonel Câmara

unread,
Mar 10, 2017, 9:27:55 AM3/10/17
to web2py-users
Note that you can do what you want the first feature for, easily with common filters:

Jurgis Pralgauskis

unread,
Mar 11, 2017, 2:16:00 AM3/11/17
to web...@googlegroups.com
Common filters only add to query,  but I need to change/replace fields/expressions .

Now I think of monkeypatch'ing Set 'select' method (probably inside of objects.py, because I guess Set is imported in different places).

Or maybe I don't need to touch pydal files, if I monkeypatch from db.py some XAdapter in  DAL ADAPTERS. I hope it is single point of XAdapter import.. 

Ps: class method monkeypatching seems quite straightforward https://tryolabs.com/blog/2013/07/05/run-time-method-patching-python/

2017-03-10 04:28 popiet "Leonel Câmara" <leonel...@gmail.com> rašė:
Note that you can do what you want the first feature for, easily with common filters:

--

Leonel Câmara

unread,
Mar 11, 2017, 8:42:13 AM3/11/17
to web2py-users
> Common filters only add to query,  but I need to change/replace fields/expressions .

Why don't you simply change the fields/expressions before running the select?  
  
If it's a matter of representation you can use the fields represent and then render. What exactly are you trying to achieve and why?  
Reply all
Reply to author
Forward
0 new messages