repeated error messages

Inside my plugin, there are four directory items. If you're not logged in, I'd like to show the same error message when you try to access any one.

 

I do a conditional statement to see if a user is logged in and if they're not, show the message. However, because this is a repeated message, I'd prefer not to have it in each of the submenu's code.

 

Example:

def SubMenuCode():    
   if Dict["Login"] == True:
        # return the menu
    else:
        ErrorNotLoggedIn

def ErrorNotLoggedIn():
return ObjectContainer(
header = “You’re not logged in”,
message = “You need to be logged in to view the upcoming streams”
)

If I do the above, I get this in console:

2014-06-04 23:17:40,460 (10e204000) :  DEBUG (runtime:918) - Response: [404] NoneType, 0 bytes

If I try this:

def SubMenuCode(): 
    if Dict["Login"] == True:
        # return the menu
    else:
        ERROR__MESSAGE          = ErrorNotLoggedIn
    return ERROR__MESSAGE

def ErrorNotLoggedIn():
return ObjectContainer(
header = “You’re not logged in”,
message = “You need to be logged in to view the upcoming streams”
)

I get this in console:

2014-06-04 23:20:01,950 (11250a000) :  DEBUG (runtime:1021) - Unable to handle response type: 
2014-06-04 23:20:01,951 (11250a000) :  DEBUG (runtime:918) - Response: [500] function, 0 bytes

I know it's probably something simple, but what am I doing wrong?

Figured it out, within seconds of posting (don't I look stupid now)

Solution:

def SubMenuCode(): 
    if Dict["Login"] == True:
        # return the menu
    else:
        ERROR__MESSAGE          = ErrorNotLoggedIn()
    return ERROR__MESSAGE

def ErrorNotLoggedIn():
return ObjectContainer(
header = “You’re not logged in”,
message = “You need to be logged in to view the upcoming streams”
)

Brackets after the function name in the variable.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.