Portlets at the root of the website and the getShop method

2 views
Skip to first unread message

Lôc Cosnier

unread,
Jun 2, 2010, 5:13:11 PM6/2/10
to easy...@googlegroups.com
Hi all,

I would like to have an homogeneous website about portlets but the
EasyShop portlets can't be view outside the shop.
I try to change the getShop method in easyshop.shop

def getShop(self):
"""
"""
object = self.context

#try:
# while IShop.providedBy(object) == False:
# if object.meta_type == "Plone Factory Tool":
# object = object.aq_parent
# else:
# object = object.aq_inner.aq_parent
#except AttributeError:

# Next line is needed for the temporary products for payment and
# shipping. As they have real context above code seems not to
# work. But they have given the shop as context so we can give
# it back here. See also:
# - adapters/shop/payment/createTemporaryPaymentProduct
# -
adapters/shop/shipping/createTemporaryShippingProduct.
# I'm not sure whether this is clean, I assume it is not.

#try:
# if IShop.providedBy(object.context):
# return object.context
# else:
# return None
#except AttributeError:
# return None

while object.meta_type != "Plone Site":
try:
object = object.aq_inner.aq_parent
except AttributeError:
object = object.context

catalog = getToolByName(object, "portal_catalog")
for shop in catalog(portal_type = "EasyShop"):
if shop:
object = shop.getObject()
return object

And it works for me but I don't know if it's a good idea, because from
my point of view, I want one only instance of EasyShop and if there are
more, I think this method doesn't work...
Does anyone has a better solution (or a better code)?

Loc

ned14

unread,
Jun 3, 2010, 8:13:59 AM6/3/10
to easyshop
There are several places throughout the Easyshop code where the
problem of what context to use arises, and to my knowledge there is a
temporary hack which simply forces it to the first shop added to the
Plone site. There is a comment right next to the code in question, and
I think it's in easyshop.core.

Can you have your modification pull the context from that hack in
easyshop.core? That way everything runs through the same hack so if
someone wanted say the second shop in the Plone site it would be very
easy to change.

I can try to refind that code for you if you can't find it?

Niall

Lôc Cosnier

unread,
Jun 4, 2010, 11:26:54 AM6/4/10
to easy...@googlegroups.com
Hi,

Thanks Niall for answer.

> Can you have your modification pull the context from that hack in
> easyshop.core?

No.

Well, I'll try to find that code this week-end.
I saw that my code doesn't work for anonymous checkout.

I changed the getShop method to resolve this problem and check if there
are one instance or more of EasyShop,
but I'll look more closely at the code in easyshop.core and I'll tell
you after.

Loc


Le 03/06/2010 14:13, ned14 a �crit :


> There are several places throughout the Easyshop code where the
> problem of what context to use arises, and to my knowledge there is a
> temporary hack which simply forces it to the first shop added to the
> Plone site. There is a comment right next to the code in question, and
> I think it's in easyshop.core.
>
> Can you have your modification pull the context from that hack in
> easyshop.core? That way everything runs through the same hack so if
> someone wanted say the second shop in the Plone site it would be very
> easy to change.
>
> I can try to refind that code for you if you can't find it?
>
> Niall
>
>

Lôc Cosnier

unread,
Jun 4, 2010, 11:33:59 AM6/4/10
to easy...@googlegroups.com
>
>> Can you have your modification pull the context from that hack in
>> easyshop.core?
>>
> No.
Oups, sorry, this is not what I wanted to say.

Loc


Le 04/06/2010 17:26, L�c Cosnier a �crit :

Reply all
Reply to author
Forward
0 new messages