Quantcast

resolveuid wake up the object to just made a response.redirect

classic Classic list List threaded Threaded
14 messages Options
toutpt toutpt
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

resolveuid wake up the object to just made a response.redirect

Hi,

I'm looking at decrease the requests & responses done to display a page on my current project.

One issue I have is with resolveuid. It made redirect. But worst is that to make this redirect it wake up the object corresponding to uuid.

So I have re-wrote it to just don't wake up object. Here is the new version + patch.


New script:

http://pastebin.com/1BGYjG2b

Diff with kupu/Plone3.3 version:

http://pastebin.com/zhpSncTm

In my opinion:
Pros: Improve performance.
Cons: I don't know the impact on the design but I use the uid_catalog and not the reference_catalog because this what lookup object does.
Hanno Schlichting-4 Hanno Schlichting-4
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: resolveuid wake up the object to just made a response.redirect

On Tue, Jun 22, 2010 at 12:25 PM, toutpt <[hidden email]> wrote:

> New script:
>
> http://pastebin.com/1BGYjG2b
>
> Diff with kupu/Plone3.3 version:
>
> http://pastebin.com/zhpSncTm
>
> In my opinion:
> Pros: Improve performance.
> Cons: I don't know the impact on the design but I use the uid_catalog and
> not the reference_catalog because this what lookup object does.

Using the uid catalog instead of the reference catalog is fine in general.

But you are simply concatenating portal_url() + brain.getPath()
instead of calling obj.absolute_url(). I think this leaves out a good
deal of the virtual hosting logic.

I think if you'd use the portal_catalog(UID=uuid) and use the
brain.getURL() method, that should actually work and preserve virtual
hosting.

Hanno

------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit.  See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Plone-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-developers
toutpt toutpt
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: resolveuid wake up the object to just made a response.redirect

Yes it's because brain.getPath() on a brain from uid_catalog is different from a portal_catalog one.
The path doesn't start from the zope root but from the current plone site. And portal_url use virtual hosting logic, so no issue their.

portal_catalog(UID=uuid) should working great here, but I don't know if UID is by default in the portal_catalog.

I have updated it to use portal_catalog, the diff is here: http://pastebin.com/ndq2Gp5i

I have also discover that resolveuid script has been duplicated in TinyMCE. I can commit the improvement on TinyMCE.


Sergey V. Sergey V.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: resolveuid wake up the object to just made a response.redirect

In reply to this post by toutpt

I'm looking at decrease the requests & responses done to display a page on
my current project.

One issue I have is with resolveuid. It made redirect. But worst is that to
make this redirect it wake up the object corresponding to uuid.

Are you sure there are any performance benefits in not waking up the object in this particular case? The object is about to be woken up a few milliseconds later anyway, when browser will make the next request as a result of the redirect. I'm sure there is no performance penalty in this case (waking up a single object is not a big deal anyway)

I don't also see any issues with resolveuid making a redirect - for me it looks like a perfectly valid use of redirects :)
 
--
Sergey Volobuev

------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit.  See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Plone-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-developers
toutpt toutpt
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: resolveuid wake up the object to just made a response.redirect

In the case you are using proxy cache images can be served by an other service than Plone. In my opinion, It is never a good idea to wakeup things where they are not immediatly needed.
toutpt toutpt
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: resolveuid wake up the object to just made a response.redirect

In reply to this post by Sergey V.
> I don't also see any issues with resolveuid making a redirect - for me it looks like a perfectly valid use of redirects :)

A redirect is a performace issue, but redirection are sometimes needed.

So on all pages you are visiting your browser do two requests for each image added with the visual editor. This create a load (x2 request to process) that is not always needed.

/me think about a tinymce_imguid browserview that make the job without a redirect.
yuri-2 yuri-2
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: resolveuid wake up the object to just made a response.redirect

In reply to this post by toutpt
Il 22/06/2010 12:25, toutpt ha scritto:

> Hi,
>
> I'm looking at decrease the requests&  responses done to display a page on
> my current project.
>
> One issue I have is with resolveuid. It made redirect. But worst is that to
> make this redirect it wake up the object corresponding to uuid.
>
> So I have re-wrote it to just don't wake up object. Here is the new version
> + patch.
>
>
> New script:
>
> http://pastebin.com/1BGYjG2b
>
> Diff with kupu/Plone3.3 version:
>
> http://pastebin.com/zhpSncTm
>
> In my opinion:
> Pros: Improve performance.
> Cons: I don't know the impact on the design but I use the uid_catalog and
> not the reference_catalog because this what lookup object does.
>    

  The better would to make a new call
reference_tool.lookupObjectBrain(uuid) and return the brain.

>
> -----
> Jean-Michel François aka toutpt
> http://toutpt.wordpress.com
> http://twitter.com/toutpt
>
>    


------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit.  See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Plone-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-developers
Sergey V. Sergey V.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: resolveuid wake up the object to just made a response.redirect

In reply to this post by toutpt

> I don't also see any issues with resolveuid making a redirect - for me it
looks like a perfectly valid use of redirects :)

A redirect is a performace issue, but redirection are sometimes needed.

So on all pages you are visiting your browser do two requests for each image
added with the visual editor. This create a load (x2 request to process)
that is not always needed.

I mean, if you have links to /resolveuid in the html of the page you're at it's perfectly valid for resolveuid to make a redirect - another option would be for resolveuid to return the content of the object directly but it produces more problems than it solves.

The better solution to the problem would be not to have any resolveuid links in the original page - then there will be no need in redirects and waking up objects.

I even vaguely remember that at some point there was a portal transform which was doing exactly that - replacing resolveuid links in a document with proper absolute links (including <img src=...>). Is it not working anymore? 

/me think about a tinymce_imguid browserview that make the job without a
redirect.

-----
Jean-Michel François aka toutpt
http://toutpt.wordpress.com
http://twitter.com/toutpt

--
View this message in context: http://plone.293351.n2.nabble.com/resolveuid-wake-up-the-object-to-just-made-a-response-redirect-tp5208147p5208382.html
Sent from the Core Developers mailing list archive at Nabble.com.

------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit.  See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Plone-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-developers



--
Sergey Volobuev

------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit.  See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Plone-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-developers
Hanno Schlichting-4 Hanno Schlichting-4
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: resolveuid wake up the object to just made a response.redirect

In reply to this post by toutpt
On Tue, Jun 22, 2010 at 1:30 PM, toutpt <[hidden email]> wrote:
> Yes it's because brain.getPath() on a brain from uid_catalog is different
> from a portal_catalog one.
> The path doesn't start from the zope root but from the current plone site.

Yep, I know. One of those annoying difference between catalogs.

> And portal_url use virtual hosting logic, so no issue their.

Ah ok. Didn't know that :)

> portal_catalog(UID=uuid) should working great here, but I don't know if UID
> is by default in the portal_catalog.

It's in there by default and has been for a long time.

> I have updated it to use portal_catalog, the diff is here:
> http://pastebin.com/ndq2Gp5i

Looks good. Make sure to test it, I wrote the syntax from memory and
didn't double check ;)

> I have also discover that resolveuid script has been duplicated in TinyMCE.
> I can commit the improvement on TinyMCE.

That would be great.

Hanno

------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit.  See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Plone-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-developers
Hanno Schlichting-4 Hanno Schlichting-4
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: resolveuid wake up the object to just made a response.redirect

In reply to this post by Sergey V.
On Tue, Jun 22, 2010 at 1:56 PM, Sergey Volobuev
<[hidden email]> wrote:
> I even vaguely remember that at some point there was a portal transform
> which was doing exactly that - replacing resolveuid links in a document with
> proper absolute links (including <img src=...>). Is it not working anymore?

There is such a transform and a cache for it. By default you should
never see a resolveuid link in any HTML source in the browser. If you
do, there's something wrong with the configured transforms.

But still the logic to get from a UID link to an actual URL has to be
executed in some way. The portal transforms cache generally only lasts
for one request (volatile _v_ attribute on the object). TinyMCE does
this in Products.TinyMCE.transforms.parser.TinyMCEOutput
(unknown_starttag / lookup_uid). Not sure anymore where Kupu has that
code. So the same kind of fix can be applied to this code. It's a bit
more difficult as it deals with correct LinguaPlone translations /
references but the code only needs to know about the uid and compute
the URL in the end.

Hanno

------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit.  See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Plone-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-developers
Ross J. Reedstrom Ross J. Reedstrom
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: resolveuid wake up the object to just made a response.redirect

In reply to this post by Sergey V.
On Tue, Jun 22, 2010 at 09:32:51PM +1000, Sergey Volobuev wrote:
>
> Are you sure there are any performance benefits in not waking up the object
> in this particular case? The object is about to be woken up a few
> milliseconds later anyway, when browser will make the next request as a
> result of the redirect. I'm sure there is no performance penalty in this
> case (waking up a single object is not a big deal anyway)

In a multi-FE load balanced setup (like ours) it's likely that the
redirected URL will be served by a completely different frontend, with a
completely different ZEO cache, so yes, there's a big cost to loading it
now, just to get the path.

Ross
--
Ross Reedstrom, Ph.D.                                 [hidden email]
Systems Engineer & Admin, Research Scientist        phone: 713-348-6166
The Connexions Project      http://cnx.org            fax: 713-348-3665
Rice University MS-375, Houston, TX 77005
GPG Key fingerprint = F023 82C8 9B0E 2CC6 0D8E  F888 D3AE 810E 88F0 BEDE

------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit.  See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Plone-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-developers
toutpt toutpt
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: resolveuid wake up the object to just made a response.redirect

In reply to this post by Hanno Schlichting-4
Thank you Hanno,

I will fix this tomorrow. For today I have spot the issue with your help.

> There is such a transform and a cache for it. By default you should
> never see a resolveuid link in any HTML source in the browser. If you
> do, there's something wrong with the configured transforms.

You are right ! This is the problem, but it works on document body and it fails in static portlet. This should be a bug I need to confirm it first. Could someone confirm this on a fresh plone code&instance ?



Hanno Schlichting-4 Hanno Schlichting-4
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: resolveuid wake up the object to just made a response.redirect

On Wed, Jun 30, 2010 at 1:46 PM, toutpt <[hidden email]> wrote:
> You are right ! This is the problem, but it works on document body and it
> fails in static portlet. This should be a bug I need to confirm it first.
> Could someone confirm this on a fresh plone code&instance ?

Upgrade plone.portlet.static to version 1.2.1. I think Plone 3.3.5
still ships with an old 1.2rc1.

Hanno

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Plone-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-developers
Laurence Rowe Laurence Rowe
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: resolveuid wake up the object to just made a response.redirect

In reply to this post by toutpt
toutpt wrote
Thank you Hanno,

I will fix this tomorrow. For today I have spot the issue with your help.

> There is such a transform and a cache for it. By default you should
> never see a resolveuid link in any HTML source in the browser. If you
> do, there's something wrong with the configured transforms.

You are right ! This is the problem, but it works on document body and it fails in static portlet. This should be a bug I need to confirm it first. Could someone confirm this on a fresh plone code&instance ?
plone.portlet.static 1.2 added the resolveuid transform. http://dev.plone.org/plone/browser/plone.portlet.static/trunk/CHANGES.txt

Laurence
Loading...