WebGUI
      Click here to register.
      
Sprechen Sie WebGUI? Parlez vous WebGUI? Se habla WebGUI? Spreekt u WebGUI?

Do you speak WebGUI? Please help us translate WebGUI into your language.



     Report a Bug > WebGUI Bug Tracker

7.4 Layout asset impossible to extend

User martink
Date 4/1/2007 5:02 am
Severity Minor (annoying, but not harmful)
Version WebGUI 7.x
Views 1224
Rating -4    Rate [
|
]
Karma Rank 0.000000
Previous · Next
User Message
martink

The prepareView method in the Layout asset uses getLineage to get its content. To avoid other layouts (that are directly below the current layout) from showing up, an excludeClasses => ["WebGIUI::Asset::Wobject::Layout"] is passed to getLineage.

Now if you extend the Layout asset, or even create  another assetContainer thatis not supposed to be shown in Layouts, it is impossible to hide them from Layouts.

There is a workaroud that works by fiddling with canView (see the L33tout asset in the acme contrib area) but that is just a dirty hack, which I'd  rather not use in production code.

My suggested fix is to pass the assetContainers config option to excludeClasses. This will however have an impact in case of folders which'll stop showing up too after this 'fix'.



Back to Top
Rate [
|
]
 
 
nogura

Send me a copy of your extended Layout if you will.  From the code, I would think it would automatically exclude Asset::Wobject::Layout::NewLayout too.  

It'll be easier if I can look at what you are looking at.

You can reach me at nik@plainblack.com 



Back to Top
Rate [
|
]
 
 
martink

The problem lies in WebGUI::Asset::Wobject::Layout->prepareView. See the excerpt below (line nr's are from the svn as i write this)

148 sub prepareView {
149         my $self = shift;
150         $self->SUPER::prepareView;
151         my $children = $self->getLineage( ["children"], { returnObjects=>1, excludeClasses=>["WebGUI::Asset::Wobject::Layout"] });

The problem is caused by line 151. The excludeClasses clause is hard coded and not changeable. If you extend the layout class with something you devised on your own this extension will obviously have a classname different from WebGUI::Asset::Wobject::Layout. This in combination with the hard coded excludeClasses clause will cause any extension to be displayed on the layout it's under.

Now somewhere down the line  prepareView is filtering out the assets that return false in canView(). I used this fact in my L33tout asset to work around the problem, but it's not  a 'nice' solution:

 117 #-------------------------------------------------------------------
118 sub canView {
119         my $self = shift;
120
121         # Ironically this is sort of a hack to 'hide' the l33tout from other
122         # container assets. It's necesarry b/c the Layout asset only considers
123         # itself to be an asset container, and does not take the assetContainers
124         # setting.
125         if (isIn(caller, @{$self->session->config->get("assetContainers")})) {
126                 return 0;
127         }
128
129         return $self->SUPER::canView;
130 }

You can download the l33tout asset at  http://www.plainblack.com/uploads/AR/mi/ARmiM8GqQhF9Y2pLOsM-tw/L33out-1.0.0.tar.gz



Back to Top
Rate [
|
]
 
 
nogura

Hmm.  I would have thought that the syntax in getLineage from AssetLineage.pm would have taken care of that.  Apparently not though.

I'll dig into it.  I think what was intended was that anything under Asset::Wobject::Layout would be excluded.



Back to Top
Rate [
|
]
 
 
martink
I can fix it too, I just need to know if WG::A::W::Layout is supposed to display Folder assets. If it does the particular partof webgui concerning asset containers should be looked at. I think that's something for the dev list, in stead of bug report though.

Back to Top
Rate [
|
]
 
 
nogura

I suspect your problem is that whle you're using the base WebGUI::Asset::Wobject::Layout, your class name is WebGUI::Asset::Wobject::L33tout.

The getLineage function will automatically not return anything starting with WebGUI::Asset::Wobject::Layout.  

Since you are extending Layout, is it too much to ask that the classname be WebGUI::Asset::Wobject::Layout::L33tout?  That way, the built in filtering will automatically take care of it.  That seems to be the organizational pattern of wG.  I'd want to think long and hard before messing with it.

 

Let me know your thoughts on this.  I'm still pretty new on the project, and might have missed some parts. 



Back to Top
Rate [
|
]
 
 
martink

The getLineage function will automatically not return anything starting with WebGUI::Asset::Wobject::Layout. 

Since you are extending Layout, is it too much to ask that the classname be WebGUI::Asset::Wobject::Layout::L33tout?

Ah, I see. I never noticed that getLineage() extends the className with a like clause. If figured it uses an =. 

I would be fine with the class you suggest too, but I already put the old one in the contrib acme section, so I'd rather not. That's no problem since it's only an Acme and it work with the work around too.

Still, I think the handling of container assets should be treated differently somehow. What happens if someone wants to create another container asset that is not supposed to be displayed on a page layout?  It seems more an API thing.

Anyway, closing this 'bug' for now. It can wait till the wuc or so =)



Back to Top
Rate [
|
]
 
 
nogura

I talked to JT on this one.  He concurrs that, for the time being anyway, the way to do what you want to do is as follows:

Set up your Wobject as WebGUI::Asset::Wobject::Layout::L33tout .  To do otherwise would significantly impact performance.

I'm gonna close this one as a bug as, the creature is in fact, doing just what the man wants it to do. 



Back to Top
Rate [
|
]