Added error handler argument in CMS_STORAGE_BUILDER.storage (...) function.

Removed testing purpose code.
Update debug module.
This commit is contained in:
2015-07-10 12:20:28 +02:00
parent d24f124e42
commit 5477bab83c
8 changed files with 25 additions and 43 deletions

View File

@@ -26,7 +26,7 @@ feature {NONE} -- Initialization
feature -- Factory feature -- Factory
storage (a_setup: CMS_SETUP): detachable CMS_STORAGE_STORE_MYSQL storage (a_setup: CMS_SETUP; a_error_handler: ERROR_HANDLER): detachable CMS_STORAGE_STORE_MYSQL
local local
conn: DATABASE_CONNECTION conn: DATABASE_CONNECTION
do do
@@ -40,6 +40,8 @@ feature -- Factory
initialize (a_setup, Result) initialize (a_setup, Result)
end end
end end
else
a_error_handler.add_custom_error (0, "Could not connect to the MySQL storage", Void)
end end
end end
end end

View File

@@ -26,7 +26,7 @@ feature {NONE} -- Initialization
feature -- Factory feature -- Factory
storage (a_setup: CMS_SETUP): detachable CMS_STORAGE_STORE_ODBC storage (a_setup: CMS_SETUP; a_error_handler: ERROR_HANDLER): detachable CMS_STORAGE_STORE_ODBC
local local
s: detachable STRING s: detachable STRING
conn: detachable DATABASE_CONNECTION conn: detachable DATABASE_CONNECTION
@@ -53,6 +53,8 @@ feature -- Factory
initialize (a_setup, Result) initialize (a_setup, Result)
end end
end end
else
a_error_handler.add_custom_error (0, "Could not connect to the ODBC storage", Void)
end end
else else
-- Wrong mapping between storage name and storage builder! -- Wrong mapping between storage name and storage builder!

View File

@@ -145,7 +145,7 @@ feature -- Access: storage
attached (create {APPLICATION_JSON_CONFIGURATION_HELPER}).new_database_configuration (environment.application_config_path) as l_database_config and then attached (create {APPLICATION_JSON_CONFIGURATION_HELPER}).new_database_configuration (environment.application_config_path) as l_database_config and then
attached storage_drivers.item (l_database_config.driver) as l_builder attached storage_drivers.item (l_database_config.driver) as l_builder
then then
Result := l_builder.storage (Current) Result := l_builder.storage (Current, a_error_handler)
end end
else else
to_implement ("Workaround code, persistence layer does not implement yet this kind of error handling.") to_implement ("Workaround code, persistence layer does not implement yet this kind of error handling.")

View File

@@ -71,6 +71,7 @@ feature -- Hooks
create dbg.make create dbg.make
create s.make_empty create s.make_empty
dbg.append_information_to (a_response.request, a_response.response, s) dbg.append_information_to (a_response.request, a_response.response, s)
append_info_to ("Storage", a_response.api.storage.generator, a_response, s)
create b.make ("debug-info", "Debug", s, a_response.formats.plain_text) create b.make ("debug-info", "Debug", s, a_response.formats.plain_text)
a_response.add_block (b, "footer") a_response.add_block (b, "footer")
end end
@@ -102,15 +103,17 @@ feature -- Handler
-- append_info_to ("Base url", cms.base_url, r, s) -- append_info_to ("Base url", cms.base_url, r, s)
-- append_info_to ("Script url", cms.script_url, r, s) -- append_info_to ("Script url", cms.script_url, r, s)
s.append ("<hr/>") s.append ("<hr/>")
append_info_to ("Site dir", api.setup.environment.path.utf_8_name, r, s) append_info_to ("Site dir", api.site_location.utf_8_name, r, s)
append_info_to ("Www dir", api.setup.environment.www_path.utf_8_name, r, s) append_info_to ("Www dir", api.setup.environment.www_path.utf_8_name, r, s)
append_info_to ("Assets dir", api.setup.environment.assets_path.utf_8_name, r, s) append_info_to ("Assets dir", api.setup.environment.assets_path.utf_8_name, r, s)
append_info_to ("Config dir", api.setup.environment.config_path.utf_8_name, r, s) append_info_to ("Config dir", api.setup.environment.config_path.utf_8_name, r, s)
s.append ("<hr/>") s.append ("<hr/>")
append_info_to ("Theme", api.setup.theme_name, r, s) append_info_to ("Theme", api.setup.theme_name, r, s)
append_info_to ("Theme location", api.setup.themes_location.utf_8_name, r, s) append_info_to ("Theme location", api.theme_location.utf_8_name, r, s)
s.append ("<hr/>") s.append ("<hr/>")
-- append_info_to ("Files location", api...files_location.utf_8_name, r, s) append_info_to ("Files location", api.files_location.utf_8_name, r, s)
append_info_to ("Modules location", api.modules_location.utf_8_name, r, s)
append_info_to ("Storage", api.storage.generator, r, s)
-- s.append ("<hr/>") -- s.append ("<hr/>")
append_info_to ("Url", r.url ("/", Void), r, s) append_info_to ("Url", r.url ("/", Void), r, s)

View File

@@ -11,9 +11,12 @@ deferred class
feature -- Factory feature -- Factory
storage (a_setup: CMS_SETUP): detachable CMS_STORAGE storage (a_setup: CMS_SETUP; a_error_handler: ERROR_HANDLER): detachable CMS_STORAGE
-- CMS Storage object based on CMS setup `a_setup'. -- CMS Storage object based on CMS setup `a_setup'.
deferred deferred
end end
note
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
end end

View File

@@ -14,9 +14,12 @@ inherit
feature -- Factory feature -- Factory
storage (a_setup: CMS_SETUP): detachable CMS_STORAGE_NULL storage (a_setup: CMS_SETUP; a_error_handler: ERROR_HANDLER): detachable CMS_STORAGE_NULL
do do
create Result create Result
end end
note
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
end end

View File

@@ -59,37 +59,9 @@ feature -- Initialization
l_authenticated_role.add_permission ("trash own page") l_authenticated_role.add_permission ("trash own page")
a_storage.save_user_role (l_authenticated_role) a_storage.save_user_role (l_authenticated_role)
--|-------------------------------------------|--
--| For testing purpose, to be removed later. |--
--|-------------------------------------------|--
-- Roles, view role for testing.
create r.make ("view")
r.add_permission ("view any page")
a_storage.save_user_role (r)
create {ARRAYED_LIST [CMS_USER_ROLE]} l_roles.make (1)
l_roles.force (r)
create u.make ("auth")
u.set_password ("enticated#")
u.set_email (a_setup.site_email)
u.set_status ({CMS_USER}.active)
a_storage.new_user (u)
create u.make ("test")
u.set_password ("test#")
u.set_email (a_setup.site_email)
u.set_status ({CMS_USER}.active)
a_storage.new_user (u)
create u.make ("view")
u.set_password ("only#")
u.set_email (a_setup.site_email)
u.set_status ({CMS_USER}.active)
u.set_roles (l_roles)
a_storage.new_user (u)
end end
note
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
end end

View File

@@ -407,15 +407,12 @@ feature -- Environment/ theme
Result := theme_location.extended ("assets") Result := theme_location.extended ("assets")
end end
feature -- Environment/ module
feature -- Environment/ module feature -- Environment/ module
module_configuration_by_name (a_module_name: READABLE_STRING_GENERAL; a_name: detachable READABLE_STRING_GENERAL): detachable CONFIG_READER module_configuration_by_name (a_module_name: READABLE_STRING_GENERAL; a_name: detachable READABLE_STRING_GENERAL): detachable CONFIG_READER
-- Configuration reader for `a_module', and if `a_name' is set, using name `a_name'. -- Configuration reader for `a_module', and if `a_name' is set, using name `a_name'.
local local
p, l_path: detachable PATH p: detachable PATH
l_name: READABLE_STRING_GENERAL
do do
-- Search first in site/config/modules/$module_name/($app|$module_name).(json|ini) -- Search first in site/config/modules/$module_name/($app|$module_name).(json|ini)
-- if none, look as sub configuration if $app /= Void -- if none, look as sub configuration if $app /= Void