-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add an utility function to get object paths (fixes #119) #120
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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): |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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_url
s . 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): |
There was a problem hiding this comment.
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
.
@@ -128,3 +128,11 @@ def get_valid_objects(brains): | |||
logger.warn(msg.format(b.getPath())) | |||
continue | |||
yield obj | |||
|
|||
|
|||
def get_path_to_virtual_path(request, item): |
There was a problem hiding this comment.
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..
There was a problem hiding this comment.
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? 😉
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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/
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
@idgserpro I think we need another pair of eyes here; can you help? |
Does anybody have something to add about it? @hvelarde @idgserpro |
Closes #119