[cherrypy-devel] problem entering a login requiered page

2 views
Skip to first unread message

eranlevi

unread,
Nov 10, 2008, 8:00:15 AM11/10/08
to cherryp...@googlegroups.com

Hi All,

I have a very strange problem. I have two Solaris machines that have the
python2.5 + cherrypy installed. I have wrote a program that uses the
cherrypy as web service. GUI is working just fine on both machines. The only
thing that is different when I'm trying to login into a password protected
web pages. In one machine the HttpRedirect function works as expected and on
the other one returns to the login page.
I have installed the faulty machine again with the same installation CD and
gave it the same IP address. Both configurations are identical. I'm just
moving the lan cable from one machine to another and the problem is still
there.
I have installed another machine (same hardware) and it happened again. The
only thing that had left to do is to reinstall the machine that is working.

The code looks like this:
def login(self, failed = False, referer=""):
cherrypy.session[LOGIN] = None
tmpl = login.login(searchList=[{
"version" : self.version,
"timeFormat" : self.timeFormat,
"failed" : failed,
"referer" : referer
}])
return str(tmpl)
login.exposed = True

def authLogin(self, signIn=None, password=None, referer=""):
if password:
if password == self.password:
cherrypy.session[LOGIN] = AUTHENTICATED
raise cherrypy.HTTPRedirect("/%s" % referer)
else:
raise cherrypy.HTTPRedirect("/login?failed=True&referer=%s"
% referer)
else:
raise cherrypy.HTTPRedirect("/login?failed=True&referer=%s" %
referer)
authLogin.exposed=True

def status(self):
user = cherrypy.session.get(LOGIN)
statDict = self.daemon.statusInterface.getStatusForGUI()
errors = statDict[DaemonConsts.MAIN_ERROR_MSG]
activeRole, activeName, activeColor, activeStatus =
statDict[DaemonConsts.ACTIVE_DBS_DETAILS]
stdbyRole, stdbyName, stdbyColor, stdbyStatus =
statDict[DaemonConsts.STDBY_DBS_DETAILS]
repServerName, repServerColor, repServerStatus =
statDict[DaemonConsts.REP_SERVER_DETAILS]
tasks = statDict[DaemonConsts.RUNNING_TASKS]
sysMessages = statDict[DaemonConsts.SYSTEM_MESSAGES]
sysCounters = statDict[DaemonConsts.SYSTEM_COUNTERS]
###
tmpl = status.status(searchList=[{
"user" : user,
"referer" : "status",
"refreshRate" : self.refreshRate,
"version" : self.version,
"timeFormat" : self.timeFormat,
"activeDbsColor" : self._int2color(activeColor),
"replicationServerColor" : self._int2color(repServerColor),
"standbyDbsColor" : self._int2color(stdbyColor),
"activeDbsHost" : activeName,
"replicationServerHost" : repServerName,
"standbyDbsHost" : stdbyName,
"errors" : errors,
"tasks" : tasks,
"sysCounters" : sysCounters,
"sysMessages" : sysMessages
}])
return str(tmpl)
status.exposed = True

def replication(self, actionStatus = True, message = ''):
if not cherrypy.session.get(LOGIN) == AUTHENTICATED:
raise cherrypy.InternalRedirect("/login?referer=replication")
###
user = cherrypy.session.get(LOGIN)
statDict = self.daemon.statusInterface.getStatusForGUI()
activeRole, activeName, activeColor, activeStatus =
statDict[DaemonConsts.ACTIVE_DBS_DETAILS]
stdbyRole, stdbyName, stdbyColor, stdbyStatus =
statDict[DaemonConsts.STDBY_DBS_DETAILS]
repServerName, repServerColor, repServerStatus =
statDict[DaemonConsts.REP_SERVER_DETAILS]
tasks = statDict[DaemonConsts.CONTROL_TASKS]
stopStartBtn = statDict[DaemonConsts.STOP_START_BUTTON]
suspendResumeBtn = statDict[DaemonConsts.SUSPEND_RESUME_BUTTON]
terminateRebuildBtn =
statDict[DaemonConsts.TERMINATE_REBUILD_BUTTON]
switchFailoverBtn = statDict[DaemonConsts.SWITCH_FAILOVER_BUTTON]
###
tmpl = replication.replication(searchList=[{
"user" : user,
"referer" : "replication",
"refreshRate" : self.refreshRate,
"version" : self.version,
"timeFormat" : self.timeFormat,
"repStatusMessage" : self._int2dbStatus(repServerStatus),
"activeDbsHost" : activeName,
"standbyDbsHost" : stdbyName,
"stopStartBtn" : stopStartBtn,
"suspendResumeBtn" : suspendResumeBtn,
"terminateRebuildBtn" : terminateRebuildBtn,
"switchFailoverBtn" : switchFailoverBtn,
"tasks" : tasks,
"actionStatus" : actionStatus,
"message" : message
}])
return str(tmpl)
replication.exposed = True


authLogin works fine till the HttpRedirect("/%s" % referer) function.
replication function is a login page's function. status function is a
regular page's function. The problem is between the HttpRedirect function
and cherrypy.session.get(LOGIN) function in the replication function.

Please let me know if you need anymore information.

Thanks

Gil
--
View this message in context: http://www.nabble.com/problem-entering-a-login-requiered-page-tp20419467p20419467.html
Sent from the cherrypy-devel mailing list archive at Nabble.com.

eranlevi

unread,
Nov 11, 2008, 4:43:12 AM11/11/08
to cherryp...@googlegroups.com

Problem has been solved.
Problem was that the Cherrypy machine's clock was 8 hours in the past from
all the windows machines that I have tried to login with. Problem was
because of the cookies that expire after X minutes and loose the data that
they are holding.

Thanks anyway

--
View this message in context: http://www.nabble.com/problem-entering-a-login-requiered-page-tp20419467p20436261.html

Sylvain Hellegouarch

unread,
Nov 11, 2008, 4:59:37 AM11/11/08
to cherryp...@googlegroups.com
Interesting use case. I didn't think of that at all in the first place.
Almost worth a not on our documentation :)

Thank you for providing the feedback.
- Sylvain

eranlevi a écrit :

Reply all
Reply to author
Forward
0 new messages