本文整理匯總了Python中managers.model_managers.WorkspaceManager.openDefaultWorkspace方法的典型用法代碼示例。如果您正苦於以下問題:Python WorkspaceManager.openDefaultWorkspace方法的具體用法?Python WorkspaceManager.openDefaultWorkspace怎麽用?Python WorkspaceManager.openDefaultWorkspace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類managers.model_managers.WorkspaceManager
的用法示例。
在下文中一共展示了WorkspaceManager.openDefaultWorkspace方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: MainApplication
# 需要導入模塊: from managers.model_managers import WorkspaceManager [as 別名]
# 或者: from managers.model_managers.WorkspaceManager import openDefaultWorkspace [as 別名]
class MainApplication(object):
"""
"""
def __init__(self, args):
self._original_excepthook = sys.excepthook
self._configuration = CONF
self._security_manager = SecurityManager()
self._mappers_manager = MapperManager()
self._changes_controller = ChangeController()
self._db_manager = DbManager()
self._model_controller = ModelController(self._security_manager, self._mappers_manager)
self._plugin_manager = PluginManager(os.path.join(CONF.getConfigPath(), "plugins"), self._mappers_manager)
self._reports_manager = ReportManager(10, self._plugin_manager.createController("ReportManager"))
self._workspace_manager = WorkspaceManager(
self._db_manager, self._mappers_manager, self._changes_controller, self._reports_manager
)
self.gui_app = UiFactory.create(self._model_controller, self._plugin_manager, self._workspace_manager, args.gui)
self.gui_app.setSplashImage(os.path.join(CONF.getImagePath(), "splash2.png"))
self.timer = TimerClass()
self.timer.start()
def enableExceptHook(self):
sys.excepthook = exception_handler
installThreadExcepthook()
def disableLogin(self):
CONF.setAuth(sys.disablelogin)
def start(self):
try:
self.gui_app.startSplashScreen()
self.gui_app.splashMessage("Starting Faraday")
signal.signal(signal.SIGINT, self.ctrlC)
logged = True
while True:
username, password = "usuario", "password"
if username is None and password is None:
break
result = self._security_manager.authenticateUser(username, password)
if result == codes.successfulLogin:
logged = True
break
if logged:
model.api.devlog("Starting application...")
model.api.devlog("Setting up remote API's...")
# We need to create the last used workspace (or the default
# workspace) before we start the model controller and the
# report manager
last_workspace = CONF.getLastWorkspace()
try:
if not self._workspace_manager.workspaceExists(last_workspace):
getLogger(self).info(
"Your last workspace ("
+ str(last_workspace)
+ ") wasn't accessible, check configuration..."
)
self._workspace_manager.openDefaultWorkspace()
# self._workspace_manager.createWorkspace(last_workspace, 'default workspace, probably created already in couchb')
else:
self._workspace_manager.openWorkspace(last_workspace)
except restkit.errors.Unauthorized:
print "You are trying to enter CouchDB with authentication"
print "Add your credentials to your user configuration file in $HOME/.faraday/config/user.xml"
print "For example: <couch_uri>http://john:[email protected]:5984</couch_uri>"
return
model.api.setUpAPIs(
self._model_controller, self._workspace_manager, CONF.getApiConInfoHost(), CONF.getApiConInfoPort()
)
model.guiapi.setUpGUIAPIs(self._model_controller)
model.api.devlog("Starting model controller daemon...")
self._model_controller.start()
model.api.startAPIServer()
restapi.startAPIs(
self._plugin_manager,
self._model_controller,
self._mappers_manager,
CONF.getApiConInfoHost(),
CONF.getApiRestfulConInfoPort(),
)
#.........這裏部分代碼省略.........