RE: [Zope3-Users] Making site skins

2005-08-17 Thread Roger Ineichen
Hi Johan 

> -Original Message-
> From: Johan Carlsson [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, August 17, 2005 8:38 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [Zope3-Users] Making site skins
> 
> 
> And also thanks for reminding me of the src distribution of Zope3 :-)
> As a Windows user I run the beta dist which exludes a lot of stuff.
> Cheers,
> Johan

You can checkout the trunk witha subverison client like
TortoiseSVN from: 

After that, download the latest compiled *.pyd files from
http://www.zope.org/Members/tim_one/

and extract the zip at the root of your zope.
After that add a principals.zcml and you will be able 
to start with "python z3.py" the fresh version from the trunk
without a compiler.

Regards
Roger

> -- 
> Johan Carlsson  Tel: + 46 8 31 24 94
> Colliberty  Mob: + 46 70 558 25 24
> Torsgatan 72Email: [EMAIL PROTECTED]
> SE-113 37 STOCKHOLM
> 
> 

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


Re: [Zope3-Users] Making site skins

2005-08-17 Thread Johan Carlsson

Roger Ineichen wrote:

Take a look at:
src\zope\app\demo\skinpref

It's a demo how you can use preferences for to switch the skin.
Probably you can use some parts from there.

Regards
Roger Ineichen


Thanks Roger,
Sound like something right up my alley :-)
/Johan

--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM

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


RE: [Zope3-Users] Making site skins

2005-08-17 Thread Roger Ineichen
Hi Johan

On Behalf Of Johan Carlsson
> Sent: Wednesday, August 17, 2005 7:59 PM
> To: Dominik Huber
> Cc: zope3-users@zope.org
> Subject: Re: [Zope3-Users] Making site skins
> 
> 
> Some small success :-)
> 
> I've figured out (thanks to input Dominik, others, and reading the
> source):
> 
> - how to change the current skin
> - how to load a resource from that skin
> 
> The following is currently running in my test View class:
> 
> ns='resource'
> name='test_me.html'
> request=self.request
> object=self.context
> 
> #Look up the skin interface
> adapters = zapi.getSiteManager().adapters
> skin = adapters.lookup((providedBy(self.request),), IDefaultSkin, '')
> skin = zapi.getUtility(ISkin, 'my_test')
> 
> #Change the defaultSkin of the current request
> if skin is not None:
>  directlyProvides(self.request, skin)
> 
> #Get the traversal adapter for the namespace (e.g. resource)
> traverser = zope.component.queryMultiAdapter((object, request), \
>  ITraversable, ns)
> if traverser is None:
>  raise TraversalError("++%s++%s" % (ns, name))
> 
> #Traverse the resource (e.g. 'test_me.html)
> resource = traverser.traverse(name, ())
> return resource()

Take a look at:
src\zope\app\demo\skinpref

It's a demo how you can use preferences for to switch the skin.
Probably you can use some parts from there.

Regards
Roger Ineichen

Projekt01 GmbH
www.projekt01.ch
_
END OF MESSAGE 

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


Re: [Zope3-Users] Making site skins

2005-08-17 Thread Johan Carlsson


Some small success :-)

I've figured out (thanks to input Dominik, others, and reading the
source):

- how to change the current skin
- how to load a resource from that skin

The following is currently running in my test View class:

ns='resource'
name='test_me.html'
request=self.request
object=self.context

#Look up the skin interface
adapters = zapi.getSiteManager().adapters
skin = adapters.lookup((providedBy(self.request),), IDefaultSkin, '')
skin = zapi.getUtility(ISkin, 'my_test')

#Change the defaultSkin of the current request
if skin is not None:
directlyProvides(self.request, skin)

#Get the traversal adapter for the namespace (e.g. resource)
traverser = zope.component.queryMultiAdapter((object, request), \
ITraversable, ns)
if traverser is None:
raise TraversalError("++%s++%s" % (ns, name))

#Traverse the resource (e.g. 'test_me.html)
resource = traverser.traverse(name, ())
return resource()


Cheers,
Johan

--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM

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


Re: [Zope3-Users] Making site skins

2005-08-17 Thread Dominik Huber

Johan Carlsson wrote:

(zope.app.publication.httpfactory.HTTPPublicationRequestFactory -> 
zope.app.publication.browser.setDefaultSkin)


Afterward the specific adapters such as views get invoked, because 
you register those to a dedicated request interface using the layer 
attribute. Attention they get looked up via the regular 
default-adapter mechansim and not as named adapters.


IMO you can register only a specific IDefaultSkin adapter to a site 
marked for example as ISkinableSite:


   
factory='.adapter_that_offers_a_skin_interface_selected_by_the_user' />


Within this adapter you can invoke the user preferences or something 
else.


The browser request gets directly marked by a skin interface.This is 
done by the http publication request factory:


Thanks Dominik,
I been reading the source and trying to figure this out (still trying 
to get in to the adapter/interface thinking, which is really hard and 
unintuitive for me.)


I do not quite understand what your suggesting.
Could you give me a short list of what steps would be involved 
implementing your suggestion? And how it would work from a user 
perspective?


Excuse me, I was wrong. The setDefaultSkin function does not adapt 
regularly to IDefaultSkin is just looks up the registered interface 
using the IDefaultSkin. So you cannot provide your own adapter 
evaluating a skin.



What I'm not quite sure about is what a IDefaultSkin is?
Is it the interface for the global default skin for the whole server?


The IDefaultSkin is just a marker that is used to register the skin 
declared within the browser:defaultSkin directive. (handler : 
zope.app.publisher.browser.metaconfigure.defaultSkin, the default skin 
is set regularly within zope.app.browser.zcml)


Regards,
Dominik




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


Re: [Zope3-Users] Making site skins

2005-08-17 Thread Johan Carlsson

Dominik Huber wrote:

Johan Carlsson wrote:



Ok, so far I figured out the following:

1. Resources gets registered as adapters in the Global Site Manager.
2. The adapter is registerd to adapt from the current layer interface 
(defaults to IDefaultBrowserLayer) to the Interface interface 
(strange, why is that so I wounder?)



The browser request gets directly marked by a skin interface.This is 
done by the http publication request factory:
(zope.app.publication.httpfactory.HTTPPublicationRequestFactory -> 
zope.app.publication.browser.setDefaultSkin)


Afterward the specific adapters such as views get invoked, because you 
register those to a dedicated request interface using the layer 
attribute. Attention they get looked up via the regular default-adapter 
mechansim and not as named adapters.


IMO you can register only a specific IDefaultSkin adapter to a site 
marked for example as ISkinableSite:




Within this adapter you can invoke the user preferences or something else.


Thanks Dominik,
I been reading the source and trying to figure this out (still trying to 
get in to the adapter/interface thinking, which is really hard and 
unintuitive for me.)


I do not quite understand what your suggesting.
Could you give me a short list of what steps would be involved 
implementing your suggestion? And how it would work from a user perspective?


Cheers,
Johan


--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM

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


Re: [Zope3-Users] Making site skins

2005-08-17 Thread Johan Carlsson

Dominik Huber wrote:

Johan Carlsson wrote:



Ok, so far I figured out the following:

1. Resources gets registered as adapters in the Global Site Manager.
2. The adapter is registerd to adapt from the current layer interface 
(defaults to IDefaultBrowserLayer) to the Interface interface 
(strange, why is that so I wounder?)



The browser request gets directly marked by a skin interface.This is 
done by the http publication request factory:
(zope.app.publication.httpfactory.HTTPPublicationRequestFactory -> 
zope.app.publication.browser.setDefaultSkin)


Afterward the specific adapters such as views get invoked, because you 
register those to a dedicated request interface using the layer 
attribute. Attention they get looked up via the regular default-adapter 
mechansim and not as named adapters.


IMO you can register only a specific IDefaultSkin adapter to a site 
marked for example as ISkinableSite:




Within this adapter you can invoke the user preferences or something else.


Thanks for the input Dominik.
I think this is just the info I wanted.

Now I just need to understand it as well :-)




--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM

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


Re: [Zope3-Users] Making site skins

2005-08-16 Thread Dominik Huber

Johan Carlsson wrote:



Ok, so far I figured out the following:

1. Resources gets registered as adapters in the Global Site Manager.
2. The adapter is registerd to adapt from the current layer interface 
(defaults to IDefaultBrowserLayer) to the Interface interface 
(strange, why is that so I wounder?)


The browser request gets directly marked by a skin interface.This is 
done by the http publication request factory:
(zope.app.publication.httpfactory.HTTPPublicationRequestFactory -> 
zope.app.publication.browser.setDefaultSkin)


Afterward the specific adapters such as views get invoked, because you 
register those to a dedicated request interface using the layer 
attribute. Attention they get looked up via the regular default-adapter 
mechansim and not as named adapters.


IMO you can register only a specific IDefaultSkin adapter to a site 
marked for example as ISkinableSite:




Within this adapter you can invoke the user preferences or something else.

Regards,
Dominik

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


Re: [Zope3-Users] Making site skins

2005-08-16 Thread Johan Carlsson


Ok, so far I figured out the following:

1. Resources gets registered as adapters in the Global Site Manager.
2. The adapter is registerd to adapt from the current layer interface 
(defaults to IDefaultBrowserLayer) to the Interface interface (strange, 
why is that so I wounder?)
3. The layer interface I can look up byt calling: 
zapi.getUtility(ILayer, 'my_layer')


Ok, fine. So from my View class I try the following:

gsm=zapi.getGlobalSiteManager()
layer = zapi.getUtility(ILayer, 'my_test')
adapter=gsm.queryAdapter(layer, Interface, 'test_me.html')


But this doesn't work, I get the following error:


Error type: exceptions.KeyError
Error object: 

File "C:\Python24\Lib\site-packages\zope\publisher\publish.py", line 
138, in publish


File 
"C:\Python24\Lib\site-packages\zope\app\publication\zopepublication.py", 
line 164, in callObject


File "C:\Python24\Lib\site-packages\zope\publisher\publish.py", line 
113, in mapply


File "C:\Python24\Lib\site-packages\zope\publisher\publish.py", line 
119, in debug_call


File "C:\Zope\Zope31\lib\python\wfc\browser\metasite.py", line 44, in 
__call__

adapter=gsm.queryAdapter(layer, Interface, 'test_me.html')

File "C:\Python24\Lib\site-packages\zope\component\site.py", line 70, in 
queryAdapter

"""Set all module' __file__ attribute to an absolute path"""

File "C:\Zope\Zope31\lib\python\zope\interface\adapter.py", line 414, in 
queryAdapter

return self.adapter_hook(interface, object, name, default)

File "C:\Zope\Zope31\lib\python\zope\interface\adapter.py", line 404, in 
adapter_hook

factory = self.lookup1(providedBy(object), interface, name)

File "C:\Zope\Zope31\lib\python\zope\interface\adapter.py", line 392, in 
lookup1

return self.lookup((required,), provided, name, default)

File "C:\Zope\Zope31\lib\python\zope\interface\adapter.py", line 327, in 
lookup

byname = s.get(provided)

File "C:\Zope\Zope31\lib\python\zope\interface\adapter.py", line 227, in get
self.clean()

File "C:\Zope\Zope31\lib\python\zope\interface\adapter.py", line 146, in 
clean

base.unsubscribe(self)

File "C:\Zope\Zope31\lib\python\zope\interface\adapter.py", line 248, in 
unsubscribe

del self.dependents[dependent]

File "C:\Python24\lib\weakref.py", line 216, in __delitem__
del self.data[ref(key)]


Can somebody sched a light on this problem?

Regards,
Johan




--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM

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