Hello i added an authors and readers computed fields to my table
db.define_table(
'entities',
...
Field('authors',compute= lambda r:authors(r)),
...
)
when i save a record i get this
:
authors :
[*<function lazy_user at 0x2d82a28>*]
created_by :
4L
created_on :
datetime.datetime(2017, 6, 28, 16, 16, 24)
delete_record :
<pydal.helpers.classes.RecordDeleter object at 0x32142d0>
description :
entity :
saw
event :
1903
id :
401L
is_active :
True
last_error :
modified_by :
4L
modified_on :
datetime.datetime(2017, 6, 28, 16, 16, 24)
readers :
[2L, 1L, 5L, 4L,* <function lazy_user at 0x2d82a28>*]
status :
8L
type :
1L
update_record :
<pydal.helpers.classes.RecordUpdater object at 0x3214290>
uuid :
c12ecf01-0d7b-4334-81c9-b7808c8cf7f9
if i go to admin and edit the record and save again the fuction lazy_user
goes away..
Why is this and how to make it save properly in my code?
my code...
def *authors*(record):
ret=[]
row=db.status(id=record["status"])
rule=db.rules(workflow=row["workflow"],step=record["status"])
users=get_userIds(rule)
for user in users:
if not user in ret:
ret.append(user)
if ret==[]:
ret.append(record["created_by"])
return str(ret)
def get_userIds(rule):
ret=[]
for membership in rule["authors"]:
temp=db(db.auth_membership.group_id==membership).select()
for r in temp:
ret.append(r["id"])
return ret
Regards
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.