I would think it would make more sense to use the _before_update callback.
Then you could simply select the records to be updated and add the relevant
fields to the update fields before the update happens. Instead, though, I
would probably just handle it all more explicitly -- before making the
I´m moving my computed fields from db.entities to another table
db.entities_wf_fields and then i use
db.entities_after_update.append(lambda s,f: update_authors(s,f))
db.entities._after_update.append(lambda s,f: update_readers(s,f))
etc...
then
def update_authors(set,ufields):
record = set.select(
So should i use instead ?
_after_update.append(lambda s,f: function_2_compute_some_fields(s,f))
or will i trigger a recursive update and hang the cpu?
regards
2017-06-30 19:35 GMT+01:00 Anthony :
> On Friday, June 30, 2017 at 11:45:37 AM UTC-4, Ramos wrote:
>>
>> Another problem or symptom is th
On Friday, June 30, 2017 at 11:45:37 AM UTC-4, Ramos wrote:
>
> Another problem or symptom is that the computed function need the record
> update call to pass all the fields the computed function needs to access
> otherwise does not execute.
>
> for example
>
> my record with id =1
> {"event":"
Another problem or symptom is that the computed function need the record
update call to pass all the fields the computed function needs to access
otherwise does not execute.
for example
my record with id =1
{"event":"1","created_by":4,"status":21}
this line
db(db.entities.id==1).update(event="2
My error again...
during the computation i retieve from auth_membership the user_id
i had to convert to int otherwise i would return a function
Regard
2017-06-30 11:29 GMT+01:00 António Ramos :
> this test code
>
> db(db.entities.id==473).update(status=21)
>
> does note trigger the computed fie
this test code
db(db.entities.id==473).update(status=21)
does note trigger the computed field on record 473 that takes status and
does some computation
Thank you
2017-06-29 14:13 GMT+01:00 António Ramos :
> Solved again...
>
> Thank you
>
> 2017-06-29 14:03 GMT+01:00 Anthony :
>
>> if not
Solved again...
Thank you
2017-06-29 14:03 GMT+01:00 Anthony :
> if not *record["created_by"]()* in ret:
>> ret.append(*record["created_by"]()*)
>>
>>
> That's different from the code you showed earlier. Probably you should
> just do something like this:
>
> created_by = record['crea
>
> if not *record["created_by"]()* in ret:
> ret.append(*record["created_by"]()*)
>
>
That's different from the code you showed earlier. Probably you should just
do something like this:
created_by = record['created_by']
created_by = created_by() if callable(created_by) else created_
Aparently not solved...
*function lazy_user at 0x2d82a28*
disappears but the field authors does not update anymore
if i go to admin to save a record i get this error
if not record["created_by"]() in ret:
TypeError: 'int' object is not callable
this is my new code
def get_userIds(rule):
Solved.
Thank you again Anthony
2017-06-28 19:21 GMT+01:00 Anthony :
> In auth.signature, the "created_by" field has a "default" attribute, which
> is a function (called "lazy_user") that returns auth.user_id. At the point
> at which the value of the compute field is computed, the row object pass
In auth.signature, the "created_by" field has a "default" attribute, which
is a function (called "lazy_user") that returns auth.user_id. At the point
at which the value of the compute field is computed, the row object passed
to the compute function simply includes the "lazy_user" function as the
On Tuesday, May 23, 2017 at 11:39:17 AM UTC-4, runru...@gmail.com wrote:
>
> this feels like checkmate.
>
Why? Just write a function that accepts a form as an argument (you don't
have to actually do anything with the form in the function) and does the
inserts, and use that as the register_onacce
this feels like checkmate. I did get the 'is not callable' error as you
anticipated. Is there an avenue that I don't see? At this point I am
resigned to running the code a bunch of times and creating a bunch of
lists; then assign one to each user; any advice before I go down that road?
On
On Sunday, May 21, 2017 at 4:58:24 PM UTC-4, runru...@gmail.com wrote:
>
> fun = database
> zip = table name
> inform = Field name
>this enters data into the database but I would prefer it run only once
> at registration.
> fun.zipdip.insert(infom=result)
>
> An interesting behavior is
fun = database
zip = table name
inform = Field name
this enters data into the database but I would prefer it run only once
at registration.
fun.zipdip.insert(infom=result)
An interesting behavior is when I run the above I get 20 dates in the db.
But when I run
--auth.settings.registe
What is fun.zipdip.insert(inform=result), and how does the other code you
have shown come into play?
On Friday, May 19, 2017 at 5:59:06 PM UTC-4, R U wrote:
>
> I would like to add a list of dates into my data base when the user signs
> up.
>
> from datetime import date, datetime, timedelta
> im
On Wednesday, March 23, 2016 at 5:44:34 PM UTC+2, Dave S wrote:
>
>
>
> On Wednesday, March 23, 2016 at 7:46:24 AM UTC-7, M Mihai wrote:
>>
>>
>>
>> On Wednesday, March 23, 2016 at 1:24:32 AM UTC+2, Dave S wrote:
>>>
>>>
>>>
>>> On Tuesday, March 22, 2016 at 3:45:25 PM UTC-7, M Mihai wrote:
On Wednesday, March 23, 2016 at 7:46:24 AM UTC-7, M Mihai wrote:
>
>
>
> On Wednesday, March 23, 2016 at 1:24:32 AM UTC+2, Dave S wrote:
>>
>>
>>
>> On Tuesday, March 22, 2016 at 3:45:25 PM UTC-7, M Mihai wrote:
>>>
>>> So I want to update the database while a scheduler task is running but
>>> t
On Wednesday, March 23, 2016 at 1:24:32 AM UTC+2, Dave S wrote:
>
>
>
> On Tuesday, March 22, 2016 at 3:45:25 PM UTC-7, M Mihai wrote:
>>
>> So I want to update the database while a scheduler task is running but
>> the function won't update it. If I try to run the same function from a
>> contro
On Tuesday, March 22, 2016 at 3:45:25 PM UTC-7, M Mihai wrote:
>
> So I want to update the database while a scheduler task is running but the
> function won't update it. If I try to run the same function from a
> controller it will update the database.
>
> Here is the function:
>
> def Test():
Thanks for the answer.
I'm using web2py version 2.10.3, so in the model I did this:
_cmd_options = request.global_settings.cmd_options
if not (_cmd_options and _cmd_options.scheduler):
# this code is executed when the request is NOT done through scheduler
Thank you both Anthony and Niphlod fo
There is a request object, but it doesn't have all the same attributes
during a scheduler run as it does during an HTTP request. Anyway, you can
determine whether the current execution is happening via the scheduler by
checking request.is_scheduler. Similarly, you can determine if in a shell
wi
Thanks for the answer.
I've found that one of my models does a conditional check on request
object.
However, when the function is called from the scheduler, there is no HTTP
request, so there is no request object.
Is there a way to check if request object exists from inside the model?
I've tr
it seems an error in the model definition, as line 166 in gluon.shell is
where an exception is raised when executing model files BEFORE calling the
controller.
As I repeatedly said, scheduler is just calling shell at regular intervals
on steroids. If it works on the shell, it'll work on the sche
On Tuesday, May 12, 2015 at 10:07:03 AM UTC-7, KevC wrote:
>
> Hi community!
>
> I want to call a function inside other function, What can I do?
>
>
> For example:
> def function_1():
> y = 'This is an example'
> (I wanna here my function "function_2")
> return locals()
>
> def functi
just call it...
function2()
you could even define the second function inside the first if you wanted.
On Tuesday, May 12, 2015 at 10:07:03 AM UTC-7, KevC wrote:
>
> Hi community!
>
> I want to call a function inside other function, What can I do?
>
>
> For example:
> def function_1():
> y =
Here is what would cause this problem. You have this link:
{{=A('Confirm',_href=URL('reservation_confirmed',
args=request.args),_style="color:#ff3300;font-size:20px;background-color:#ff;padding:5px;border:1px
solid #99")}}
Now if in the view for reservation_confirmed you include an im
Use the browser console to investigate.
Look at the Network tab if it performs two actions with that URL.
Another thing that may sound stupid but it is not uncommon and I have
already seen it.
Some people double click buttons, icons in the web too.
I saw a case that a delay between clicks was need.
On Thursday, February 26, 2015 at 9:50:26 AM UTC-8, peter wrote:
>
> Thanks for your replies. I guess you are right Anthony, one should handle
> unlikely events even if they are normally rare. The site did already does
> this for paying bookings, but I did not expect the duplicates on
> reserv
Thanks for your replies. I guess you are right Anthony, one should handle
unlikely events even if they are normally rare. The site did already does
this for paying bookings, but I did not expect the duplicates on
reservations.
I have now prevented multiple reservations from a single confirm.
P
In any case, you should probably have some code that prevents double
booking (i.e., the first time you receive a request with the confirmation,
make some change in the session or db that prevents the same order from
being confirmed/fulfilled twice).
Anthony
On Thursday, February 26, 2015 at 7:
I don't see how it can happen. Your costumer probably has a virus or
something. It may also be a buggy browser extension (tell him to try with
the browser in private mode so the extensions are off).
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/w
Hmm i didnt't know about that, i really need to check out lazy_tables.
Saves me alot of time :P thanks for the info
Op 30-nov.-2014 13:38 schreef "Niphlod" :
> you're the one choosing an app without models :P there's nothing on
> modules that is available globally on views if not a model.
> That b
you're the one choosing an app without models :P there's nothing on modules
that is available globally on views if not a model.
That being said, the model-less approach was done in a time where the thing
that hurted performances was table definitions, that later got the
possibility to be lazy-de
Did you install postgis? Did you
CREATE EXTENSION postgis;
CREATE EXTENSION postgis_topology;
On the database you're using?
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (
Now a web2py error
On Thursday, 30 October 2014 23:07:11 UTC-5, Raouf Mir wrote:
>
> i am gettting this error.
> function 'GEOSversion' not found
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.co
Thanks Alan!
On Wednesday, July 17, 2013 10:05:14 PM UTC+2, Alan Etkin wrote:
>
>
>> def download_file():
>> file = db(db.files.user_id == int(request.args(0))).select()
>> for f in file:
>> name = f.name
>> return response.download(name,db)
>>
>> I think that the call to download should be respo
>
>
> def download_file():
> file = db(db.files.user_id == int(request.args(0))).select()
> for f in file:
> name = f.name
> return response.download(name,db)
>
> I think that the call to download should be response.download(request, db)
and you could customize the request args so the method get
Sorry for the noise.
I am such a noob :)
I posted a wrong link to thepost about "islambda" function.
The correct one is: http://kbyanc.blogspot.com/2007/05/python-islambda.html
Amnon
On Sep 2, 7:12 pm, Amnon Khen wrote:
> Hi,
> As a quick workaround, I thought of modifying serializers.custom_j
Hi,
As a quick workaround, I thought of modifying serializers.custom_json
in the following manner:
1. check whether the item is a lambda expression
2. if so, return its string representation (using repr())
I used a nice "islambda" function I found in
http://bytes.com/topic/python/answers/39908-wha
Thanks for the advice. The problem does indeed not occur with another
plugin layout (I used Whitelight before).
I am just testing some functionality and will add a form statement
soon.
On Apr 3, 3:56 am, Massimo Di Pierro
wrote:
> Add a print statement. You find that the function is being called
Add a print statement. You find that the function is being called
twice. A broken link in the page like make cause
that.
Mind that a function that inserts without a form posting is vulnerable
to URL redirection attacks.
On Apr 2, 4:55 pm, Serbitar wrote:
> I have the controller:
>
> @auth.req
If you're going to be searching based on the difference between date1 and
date2 why not just include the difference in the DB itself with a computed
field? (http://www.web2py.com/book/default/chapter/06#Computed-Fields)
Yes I do not know how to compare dates with datetime fields in a
query.
I suppose there would ideally be some built-in method to express one
type as the other.
Maybe someone knows a way to do it... D
On Feb 15, 7:20 am, Manuele Pesenti wrote:
> Il 14/02/2011 19:57, villas ha scritto:
>
> > Well
Il 14/02/2011 19:57, villas ha scritto:
Well, this might not help at all... but maybe you can pick out
something to give you a step forward:)
I cannot see how, the problem is the introduction of a function inside
an expression in which appears fields objects that contains date or
datetime ob
> I use datetime.combine() it says "TypeError: combine() argument 1 must
> be datetime.date, not Field"
> any suggestion?
Well, this might not help at all... but maybe you can pick out
something to give you a step forward :)
import datetime, time
# create a datetime for the example
d1 = datetime.
Il 11/02/2011 18:53, Massimo Di Pierro ha scritto:
db(db.mytab.date1-db.mytab.date1 ==
datetime.timedelta(days=2).select()
must be
db(db.mytab.date1 == db.mytab.date1 +
datetime.timedelta(days=2).select()
a query has the form field = expression. You cannot have the
expression on the left-hand
db(db.mytab.date1-db.mytab.date1 ==
datetime.timedelta(days=2).select()
must be
db(db.mytab.date1 == db.mytab.date1 +
datetime.timedelta(days=2).select()
a query has the form field = expression. You cannot have the
expression on the left-hand side.
I cannot exclude something else is also wrong
I think something like this:
notice not all options are covered.
def check(type1,type2,type3):
query1 =
db.archives.symbol.like('%'+request.vars.txtSoKyHieu+'%')
query2 = db.archives.key.like('%'+request.vars.txtTuKhoa
+'%')
query3 = db.archives.archives_ty
>From http://web2py.com/book/default/chapter/04#Dispatching :
"Functions that take arguments or start with a double underscore are
not publicly exposed and can only be called by other functions."
So, as long as a function takes at least one argument, it will be
private, even without the double un
Tks for the helpful replies.
On Oct 25, 1:21 am, JimK wrote:
> You can leave the function in the controller file but pre-pend __ to
> the name. This is the Python way to create private functions and it
> appears to be supported well in Web2Py.
>
> An example would be:
>
> def __privateFunc():
>
You can leave the function in the controller file but pre-pend __ to
the name. This is the Python way to create private functions and it
appears to be supported well in Web2Py.
An example would be:
def __privateFunc():
On Oct 24, 5:18 am, Luther Goh Lu Feng wrote:
> If I have a function that
I personally put them in a special section of the file I am using. It's
easier to me. If you need to restrict access to it you can use the same
decorators you normally use too.
On Sun, 2010-10-24 at 07:11 -0700, mdipierro wrote:
> If a function returns a string it does not require a view.
>
>
If a function returns a string it does not require a view.
On Oct 24, 7:18 am, Luther Goh Lu Feng wrote:
> If I have a function that I intend to call from different controllers, but I
> have no need for the function to have a view, where should this function be
> defined? eg. a function that simp
I don't think there is one built in but it should be simple. Something
like this maybe:
def get_members(role):
try:
group = db(db.auth_group.role==role).select()[0]
members = db(db.auth_membership.group_id==group.id).select()
return members
except:
return No
56 matches
Mail list logo