public inbox for [email protected]
help / color / mirror / Atom feedFrom: Murtuza Zabuawala <[email protected]>
To: Dave Page <[email protected]>
Cc: pgadmin-hackers <[email protected]>
Subject: Re: [pgAdmin4][RM#3139] Create proper template path if Windows
Date: Tue, 13 Mar 2018 18:57:04 +0530
Message-ID: <CAKKotZTVdbS2-LtUehHZ3ONQGs9tnR_UTQwEH3n22prLy1AkGw@mail.gmail.com> (raw)
In-Reply-To: <CAKKotZRyi5+W=MOoqP5ikUcWr=q0rScYe8K54-oXuH8k4U4D3Q@mail.gmail.com>
References: <CAKKotZSDVNp73-NJ3WFJi=SBNNQ7Mu0SjfLmOcLcGTdFFxbmow@mail.gmail.com>
<CA+OCxoyZpBo4M9LqGF=3p6sQLZ4xZfgFB=+1sRh1dQN7XwOoug@mail.gmail.com>
<CAKKotZRxjPX6Gb5ax2HgjShzoHzVBL2F-Me=Uoa0+dV3fgspsA@mail.gmail.com>
<CA+OCxoz6_QYKsRnBZeg65-DaSUvr8aR36WcKExd0DY038_ORww@mail.gmail.com>
<CA+OCxoxPa3=664RSrTdmNnVAzCXymkv07q-EeDVbU8-fFaP_Sg@mail.gmail.com>
<CAKKotZRyi5+W=MOoqP5ikUcWr=q0rScYe8K54-oXuH8k4U4D3Q@mail.gmail.com>
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
view thread (8+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: [pgAdmin4][RM#3139] Create proper template path if Windows
In-Reply-To: <CAKKotZTVdbS2-LtUehHZ3ONQGs9tnR_UTQwEH3n22prLy1AkGw@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox