How to get login field from session info

61 views
Skip to first unread message

erey...@gmail.com

unread,
Dec 28, 2018, 3:33:20 PM12/28/18
to Jam.py Users Mailing List
Hi all, I am new to jam.py, first, thanks for such wonderful framework. I would like to know if there is a way to get the login field data from the session info. Looking at the examples in the documention and making some test I found that the dictionary has values for almost every field in the user table but the login field. How can I get it from my code? can I get it somehow using the user_id present in the session "user_info" diccionary? I don´t know if it is possible tu access the user table data from code, haven´t found documentation on that.

thanks

Dražen Babić

unread,
Dec 29, 2018, 8:08:33 AM12/29/18
to erey...@gmail.com, Jam.py Users Mailing List
Hi,

Have a look at Task/Client module, here is the code:

if (task.safe_mode) {

$("#user-info").text(task.user_info.role_name + ' ' + task.user_info.user_name);

$('#log-out')

.show() 

.click(function(e) {

e.preventDefault();

task.logout();

}); 

}


Hope this helps.


D.


On Saturday, December 29, 2018, <erey...@gmail.com> wrote:
Hi all, I am new to jam.py, first, thanks for such wonderful framework. I would like to know if there is a way to get the login field data from the session info. Looking at the examples in the documention and making some test I found that the dictionary has values for almost every field in the user table but the login field. How can I get it from my code? can I get it somehow using the user_id present in the session "user_info" diccionary? I don´t know if it is possible tu access the user table data from code, haven´t found documentation on that.

thanks

--
You received this message because you are subscribed to the Google Groups "Jam.py Users Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jam-py+unsubscribe@googlegroups.com.
To post to this group, send email to jam...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jam-py/70ea90a2-53f8-4e6d-beef-b0554e1a22b5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Andrew Yushev

unread,
Dec 29, 2018, 8:55:56 PM12/29/18
to Dražen Babić, erey...@gmail.com, Jam.py Users Mailing List
Hi,

The session user_info doesn't have login and password attributes.
You can find it using this function:

def login_by_id(task, user_id):
    #search in the admin.sqlite
    users = task.app.admin.sys_users.copy(handlers=False)
    users.set_where(id=user_id)
    users.open()    
    if users.record_count() == 1:
        return users.f_login.value
    #search in the custom users table if it exists, otherwise remove the code
    users = task.users.copy(handlers=False)
    users.set_where(id=user_id)
    users.open()
    if users.record_count() == 1:
        return users.login.value

Regards,
Andrew Yushev

сб, 29 дек. 2018 г. в 16:08, Dražen Babić <bab...@gmail.com>:
Hi,

Have a look at Task/Client module, here is the code:

if (task.safe_mode) {

$("#user-info").text(task.user_info.role_name + ' ' + task.user_info.user_name);

$('#log-out')

.show() 

.click(function(e) {

e.preventDefault();

task.logout();

}); 

}


Hope this helps.


D.


On Saturday, December 29, 2018, <erey...@gmail.com> wrote:
Hi all, I am new to jam.py, first, thanks for such wonderful framework. I would like to know if there is a way to get the login field data from the session info. Looking at the examples in the documention and making some test I found that the dictionary has values for almost every field in the user table but the login field. How can I get it from my code? can I get it somehow using the user_id present in the session "user_info" diccionary? I don´t know if it is possible tu access the user table data from code, haven´t found documentation on that.

thanks

--
You received this message because you are subscribed to the Google Groups "Jam.py Users Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jam-py+un...@googlegroups.com.

To post to this group, send email to jam...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jam-py/70ea90a2-53f8-4e6d-beef-b0554e1a22b5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Jam.py Users Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jam-py+un...@googlegroups.com.

To post to this group, send email to jam...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages