Skip to content

Add an utility function to get object paths (fixes #119)#120

Open
tcurvelo wants to merge 2 commits intomasterfrom
issue_119
Open

Add an utility function to get object paths (fixes #119)#120
tcurvelo wants to merge 2 commits intomasterfrom
issue_119

Conversation

@tcurvelo
Copy link
Copy Markdown

@tcurvelo tcurvelo commented Jul 24, 2017

Closes #119

@tcurvelo tcurvelo requested a review from hvelarde July 24, 2017 14:38
Copy link
Copy Markdown
Member

@hvelarde hvelarde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we have some pending issues as you can see.

self.obj = api.content.create(portal, type='News Item', id='foo')
api.content.transition(self.obj, 'publish')

def test_get_path_to_virtual_path(self):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test is redundant with test_canonical_url in the test_behaviors.py module.

Copy link
Copy Markdown
Author

@tcurvelo tcurvelo Jul 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not exactly. These tests are not about canonical_urls . They're mean to test getting the paths based on the request, and how it changes with VHM.

get_path_to_virtual_path(self.request, self.obj),
'plone/foo')

def test_get_path_to_virtual_path_using_virtualhostmonster(self):
Copy link
Copy Markdown
Member

@hvelarde hvelarde Jul 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test must be moved to the test_behaviors.py module; rename it to test_canonical_url_with_virtual_host_root.

Comment thread sc/social/like/utils.py
yield obj


def get_path_to_virtual_path(request, item):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's no need to create this function; just place the code inside the assign_canonical_url subscriber, as this is the only place where it's called..

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And how I suppose to unittest it? 😉

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should test just the final result as in the test I uncommented in the behavior.

# FIXME: we're currently ignoring the Plone site id
# https://github.com/collective/sc.social.like/issues/119
path = '/'.join(obj.getPhysicalPath()[2:])
path = get_path_to_virtual_path(self.request, obj)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to fix this on a different way: this form is only used to assign a canonical URL to objects created before the package was installed/upgraded.

now imagine the following case: Plone site with the id visible to the end user migrating to a site where the id is no longer available, that is from http://www.example.org/Plone to http://www.example.org/.

we're currently not covering this case and the only solution I can think about is to add a Bool field to enforce the use of the site id or a ASCIILine field that lets you add an arbitrary string.

we need to think about this.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's tough. I can't see a safer way to get the previous URL than accessing it with it (eg. with VHM).

However, asking the user to choose to use or not the Site Id as you said, sounds better than ask for the old VirtualHostMonster URL. 🤔

Is this case, we should allow path in the canonical_url. Imagine http://localhost:8080/VirtualHostBase/http/foo.com:80/Plone/VirtualHostRoot/_vh_intranet
Just saying to not use the Site Id isn't enough, you have to say that the root URL was http://foo.com/intranet/

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to think about this.

# FIXME: we're currently ignoring the Plone site id
# https://github.com/collective/sc.social.like/issues/119
path = '/'.join(obj.getPhysicalPath()[2:])
path = get_path_to_virtual_path(event.request, obj)
Copy link
Copy Markdown
Member

@hvelarde hvelarde Jul 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just do the conversion right here; you'll need to get the request on a different way (probably using getRequest() from zope.globalrequest) as the AfterTransitionEvent doesn't include it.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While reviewing #118, I had a bad time trying to reach the code in the subscriber. Is it really working?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes it is, why you had such bad time? can you elaborate?

@hvelarde
Copy link
Copy Markdown
Member

@idgserpro I think we need another pair of eyes here; can you help?

@hvelarde hvelarde requested a review from idgserpro July 27, 2017 12:20
@tcurvelo
Copy link
Copy Markdown
Author

Does anybody have something to add about it? @hvelarde @idgserpro

@idgserpro
Copy link
Copy Markdown
Member

@tcurvelo sorry. I have nothing to add. I didn't understand the issue, but I believe you have to fix that @hvelarde asked for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants