witten
/
luminotes
Archived
1
0
Fork 0

* controller.Users.current() now returns an http_url if one is configured in config/Common.py

* changed controller.Users and controller.Root constructor arguments to support this.
 * Updated INSTALL document accordingly.
 * Client now will prepend this new http_url variable to the logout link.
This commit is contained in:
Dan Helfman 2007-08-02 18:52:20 +00:00
parent ef53bb8159
commit 0ac518e395
8 changed files with 23 additions and 13 deletions

View File

@ -35,9 +35,11 @@ mode doesn't support auto-reload, and logging goes to file (luminotes.log)
instead of the console, but performance should be better than in development instead of the console, but performance should be better than in development
mode. mode.
If you want to use SSL, edit config/Common.py and change the value of If you want to use SSL, edit config/Common.py and change the values of
luminotes.https_url to the URL of your SSL server. For instance: luminotes.http_url and luminotes.https_url based on the domain you're using.
For instance:
"luminotes.http_url": "http://luminotes.com",
"luminotes.https_url": "https://luminotes.com", "luminotes.https_url": "https://luminotes.com",
Then you'll need to configure your web server to forward requests for Then you'll need to configure your web server to forward requests for

View File

@ -15,6 +15,7 @@ settings = {
"encoding_filter.encoding": "utf-8", "encoding_filter.encoding": "utf-8",
"decoding_filter.on": True, "decoding_filter.on": True,
"decoding_filter.encoding": "utf-8", "decoding_filter.encoding": "utf-8",
"luminotes.http_url": "",
"luminotes.https_url": "", "luminotes.https_url": "",
}, },
} }

View File

@ -14,11 +14,11 @@ from view.Not_found_page import Not_found_page
class Root( object ): class Root( object ):
def __init__( self, scheduler, database ): def __init__( self, scheduler, database, settings ):
self.__scheduler = scheduler self.__scheduler = scheduler
self.__database = database self.__database = database
self.__notebooks = Notebooks( scheduler, database ) self.__notebooks = Notebooks( scheduler, database )
self.__users = Users( scheduler, database ) self.__users = Users( scheduler, database, settings[ u"global" ].get( u"luminotes.http_url", u"" ) )
@expose( view = Main_page ) @expose( view = Main_page )
def index( self ): def index( self ):

View File

@ -103,9 +103,10 @@ def update_auth( function ):
class Users( object ): class Users( object ):
def __init__( self, scheduler, database ): def __init__( self, scheduler, database, http_url ):
self.__scheduler = scheduler self.__scheduler = scheduler
self.__database = database self.__database = database
self.__http_url = http_url
@expose( view = Json ) @expose( view = Json )
@update_auth @update_auth
@ -227,6 +228,7 @@ class Users( object ):
yield dict( yield dict(
user = user, user = user,
notebooks = notebooks, notebooks = notebooks,
http_url = self.__http_url,
) )
scheduler = property( lambda self: self.__scheduler ) scheduler = property( lambda self: self.__scheduler )

View File

@ -13,7 +13,8 @@ class Test_controller( object ):
cherrypy.lowercase_api = True cherrypy.lowercase_api = True
self.scheduler = Scheduler() self.scheduler = Scheduler()
self.database = Database( self.scheduler, database_path = None ) self.database = Database( self.scheduler, database_path = None )
cherrypy.root = Root( self.scheduler, self.database ) self.settings = { u"global": { u"luminotes.http_url" : u"http://luminotes.com" } }
cherrypy.root = Root( self.scheduler, self.database, self.settings )
cherrypy.config.update( Common.settings ) cherrypy.config.update( Common.settings )
cherrypy.config.update( { u"server.log_to_screen": False } ) cherrypy.config.update( { u"server.log_to_screen": False } )
cherrypy.server.start( init_only = True, server_class = None ) cherrypy.server.start( init_only = True, server_class = None )

View File

@ -139,9 +139,11 @@ class Test_users( Test_controller ):
assert result[ u"user" ] == self.user assert result[ u"user" ] == self.user
assert result[ u"notebooks" ] == [ self.anon_notebook ] + self.notebooks assert result[ u"notebooks" ] == [ self.anon_notebook ] + self.notebooks
assert result[ u"http_url" ] == self.settings[ u"global" ].get( u"luminotes.http_url" )
def test_current_without_login( self ): def test_current_without_login( self ):
result = self.http_get( "/users/current" ) result = self.http_get( "/users/current" )
assert result[ u"user" ].username == "anonymous" assert result[ u"user" ].username == "anonymous"
assert result[ u"notebooks" ] == [ self.anon_notebook ] assert result[ u"notebooks" ] == [ self.anon_notebook ]
assert result[ u"http_url" ] == self.settings[ u"global" ].get( u"luminotes.http_url" )

View File

@ -9,18 +9,20 @@ def main( args ):
scheduler = Scheduler() scheduler = Scheduler()
database = Database( scheduler, "data.db" ) database = Database( scheduler, "data.db" )
cherrypy.lowercase_api = True
root = Root( scheduler, database )
cherrypy.root = root
cherrypy.config.update( Common.settings ) cherrypy.config.update( Common.settings )
if len( args ) > 0 and args[ 0 ] == "-d": if len( args ) > 0 and args[ 0 ] == "-d":
from config import Development from config import Development
cherrypy.config.update( Development.settings ) settings = Development.settings
else: else:
from config import Production from config import Production
cherrypy.config.update( Production.settings ) settings = Production.settings
cherrypy.config.update( settings )
cherrypy.lowercase_api = True
root = Root( scheduler, database, cherrypy.config.configMap )
cherrypy.root = root
if scheduler.shutdown not in cherrypy.server.on_stop_server_list: if scheduler.shutdown not in cherrypy.server.on_stop_server_list:
cherrypy.server.on_stop_server_list.append( scheduler.shutdown ) cherrypy.server.on_stop_server_list.append( scheduler.shutdown )

View File

@ -68,7 +68,7 @@ Wiki.prototype.display_user = function ( result ) {
replaceChildNodes( "user_area", span ); replaceChildNodes( "user_area", span );
appendChildNodes( span, "logged in as " + result.user.username ); appendChildNodes( span, "logged in as " + result.user.username );
appendChildNodes( span, " | " ); appendChildNodes( span, " | " );
appendChildNodes( span, createDOM( "a", { "href": "/", "id": "logout_link" }, "logout" ) ); appendChildNodes( span, createDOM( "a", { "href": result.http_url + "/", "id": "logout_link" }, "logout" ) );
var self = this; var self = this;
connect( "recent_notes_link", "onclick", function ( event ) { connect( "recent_notes_link", "onclick", function ( event ) {