public inbox for [email protected]
help / color / mirror / Atom feed[pgAdmin4][RM#3139] Create proper template path if Windows
8+ messages / 2 participants
[nested] [flat]
* [pgAdmin4][RM#3139] Create proper template path if Windows
@ 2018-03-12 14:15 Murtuza Zabuawala <[email protected]>
2018-03-13 00:41 ` Re: [pgAdmin4][RM#3139] Create proper template path if Windows Dave Page <[email protected]>
0 siblings, 1 reply; 8+ messages in thread
From: Murtuza Zabuawala @ 2018-03-12 14:15 UTC (permalink / raw)
To: pgadmin-hackers
Hi,
PFA patch to correct the template path generation logic incase of Windows
system.
--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
Attachments:
[application/octet-stream] RM_3139.diff (1.3K, 3-RM_3139.diff)
download | inline diff:
diff --git a/web/pgadmin/utils/compile_template_name.py b/web/pgadmin/utils/compile_template_name.py
index 1e0b94fa..1232b6a0 100644
--- a/web/pgadmin/utils/compile_template_name.py
+++ b/web/pgadmin/utils/compile_template_name.py
@@ -11,10 +11,13 @@ import os
def compile_template_name(
template_prefix, template_file_name, server_type, version):
- return os.path.join(
- compile_template_path(template_prefix, server_type, version),
- template_file_name
- )
+
+ # Template path concatenation should be same as
+ # Ref: ../pgadmin4/web/pgadmin/utils/versioned_template_loader.py +54
+ # to avoid path mismatch in windows
+ return compile_template_path(template_prefix, server_type, version) + \
+ '/' + template_file_name
+
def compile_template_path(template_prefix, server_type, version):
@@ -22,4 +25,8 @@ def compile_template_path(template_prefix, server_type, version):
version_path = '#{0}#{1}#'.format(server_type, version)
else:
version_path = '#{0}#'.format(version)
- return os.path.join(template_prefix, version_path)
+
+ # Template path concatenation should be same as
+ # Ref: ../pgadmin4/web/pgadmin/utils/versioned_template_loader.py +54
+ # to avoid path mismatch in windows
+ return template_prefix + '/' + version_path
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: [pgAdmin4][RM#3139] Create proper template path if Windows
2018-03-12 14:15 [pgAdmin4][RM#3139] Create proper template path if Windows Murtuza Zabuawala <[email protected]>
@ 2018-03-13 00:41 ` Dave Page <[email protected]>
2018-03-13 04:32 ` Re: [pgAdmin4][RM#3139] Create proper template path if Windows Murtuza Zabuawala <[email protected]>
0 siblings, 1 reply; 8+ messages in thread
From: Dave Page @ 2018-03-13 00:41 UTC (permalink / raw)
To: Murtuza Zabuawala <[email protected]>; +Cc: pgadmin-hackers
Hi
On Mon, Mar 12, 2018 at 10:15 AM, Murtuza Zabuawala <
[email protected]> wrote:
> Hi,
>
> PFA patch to correct the template path generation logic incase of Windows
> system.
>
Seems like it would be better to fix it the other way round to me - e.g.
update the template loader to use os.path.join.
Any reason not to do that?
--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: [pgAdmin4][RM#3139] Create proper template path if Windows
2018-03-12 14:15 [pgAdmin4][RM#3139] Create proper template path if Windows Murtuza Zabuawala <[email protected]>
2018-03-13 00:41 ` Re: [pgAdmin4][RM#3139] Create proper template path if Windows Dave Page <[email protected]>
@ 2018-03-13 04:32 ` Murtuza Zabuawala <[email protected]>
2018-03-13 11:58 ` Re: [pgAdmin4][RM#3139] Create proper template path if Windows Dave Page <[email protected]>
0 siblings, 1 reply; 8+ messages in thread
From: Murtuza Zabuawala @ 2018-03-13 04:32 UTC (permalink / raw)
To: Dave Page <[email protected]>; +Cc: pgadmin-hackers
Hi Dave,
We are not joining template path with os.path.join because we are passing
prefix paths in render_template(..) at many places,
we are passing them as below,
Some of examples,
render_template(
"exclusion_constraint/js/exclusion_constraint.js",
_=_
),
recovery_check_sql = render_template(
"connect/sql/#{0}#/check_recovery.sql".format(postgres_version))
sql = render_template(
"/servers/sql/#{0}#/stats.sql".format(manager.version),
conn=conn, _=gettext
)
sql = render_template(
"/".join([self.template_path, 'create.sql']),
data=data, conn=self.conn
)
def csssnippets(self):
"""
Returns a snippet of css to include in the page
"""
snippets = [render_template("css/servers.css")]
So again it will conflict if use os.path.join, To make it consistent with
render_template(...) and VersionedTemplateLoader(..) class we opt'd for
this mechanism.
--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
On Tue, Mar 13, 2018 at 6:11 AM, Dave Page <[email protected]> wrote:
> Hi
>
> On Mon, Mar 12, 2018 at 10:15 AM, Murtuza Zabuawala <murtuza.zabuawala@
> enterprisedb.com> wrote:
>
>> Hi,
>>
>> PFA patch to correct the template path generation logic incase of Windows
>> system.
>>
>
> Seems like it would be better to fix it the other way round to me - e.g.
> update the template loader to use os.path.join.
>
> Any reason not to do that?
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: [pgAdmin4][RM#3139] Create proper template path if Windows
2018-03-12 14:15 [pgAdmin4][RM#3139] Create proper template path if Windows Murtuza Zabuawala <[email protected]>
2018-03-13 00:41 ` Re: [pgAdmin4][RM#3139] Create proper template path if Windows Dave Page <[email protected]>
2018-03-13 04:32 ` Re: [pgAdmin4][RM#3139] Create proper template path if Windows Murtuza Zabuawala <[email protected]>
@ 2018-03-13 11:58 ` Dave Page <[email protected]>
2018-03-13 12:50 ` Re: [pgAdmin4][RM#3139] Create proper template path if Windows Dave Page <[email protected]>
0 siblings, 1 reply; 8+ messages in thread
From: Dave Page @ 2018-03-13 11:58 UTC (permalink / raw)
To: Murtuza Zabuawala <[email protected]>; +Cc: pgadmin-hackers
OK, thanks. Patch applied.
On Tue, Mar 13, 2018 at 12:32 AM, Murtuza Zabuawala <
[email protected]> wrote:
> Hi Dave,
>
> We are not joining template path with os.path.join because we are passing
> prefix paths in render_template(..) at many places,
> we are passing them as below,
>
> Some of examples,
>
> render_template(
> "exclusion_constraint/js/exclusion_constraint.js",
> _=_
> ),
>
> recovery_check_sql = render_template(
> "connect/sql/#{0}#/check_recovery.sql".format(postgres_version))
>
> sql = render_template(
> "/servers/sql/#{0}#/stats.sql".format(manager.version),
> conn=conn, _=gettext
> )
>
> sql = render_template(
> "/".join([self.template_path, 'create.sql']),
> data=data, conn=self.conn
> )
>
> def csssnippets(self):
> """
> Returns a snippet of css to include in the page
> """
> snippets = [render_template("css/servers.css")]
>
>
> So again it will conflict if use os.path.join, To make it consistent with
> render_template(...) and VersionedTemplateLoader(..) class we opt'd for
> this mechanism.
>
>
> --
> Regards,
> Murtuza Zabuawala
> EnterpriseDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
>
> On Tue, Mar 13, 2018 at 6:11 AM, Dave Page <[email protected]> wrote:
>
>> Hi
>>
>> On Mon, Mar 12, 2018 at 10:15 AM, Murtuza Zabuawala <
>> [email protected]> wrote:
>>
>>> Hi,
>>>
>>> PFA patch to correct the template path generation logic incase of
>>> Windows system.
>>>
>>
>> Seems like it would be better to fix it the other way round to me - e.g.
>> update the template loader to use os.path.join.
>>
>> Any reason not to do that?
>>
>> --
>> Dave Page
>> Blog: http://pgsnake.blogspot.com
>> Twitter: @pgsnake
>>
>> EnterpriseDB UK: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>
>
--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: [pgAdmin4][RM#3139] Create proper template path if Windows
2018-03-12 14:15 [pgAdmin4][RM#3139] Create proper template path if Windows Murtuza Zabuawala <[email protected]>
2018-03-13 00:41 ` Re: [pgAdmin4][RM#3139] Create proper template path if Windows Dave Page <[email protected]>
2018-03-13 04:32 ` Re: [pgAdmin4][RM#3139] Create proper template path if Windows Murtuza Zabuawala <[email protected]>
2018-03-13 11:58 ` Re: [pgAdmin4][RM#3139] Create proper template path if Windows Dave Page <[email protected]>
@ 2018-03-13 12:50 ` Dave Page <[email protected]>
2018-03-13 12:54 ` Re: [pgAdmin4][RM#3139] Create proper template path if Windows Murtuza Zabuawala <[email protected]>
0 siblings, 1 reply; 8+ messages in thread
From: Dave Page @ 2018-03-13 12:50 UTC (permalink / raw)
To: Murtuza Zabuawala <[email protected]>; +Cc: pgadmin-hackers
And... reverted. It seems this makes Jenkins very unhappy.
On Tue, Mar 13, 2018 at 7:58 AM, Dave Page <[email protected]> wrote:
> OK, thanks. Patch applied.
>
> On Tue, Mar 13, 2018 at 12:32 AM, Murtuza Zabuawala <murtuza.zabuawala@
> enterprisedb.com> wrote:
>
>> Hi Dave,
>>
>> We are not joining template path with os.path.join because we are passing
>> prefix paths in render_template(..) at many places,
>> we are passing them as below,
>>
>> Some of examples,
>>
>> render_template(
>> "exclusion_constraint/js/exclusion_constraint.js",
>> _=_
>> ),
>>
>> recovery_check_sql = render_template(
>> "connect/sql/#{0}#/check_recovery.sql".format(postgres_version))
>>
>> sql = render_template(
>> "/servers/sql/#{0}#/stats.sql".format(manager.version),
>> conn=conn, _=gettext
>> )
>>
>> sql = render_template(
>> "/".join([self.template_path, 'create.sql']),
>> data=data, conn=self.conn
>> )
>>
>> def csssnippets(self):
>> """
>> Returns a snippet of css to include in the page
>> """
>> snippets = [render_template("css/servers.css")]
>>
>>
>> So again it will conflict if use os.path.join, To make it consistent with
>> render_template(...) and VersionedTemplateLoader(..) class we opt'd for
>> this mechanism.
>>
>>
>> --
>> Regards,
>> Murtuza Zabuawala
>> EnterpriseDB: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>>
>> On Tue, Mar 13, 2018 at 6:11 AM, Dave Page <[email protected]> wrote:
>>
>>> Hi
>>>
>>> On Mon, Mar 12, 2018 at 10:15 AM, Murtuza Zabuawala <
>>> [email protected]> wrote:
>>>
>>>> Hi,
>>>>
>>>> PFA patch to correct the template path generation logic incase of
>>>> Windows system.
>>>>
>>>
>>> Seems like it would be better to fix it the other way round to me - e.g.
>>> update the template loader to use os.path.join.
>>>
>>> Any reason not to do that?
>>>
>>> --
>>> Dave Page
>>> Blog: http://pgsnake.blogspot.com
>>> Twitter: @pgsnake
>>>
>>> EnterpriseDB UK: http://www.enterprisedb.com
>>> The Enterprise PostgreSQL Company
>>>
>>
>>
>
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: [pgAdmin4][RM#3139] Create proper template path if Windows
2018-03-12 14:15 [pgAdmin4][RM#3139] Create proper template path if Windows Murtuza Zabuawala <[email protected]>
2018-03-13 00:41 ` Re: [pgAdmin4][RM#3139] Create proper template path if Windows Dave Page <[email protected]>
2018-03-13 04:32 ` Re: [pgAdmin4][RM#3139] Create proper template path if Windows Murtuza Zabuawala <[email protected]>
2018-03-13 11:58 ` Re: [pgAdmin4][RM#3139] Create proper template path if Windows Dave Page <[email protected]>
2018-03-13 12:50 ` Re: [pgAdmin4][RM#3139] Create proper template path if Windows Dave Page <[email protected]>
@ 2018-03-13 12:54 ` Murtuza Zabuawala <[email protected]>
2018-03-13 13:27 ` Re: [pgAdmin4][RM#3139] Create proper template path if Windows Murtuza Zabuawala <[email protected]>
0 siblings, 1 reply; 8+ messages in thread
From: Murtuza Zabuawala @ 2018-03-13 12:54 UTC (permalink / raw)
To: Dave Page <[email protected]>; +Cc: pgadmin-hackers
Hi Dave,
I have already replied on another thread regarding the failure of these
tests, Joao has already sent a patch for the same.
--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
On Tue, Mar 13, 2018 at 6:20 PM, Dave Page <[email protected]> wrote:
> And... reverted. It seems this makes Jenkins very unhappy.
>
> On Tue, Mar 13, 2018 at 7:58 AM, Dave Page <[email protected]> wrote:
>
>> OK, thanks. Patch applied.
>>
>> On Tue, Mar 13, 2018 at 12:32 AM, Murtuza Zabuawala <
>> [email protected]> wrote:
>>
>>> Hi Dave,
>>>
>>> We are not joining template path with os.path.join because we are
>>> passing prefix paths in render_template(..) at many places,
>>> we are passing them as below,
>>>
>>> Some of examples,
>>>
>>> render_template(
>>> "exclusion_constraint/js/exclusion_constraint.js",
>>> _=_
>>> ),
>>>
>>> recovery_check_sql = render_template(
>>> "connect/sql/#{0}#/check_recovery.sql".format(postgres_version))
>>>
>>> sql = render_template(
>>> "/servers/sql/#{0}#/stats.sql".format(manager.version),
>>> conn=conn, _=gettext
>>> )
>>>
>>> sql = render_template(
>>> "/".join([self.template_path, 'create.sql']),
>>> data=data, conn=self.conn
>>> )
>>>
>>> def csssnippets(self):
>>> """
>>> Returns a snippet of css to include in the page
>>> """
>>> snippets = [render_template("css/servers.css")]
>>>
>>>
>>> So again it will conflict if use os.path.join, To make it consistent
>>> with render_template(...) and VersionedTemplateLoader(..) class we
>>> opt'd for this mechanism.
>>>
>>>
>>> --
>>> Regards,
>>> Murtuza Zabuawala
>>> EnterpriseDB: http://www.enterprisedb.com
>>> The Enterprise PostgreSQL Company
>>>
>>>
>>> On Tue, Mar 13, 2018 at 6:11 AM, Dave Page <[email protected]> wrote:
>>>
>>>> Hi
>>>>
>>>> On Mon, Mar 12, 2018 at 10:15 AM, Murtuza Zabuawala <
>>>> [email protected]> wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> PFA patch to correct the template path generation logic incase of
>>>>> Windows system.
>>>>>
>>>>
>>>> Seems like it would be better to fix it the other way round to me -
>>>> e.g. update the template loader to use os.path.join.
>>>>
>>>> Any reason not to do that?
>>>>
>>>> --
>>>> Dave Page
>>>> Blog: http://pgsnake.blogspot.com
>>>> Twitter: @pgsnake
>>>>
>>>> EnterpriseDB UK: http://www.enterprisedb.com
>>>> The Enterprise PostgreSQL Company
>>>>
>>>
>>>
>>
>>
>> --
>> Dave Page
>> Blog: http://pgsnake.blogspot.com
>> Twitter: @pgsnake
>>
>> EnterpriseDB UK: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>
>
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: [pgAdmin4][RM#3139] Create proper template path if Windows
2018-03-12 14:15 [pgAdmin4][RM#3139] Create proper template path if Windows Murtuza Zabuawala <[email protected]>
2018-03-13 00:41 ` Re: [pgAdmin4][RM#3139] Create proper template path if Windows Dave Page <[email protected]>
2018-03-13 04:32 ` Re: [pgAdmin4][RM#3139] Create proper template path if Windows Murtuza Zabuawala <[email protected]>
2018-03-13 11:58 ` Re: [pgAdmin4][RM#3139] Create proper template path if Windows Dave Page <[email protected]>
2018-03-13 12:50 ` Re: [pgAdmin4][RM#3139] Create proper template path if Windows Dave Page <[email protected]>
2018-03-13 12:54 ` Re: [pgAdmin4][RM#3139] Create proper template path if Windows Murtuza Zabuawala <[email protected]>
@ 2018-03-13 13:27 ` Murtuza Zabuawala <[email protected]>
2018-03-13 16:45 ` Re: [pgAdmin4][RM#3139] Create proper template path if Windows Dave Page <[email protected]>
0 siblings, 1 reply; 8+ messages in thread
From: Murtuza Zabuawala @ 2018-03-13 13:27 UTC (permalink / raw)
To: Dave Page <[email protected]>; +Cc: pgadmin-hackers
Hi Dave,
Please find updated patch which Joao sent along with RM#3139 fix.
--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
On Tue, Mar 13, 2018 at 6:24 PM, Murtuza Zabuawala <
[email protected]> wrote:
> Hi Dave,
>
> I have already replied on another thread regarding the failure of these
> tests, Joao has already sent a patch for the same.
>
> --
> Regards,
> Murtuza Zabuawala
> EnterpriseDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
>
> On Tue, Mar 13, 2018 at 6:20 PM, Dave Page <[email protected]> wrote:
>
>> And... reverted. It seems this makes Jenkins very unhappy.
>>
>> On Tue, Mar 13, 2018 at 7:58 AM, Dave Page <[email protected]> wrote:
>>
>>> OK, thanks. Patch applied.
>>>
>>> On Tue, Mar 13, 2018 at 12:32 AM, Murtuza Zabuawala <
>>> [email protected]> wrote:
>>>
>>>> Hi Dave,
>>>>
>>>> We are not joining template path with os.path.join because we are
>>>> passing prefix paths in render_template(..) at many places,
>>>> we are passing them as below,
>>>>
>>>> Some of examples,
>>>>
>>>> render_template(
>>>> "exclusion_constraint/js/exclusion_constraint.js",
>>>> _=_
>>>> ),
>>>>
>>>> recovery_check_sql = render_template(
>>>> "connect/sql/#{0}#/check_recovery.sql".format(postgres_versi
>>>> on))
>>>>
>>>> sql = render_template(
>>>> "/servers/sql/#{0}#/stats.sql".format(manager.version),
>>>> conn=conn, _=gettext
>>>> )
>>>>
>>>> sql = render_template(
>>>> "/".join([self.template_path, 'create.sql']),
>>>> data=data, conn=self.conn
>>>> )
>>>>
>>>> def csssnippets(self):
>>>> """
>>>> Returns a snippet of css to include in the page
>>>> """
>>>> snippets = [render_template("css/servers.css")]
>>>>
>>>>
>>>> So again it will conflict if use os.path.join, To make it consistent
>>>> with render_template(...) and VersionedTemplateLoader(..) class we
>>>> opt'd for this mechanism.
>>>>
>>>>
>>>> --
>>>> Regards,
>>>> Murtuza Zabuawala
>>>> EnterpriseDB: http://www.enterprisedb.com
>>>> The Enterprise PostgreSQL Company
>>>>
>>>>
>>>> On Tue, Mar 13, 2018 at 6:11 AM, Dave Page <[email protected]> wrote:
>>>>
>>>>> Hi
>>>>>
>>>>> On Mon, Mar 12, 2018 at 10:15 AM, Murtuza Zabuawala <
>>>>> [email protected]> wrote:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> PFA patch to correct the template path generation logic incase of
>>>>>> Windows system.
>>>>>>
>>>>>
>>>>> Seems like it would be better to fix it the other way round to me -
>>>>> e.g. update the template loader to use os.path.join.
>>>>>
>>>>> Any reason not to do that?
>>>>>
>>>>> --
>>>>> Dave Page
>>>>> Blog: http://pgsnake.blogspot.com
>>>>> Twitter: @pgsnake
>>>>>
>>>>> EnterpriseDB UK: http://www.enterprisedb.com
>>>>> The Enterprise PostgreSQL Company
>>>>>
>>>>
>>>>
>>>
>>>
>>> --
>>> Dave Page
>>> Blog: http://pgsnake.blogspot.com
>>> Twitter: @pgsnake
>>>
>>> EnterpriseDB UK: http://www.enterprisedb.com
>>> The Enterprise PostgreSQL Company
>>>
>>
>>
>>
>> --
>> Dave Page
>> Blog: http://pgsnake.blogspot.com
>> Twitter: @pgsnake
>>
>> EnterpriseDB UK: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>
>
Attachments:
[application/octet-stream] path-correction-for-windows_v1.diff (7.1K, 3-path-correction-for-windows_v1.diff)
download | inline diff:
diff --git a/web/pgadmin/browser/server_groups/servers/databases/external_tables/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/external_tables/__init__.py
index 137c6c4..37bbee3 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/external_tables/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/external_tables/__init__.py
@@ -133,7 +133,7 @@ class ExternalTablesView(PGChildNodeView):
did=kwargs['database_id']
)
self.sql_template_path = compile_template_path(
- 'sql/',
+ 'sql',
self.manager.server_type,
self.manager.sversion
)
diff --git a/web/pgadmin/browser/server_groups/servers/databases/external_tables/tests/test_external_tables_view.py b/web/pgadmin/browser/server_groups/servers/databases/external_tables/tests/test_external_tables_view.py
index acedc61..3f08e40 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/external_tables/tests/test_external_tables_view.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/external_tables/tests/test_external_tables_view.py
@@ -7,6 +7,7 @@
#
##########################################################################
+import os
import sys
from pgadmin.browser.server_groups.servers.databases.external_tables import \
@@ -68,7 +69,9 @@ class TestExternalTablesView(BaseTestGenerator):
connection=MagicMock(execute_2darray=MagicMock()),
execute_2darray_return_value=(True, dict(rows=[])),
- expect_render_template_called_with='sql/#gpdb#80323#/list.sql',
+ expect_render_template_called_with=os.path.join('sql',
+ '#gpdb#80323#'
+ , 'list.sql'),
expected_make_json_response_called_with=dict(
data=[],
status=200
@@ -90,7 +93,9 @@ class TestExternalTablesView(BaseTestGenerator):
connection=MagicMock(execute_2darray=MagicMock()),
execute_2darray_return_value=(False, 'Some error message'),
- expect_render_template_called_with='sql/#gpdb#80323#/list.sql',
+ expect_render_template_called_with=os.path.join('sql',
+ '#gpdb#80323#',
+ 'list.sql'),
expected_internal_server_error_called_with=dict(
errormsg='Some error message'
),
@@ -122,7 +127,9 @@ class TestExternalTablesView(BaseTestGenerator):
]
)),
- expect_render_template_called_with='sql/#gpdb#80323#/list.sql',
+ expect_render_template_called_with=os.path.join('sql',
+ '#gpdb#80323#',
+ 'list.sql'),
expected_make_json_response_called_with=dict(
data=[
{
@@ -167,7 +174,9 @@ class TestExternalTablesView(BaseTestGenerator):
execute_2darray_return_value=(False, 'Some error message'),
expect_render_template_called_with=dict(
- template_name_or_list='sql/#gpdb#80323#/node.sql',
+ template_name_or_list=os.path.join('sql',
+ '#gpdb#80323#',
+ 'node.sql'),
external_table_id=11
),
expected_internal_server_error_called_with=dict(
@@ -192,7 +201,9 @@ class TestExternalTablesView(BaseTestGenerator):
execute_2darray_return_value=(True, dict(rows=[])),
expect_render_template_called_with=dict(
- template_name_or_list='sql/#gpdb#80323#/node.sql',
+ template_name_or_list=os.path.join('sql',
+ '#gpdb#80323#',
+ 'node.sql'),
external_table_id=11
),
expected_make_json_response_called_with=dict(
@@ -229,7 +240,9 @@ class TestExternalTablesView(BaseTestGenerator):
)),
expect_render_template_called_with=dict(
- template_name_or_list='sql/#gpdb#80323#/node.sql',
+ template_name_or_list=os.path.join('sql',
+ '#gpdb#80323#',
+ 'node.sql'),
external_table_id=11
),
expected_make_json_response_called_with=dict(
@@ -283,8 +296,11 @@ class TestExternalTablesView(BaseTestGenerator):
)),
expect_render_template_called_with=dict(
- template_name_or_list='sql/#gpdb#80323#/'
- 'get_table_information.sql',
+ template_name_or_list=os.path.join(
+ 'sql',
+ '#gpdb#80323#',
+ 'get_table_information.sql'
+ ),
table_oid=11
),
expected_make_response_called_with=dict(
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_template_create.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_template_create.py
index 25d5892..cd765aa 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_template_create.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/tests/test_template_create.py
@@ -117,20 +117,26 @@ class FakeApp(Flask):
self.jinja_env.filters['qtTypeIdent'] = driver.qtTypeIdent
self.jinja_loader = ChoiceLoader([
FileSystemLoader(
- os.path.dirname(
- os.path.realpath(__file__)) + '/../templates/'
+ os.path.join(os.path.dirname(
+ os.path.realpath(__file__)
+ ), os.pardir, 'templates')
),
FileSystemLoader(
- os.path.dirname(
- os.path.realpath(__file__)) + '/../../templates/'
+ os.path.join(
+ os.path.dirname(
+ os.path.realpath(__file__)
+ ), os.pardir, os.pardir, 'templates')
),
FileSystemLoader(
- os.path.dirname(
- os.path.realpath(__file__)) + '/../../types/templates/'
+ os.path.join(os.path.dirname(
+ os.path.realpath(__file__))
+ , os.pardir, os.pardir, 'types', 'templates')
),
FileSystemLoader(
- os.path.dirname(
- os.path.realpath(__file__)) + '/../../../../templates/'
+ os.path.join(os.path.dirname(
+ os.path.realpath(__file__))
+ , os.pardir, os.pardir, os.pardir, os.pardir,
+ 'templates')
),
]
)
[application/octet-stream] RM_3139.diff (1.3K, 4-RM_3139.diff)
download | inline diff:
diff --git a/web/pgadmin/utils/compile_template_name.py b/web/pgadmin/utils/compile_template_name.py
index 1e0b94fa..1232b6a0 100644
--- a/web/pgadmin/utils/compile_template_name.py
+++ b/web/pgadmin/utils/compile_template_name.py
@@ -11,10 +11,13 @@ import os
def compile_template_name(
template_prefix, template_file_name, server_type, version):
- return os.path.join(
- compile_template_path(template_prefix, server_type, version),
- template_file_name
- )
+
+ # Template path concatenation should be same as
+ # Ref: ../pgadmin4/web/pgadmin/utils/versioned_template_loader.py +54
+ # to avoid path mismatch in windows
+ return compile_template_path(template_prefix, server_type, version) + \
+ '/' + template_file_name
+
def compile_template_path(template_prefix, server_type, version):
@@ -22,4 +25,8 @@ def compile_template_path(template_prefix, server_type, version):
version_path = '#{0}#{1}#'.format(server_type, version)
else:
version_path = '#{0}#'.format(version)
- return os.path.join(template_prefix, version_path)
+
+ # Template path concatenation should be same as
+ # Ref: ../pgadmin4/web/pgadmin/utils/versioned_template_loader.py +54
+ # to avoid path mismatch in windows
+ return template_prefix + '/' + version_path
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: [pgAdmin4][RM#3139] Create proper template path if Windows
2018-03-12 14:15 [pgAdmin4][RM#3139] Create proper template path if Windows Murtuza Zabuawala <[email protected]>
2018-03-13 00:41 ` Re: [pgAdmin4][RM#3139] Create proper template path if Windows Dave Page <[email protected]>
2018-03-13 04:32 ` Re: [pgAdmin4][RM#3139] Create proper template path if Windows Murtuza Zabuawala <[email protected]>
2018-03-13 11:58 ` Re: [pgAdmin4][RM#3139] Create proper template path if Windows Dave Page <[email protected]>
2018-03-13 12:50 ` Re: [pgAdmin4][RM#3139] Create proper template path if Windows Dave Page <[email protected]>
2018-03-13 12:54 ` Re: [pgAdmin4][RM#3139] Create proper template path if Windows Murtuza Zabuawala <[email protected]>
2018-03-13 13:27 ` Re: [pgAdmin4][RM#3139] Create proper template path if Windows Murtuza Zabuawala <[email protected]>
@ 2018-03-13 16:45 ` Dave Page <[email protected]>
0 siblings, 0 replies; 8+ messages in thread
From: Dave Page @ 2018-03-13 16:45 UTC (permalink / raw)
To: Murtuza Zabuawala <[email protected]>; +Cc: pgadmin-hackers
Thanks, applied.
On Tue, Mar 13, 2018 at 9:27 AM, Murtuza Zabuawala <
[email protected]> wrote:
> Hi Dave,
>
> Please find updated patch which Joao sent along with RM#3139 fix.
>
> --
> Regards,
> Murtuza Zabuawala
> EnterpriseDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
>
> On Tue, Mar 13, 2018 at 6:24 PM, Murtuza Zabuawala <murtuza.zabuawala@
> enterprisedb.com> wrote:
>
>> Hi Dave,
>>
>> I have already replied on another thread regarding the failure of these
>> tests, Joao has already sent a patch for the same.
>>
>> --
>> Regards,
>> Murtuza Zabuawala
>> EnterpriseDB: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>>
>> On Tue, Mar 13, 2018 at 6:20 PM, Dave Page <[email protected]> wrote:
>>
>>> And... reverted. It seems this makes Jenkins very unhappy.
>>>
>>> On Tue, Mar 13, 2018 at 7:58 AM, Dave Page <[email protected]> wrote:
>>>
>>>> OK, thanks. Patch applied.
>>>>
>>>> On Tue, Mar 13, 2018 at 12:32 AM, Murtuza Zabuawala <
>>>> [email protected]> wrote:
>>>>
>>>>> Hi Dave,
>>>>>
>>>>> We are not joining template path with os.path.join because we are
>>>>> passing prefix paths in render_template(..) at many places,
>>>>> we are passing them as below,
>>>>>
>>>>> Some of examples,
>>>>>
>>>>> render_template(
>>>>> "exclusion_constraint/js/exclusion_constraint.js",
>>>>> _=_
>>>>> ),
>>>>>
>>>>> recovery_check_sql = render_template(
>>>>> "connect/sql/#{0}#/check_recovery.sql".format(postgres_versi
>>>>> on))
>>>>>
>>>>> sql = render_template(
>>>>> "/servers/sql/#{0}#/stats.sql".format(manager.version),
>>>>> conn=conn, _=gettext
>>>>> )
>>>>>
>>>>> sql = render_template(
>>>>> "/".join([self.template_path, 'create.sql']),
>>>>> data=data, conn=self.conn
>>>>> )
>>>>>
>>>>> def csssnippets(self):
>>>>> """
>>>>> Returns a snippet of css to include in the page
>>>>> """
>>>>> snippets = [render_template("css/servers.css")]
>>>>>
>>>>>
>>>>> So again it will conflict if use os.path.join, To make it consistent
>>>>> with render_template(...) and VersionedTemplateLoader(..) class we
>>>>> opt'd for this mechanism.
>>>>>
>>>>>
>>>>> --
>>>>> Regards,
>>>>> Murtuza Zabuawala
>>>>> EnterpriseDB: http://www.enterprisedb.com
>>>>> The Enterprise PostgreSQL Company
>>>>>
>>>>>
>>>>> On Tue, Mar 13, 2018 at 6:11 AM, Dave Page <[email protected]> wrote:
>>>>>
>>>>>> Hi
>>>>>>
>>>>>> On Mon, Mar 12, 2018 at 10:15 AM, Murtuza Zabuawala <
>>>>>> [email protected]> wrote:
>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> PFA patch to correct the template path generation logic incase of
>>>>>>> Windows system.
>>>>>>>
>>>>>>
>>>>>> Seems like it would be better to fix it the other way round to me -
>>>>>> e.g. update the template loader to use os.path.join.
>>>>>>
>>>>>> Any reason not to do that?
>>>>>>
>>>>>> --
>>>>>> Dave Page
>>>>>> Blog: http://pgsnake.blogspot.com
>>>>>> Twitter: @pgsnake
>>>>>>
>>>>>> EnterpriseDB UK: http://www.enterprisedb.com
>>>>>> The Enterprise PostgreSQL Company
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> Dave Page
>>>> Blog: http://pgsnake.blogspot.com
>>>> Twitter: @pgsnake
>>>>
>>>> EnterpriseDB UK: http://www.enterprisedb.com
>>>> The Enterprise PostgreSQL Company
>>>>
>>>
>>>
>>>
>>> --
>>> Dave Page
>>> Blog: http://pgsnake.blogspot.com
>>> Twitter: @pgsnake
>>>
>>> EnterpriseDB UK: http://www.enterprisedb.com
>>> The Enterprise PostgreSQL Company
>>>
>>
>>
>
--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
^ permalink raw reply [nested|flat] 8+ messages in thread
end of thread, other threads:[~2018-03-13 16:45 UTC | newest]
Thread overview: 8+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-03-12 14:15 [pgAdmin4][RM#3139] Create proper template path if Windows Murtuza Zabuawala <[email protected]>
2018-03-13 00:41 ` Dave Page <[email protected]>
2018-03-13 04:32 ` Murtuza Zabuawala <[email protected]>
2018-03-13 11:58 ` Dave Page <[email protected]>
2018-03-13 12:50 ` Dave Page <[email protected]>
2018-03-13 12:54 ` Murtuza Zabuawala <[email protected]>
2018-03-13 13:27 ` Murtuza Zabuawala <[email protected]>
2018-03-13 16:45 ` Dave Page <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox