Re: [Zope3-Users] Re: Traverse to nearest site in menu action

2005-04-06 Thread Florian Lindner
Am Mittwoch, 6. April 2005 15:33 schrieb Philipp von Weitershausen:
> Florian Lindner wrote:
> > Am Samstag, 2. April 2005 08:37 schrieb Stephan Richter:
> >>On Saturday 02 April 2005 04:38, jÃrgen Kartnaller wrote:
> Why in the world would you want to do that? This seems just awful. What
> is your use case?
> >>>
> >>>In my case I want to have the possibility to jump back to my base view
> >>>(which is the default view of my site) from wherever I am within my
> >>> site.
> >>>
> >>>But, if there is an easier way to do this, please let me know.
> >>
> >>Then write a wrapper view for all interfaces that internally looks up the
> >>next site and looks up the default view:
> >>
> >>class SiteDefaultView(object):
> >>
> >>  def __call__(self):
> >>site = getNextSiteSomehow()
> >>defaultViewName = getDefaultViewName(site, self.request, site)
> >>view = zapi.getMultiAdapter((site, request), Interface,
> >>name=defaultViewName) return view()
> >
> > Hello,
> > your solution:
> >
> > class toSite(object):
> > def __call__(self):
> > from zope.app.zapi import *
>
> ugh. Don't do "from xyz import *" imports. Here it's ok maybe because
> the scope of the import is limited to the __call_ method. But still,
> they're highly discouraged.

Sure. I've changed it as soon as I mark this code as stable in my mind. Just 
for quick coding.

> > site = getSite()
> > defaultViewName = getDefaultViewName(site, self.request, site)
> > view = getMultiAdapter((site, self.request),
> > name=defaultViewName) return view()
> >
> > get the same results as mine:
> >
> > class toSite(object):
> > def __call__(self):
> > from zope.app.zapi import absoluteURL
> > URL = absoluteURL(getSite(), self.request)
> > return self.request.response.redirect(URL)
> >
> >
> > What are the differences? Which is better? Why?
> >
> > I think yours is better since it does not involve a redirect. What do you
> > think?
>
> I think your solution is better, Florian. Stephan's solution, while
> correct, makes it look like a site can or maybe even should be accessed
> through http://mysite.com/someobject/@@getSite.html. That's of course
> not true, a site should always be reached at
> http://mysite.com/++etc++site, so IMO it's better to redirect.
>
> (One case where the redirect is definitely better is bookmarks. Imagine
> somebody gets the site through Stephan's solution and bookmarks that
> page. Then, later, 'someobject' is renamed to 'anobject'; now the
> bookmark won't work anymore, even though the site is still there).

Thanks,

Florian
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Re: Traverse to nearest site in menu action

2005-04-03 Thread Stephan Richter
On Sunday 03 April 2005 17:02, Florian Lindner wrote:
> > You probably set your base path incorrectly. Anyways, I still think this
> > is a horrible way to do it; I would rather build a view that forwards you
> > to the site.
>
> Hello,
> I've implemented a view like that:
>
> class toSite(object):
> Â Â def __call__(self):
> Â Â Â Â from zope.app.zapi import absoluteURL
> Â Â Â Â URL = absoluteURL(getSite(), self.request)
> Â Â Â Â return self.request.response.redirect(URL)
>
> Which for me works perfectly. Any drawbacks of this solution?

No, this is perfect. Its even cleverer than my suggest algorithm.

Regards,
Stephan
-- 
Stephan Richter
CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Re: Traverse to nearest site in menu action

2005-04-03 Thread Florian Lindner
Am Samstag, 2. April 2005 08:37 schrieb Stephan Richter:
> On Saturday 02 April 2005 04:38, jÃrgen Kartnaller wrote:
> > > Why in the world would you want to do that? This seems just awful. What
> > > is your use case?
> >
> > In my case I want to have the possibility to jump back to my base view
> > (which is the default view of my site) from wherever I am within my site.
> >
> > But, if there is an easier way to do this, please let me know.
>
> Then write a wrapper view for all interfaces that internally looks up the
> next site and looks up the default view:
>
> class SiteDefaultView(object):
>
>   def __call__(self):
>   site = getNextSiteSomehow()
>   defaultViewName = getDefaultViewName(site, self.request, site)
>   view = zapi.getMultiAdapter((site, request), Interface,
> name=defaultViewName) return view()

Hello,
your solution:

class toSite(object):
def __call__(self):
from zope.app.zapi import *
site = getSite()
defaultViewName = getDefaultViewName(site, self.request, site)
view = getMultiAdapter((site, self.request), name=defaultViewName)
return view()

get the same results as mine:

class toSite(object):
def __call__(self):
from zope.app.zapi import absoluteURL
URL = absoluteURL(getSite(), self.request)
return self.request.response.redirect(URL)


What are the differences? Which is better? Why?

I think yours is better since it does not involve a redirect. What do you 
think?

Thanks,

Florian

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Re: Traverse to nearest site in menu action

2005-04-03 Thread Florian Lindner
Am Freitag, 1. April 2005 22:37 schrieb Stephan Richter:
> On Friday 01 April 2005 11:34, Florian Lindner wrote:
> > Another problem I have, that when I've clicked on home a few times you
> > have a URL like that:
> >
> > http://horus.local:8080/++skin++centershock/cs/++site++/++site++/++site++
> >/+ +site++/++site++
> >
> > Which in IMO is not so great. Any way to normalize this path?
>
> You probably set your base path incorrectly. Anyways, I still think this is
> a horrible way to do it; I would rather build a view that forwards you to
> the site.

Hello,
I've implemented a view like that:

class toSite(object):
def __call__(self):
from zope.app.zapi import absoluteURL
URL = absoluteURL(getSite(), self.request)
return self.request.response.redirect(URL)

Which for me works perfectly. Any drawbacks of this solution?

Regards,

Florian
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Re: Traverse to nearest site in menu action

2005-04-03 Thread Florian Lindner
Am Samstag, 2. April 2005 05:38 schrieb jÃrgen Kartnaller:
> Stephan Richter wrote:
> > On Thursday 31 March 2005 09:23, Florian Lindner wrote:
> >>I implemented to traverser to the nearest site using the code in the
> >>posting:
> >>
> >>[Zope3-Users] Re: Traversing to nearest site
> >>Von: jÃrgen Kartnaller <[EMAIL PROTECTED]>
> >>An: zope3-users@zope.org
> >>Datum: 17.03.2005 13:53
> >
> > Why in the world would you want to do that? This seems just awful. What
> > is your use case?
>
> In my case I want to have the possibility to jump back to my base view
> (which is the default view of my site) from wherever I am within my site.
>
> But, if there is an easier way to do this, please let me know.

My use case is exactly the same and I think it is a common problem.

Florian
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Re: Traverse to nearest site in menu action

2005-04-02 Thread Stephan Richter
On Saturday 02 April 2005 04:38, jÃrgen Kartnaller wrote:
> > Why in the world would you want to do that? This seems just awful. What
> > is your use case?
>
> In my case I want to have the possibility to jump back to my base view
> (which is the default view of my site) from wherever I am within my site.
>
> But, if there is an easier way to do this, please let me know.

Then write a wrapper view for all interfaces that internally looks up the next 
site and looks up the default view:

class SiteDefaultView(object):

  def __call__(self):
site = getNextSiteSomehow()
defaultViewName = getDefaultViewName(site, self.request, site)
view = zapi.getMultiAdapter((site, request), Interface, 
name=defaultViewName)
return view()

Regards,
Stephan
-- 
Stephan Richter
CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Re: Traverse to nearest site in menu action

2005-04-01 Thread Stephan Richter
On Friday 01 April 2005 11:34, Florian Lindner wrote:
> Another problem I have, that when I've clicked on home a few times you have
> a URL like that:
>
> http://horus.local:8080/++skin++centershock/cs/++site++/++site++/++site++/+
>+site++/++site++
>
> Which in IMO is not so great. Any way to normalize this path?

You probably set your base path incorrectly. Anyways, I still think this is a 
horrible way to do it; I would rather build a view that forwards you to the 
site.

Regards,
Stephan
-- 
Stephan Richter
CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Re: Traverse to nearest site in menu action

2005-04-01 Thread Stephan Richter
On Friday 01 April 2005 11:34, Florian Lindner wrote:
> > > > ForbiddenAttribute: ('__call__',  > > > object at 0xb6ee2d6c>)
> > > >
> > > >
> > > > How do I have to call it?
> > >
> > > I do the same without problems.
> > > Is your folder configuration correct (ZCML, interface, implementation)
> > > ?
>
> It works now. I needed to add a permission attribute to the menuItem
> subdirective.
> But why? I'm logged in as a zope,Manager and therefor I should have rights
> to see the site.

Because once you specify a permission for a menu item, the check on the 
'__call__' method is skipped.

Regards,
Stephan
-- 
Stephan Richter
CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Re: Traverse to nearest site in menu action

2005-04-01 Thread Florian Lindner
Am Donnerstag, 31. MÃrz 2005 13:58 schrieb Florian Lindner:
> Am Donnerstag, 31. MÃrz 2005 13:00 schrieb jÃrgen Kartnaller:
> > Florian Lindner wrote:
> > > Hello,
> > > I implemented to traverser to the nearest site using the code in the
> > > posting:
> > >
> > > [Zope3-Users] Re: Traversing to nearest site
> > > Von: jÃrgen Kartnaller <[EMAIL PROTECTED]>
> > > An: zope3-users@zope.org
> > > Datum: 17.03.2005 13:53
> > >
> > > it works: When I'm calling
> > > http://horus.local:8080/++skin++centershock/cs/++site++ I see the
> > > contents of the root folder (my nearest site).
> > >
> > > Now I want to use for a menu item:
> > >
> > >  > > menu="CSnavMenu"
> > > for="*"
> > > layer="centershock">
> > >
> > >  > > title="home2"
> > > action="++site++" />
> > >
> > > 
> > >
> > > Resulting in:
> > >
> > >   File "/home/florian/Zope3/src/zope/app/publisher/browser/menu.py",
> > > line 180, in getMenu
> > > return menu.getMenuItems(object, request)
> > >   File "/home/florian/Zope3/src/zope/app/publisher/browser/menu.py",
> > > line 55, in getMenuItems
> > > if item.available():
> > >   File "/home/florian/Zope3/src/zope/app/publisher/browser/menu.py",
> > > line 123, in available
> > > if not canAccess(view, '__call__'):
> > >   File "/home/florian/Zope3/src/zope/security/checker.py", line 114, in
> > > canAccess
> > > checker.check_getattr(obj, name)
> > > ForbiddenAttribute: ('__call__',  > > at 0xb6ee2d6c>)
> > >
> > >
> > > How do I have to call it?
> >
> > I do the same without problems.
> > Is your folder configuration correct (ZCML, interface, implementation) ?

It works now. I needed to add a permission attribute to the menuItem 
subdirective.
But why? I'm logged in as a zope,Manager and therefor I should have rights to 
see the site.

Another problem I have, that when I've clicked on home a few times you have a 
URL like that:

http://horus.local:8080/++skin++centershock/cs/++site++/++site++/++site++/++site++/++site++

Which in IMO is not so great. Any way to normalize this path?

Florian
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Re: Traverse to nearest site in menu action

2005-03-31 Thread Florian Lindner
Am Donnerstag, 31. MÃrz 2005 13:00 schrieb jÃrgen Kartnaller:
> Florian Lindner wrote:
> > Hello,
> > I implemented to traverser to the nearest site using the code in the
> > posting:
> >
> > [Zope3-Users] Re: Traversing to nearest site
> > Von: jÃrgen Kartnaller <[EMAIL PROTECTED]>
> > An: [EMAIL PROTECTED]
> > Datum: 17.03.2005 13:53
> >
> > it works: When I'm calling
> > http://horus.local:8080/++skin++centershock/cs/++site++ I see the
> > contents of the root folder (my nearest site).
> >
> > Now I want to use for a menu item:
> >
> >  > menu="CSnavMenu"
> > for="*"
> > layer="centershock">
> >
> >  > title="home2"
> > action="++site++" />
> >
> > 
> >
> > Resulting in:
> >
> >   File "/home/florian/Zope3/src/zope/app/publisher/browser/menu.py", line
> > 180, in getMenu
> > return menu.getMenuItems(object, request)
> >   File "/home/florian/Zope3/src/zope/app/publisher/browser/menu.py", line
> > 55, in getMenuItems
> > if item.available():
> >   File "/home/florian/Zope3/src/zope/app/publisher/browser/menu.py", line
> > 123, in available
> > if not canAccess(view, '__call__'):
> >   File "/home/florian/Zope3/src/zope/security/checker.py", line 114, in
> > canAccess
> > checker.check_getattr(obj, name)
> > ForbiddenAttribute: ('__call__',  > 0xb6ee2d6c>)
> >
> >
> > How do I have to call it?
>
> I do the same without problems.
> Is your folder configuration correct (ZCML, interface, implementation) ?

I'll double check everything and report back.

Florian
___
Zope3-users mailing list
[EMAIL PROTECTED]
http://mail.zope.org/mailman/listinfo/zope3-users