[PEAK] Example using sitemap.xml and bulletins

Tiago Cogumbreiro cogumbreiro at gmail.com
Fri Mar 25 16:46:07 EST 2005


I've been playing with sitemap a little further and actually managed
to make it show something. I've used an example analogical to
bulletins, yet it's not the same. However i'm going to "translate" the
sitemap in order to make it simillar for simplicity's sake:

<location id="root" config="bulletins">
	<import module="bulletins.app"/>
	<import module="bulletins.model"/>
	<import module="bulletins.storage"/>
	
	<container object="bulletins.app.BulletinsApp()"/>
	
	<content type="bulletins.model.Bulletin">
		<allow attributes="fullText"/>
		<view name="index_html" resource="bulletins.templates/bulletin"/>
	</content>
	
	<content type="bulletin.storage.BulletinDM">
		<view name="index_html" resource="bulletin.templates/list_bulletins"/>
	</content>

	<content type="bulletins.app.BulletinsApp">
		<allow attributes="Bulletins"/>
		<view name="index_html" resource="imobil.templates/main"/>
	</content>	
</location>

This sitemap is supposed to create a /Bulletins location which allows
/Bulletins/<ID> to retrieve a bulletins.model.Bulletin, using the
bulletin.templates/bulletin template.

However i've encountered some problems. 

The views inside the BulletinDM are ignored, thus the resource
'bulletin.templates/list_bulletins' is never accessed. This happens
because it tries to do a __getitem__ on the object first, so it sends
an error message because it tries to access the object with an id
index_html.

oid's related to sql are usually int's, but they (the web controller)
send a string. How can one intercept this procedure? Currently I'm
converting any argument to an int inside the DM, but this feels like
an hack.

Can I embedd views inside of each other?

On Thu, 24 Mar 2005 22:27:11 -0500, Phillip J. Eby
<pje at telecommunity.com> wrote:
> At 05:28 PM 03/24/2005 -0100, Tiago Cogumbreiro wrote:
> >Hello list,
> >
> >I've read, done and even corrected the
> >http://peak.telecommunity.com/DevCenter/PeakWebHowTo however I'm still
> >having a little problems understanding how the sitemap elements
> ><contents> and <components> work.
> >
> >Could someone please give me an example of a sitemap.xml for the 'bulletins'?
> 
> Not right now, but maybe this will be helpful:
> 
> http://www.eby-sarna.com/pipermail/peak/2004-October/001865.html
> 
> <location> defines a fixed URL location, and you can define views on it to
> make statically-located pages.  <content> groups views that apply to one or
> more object types.  <container> defines how dynamic children of a location
> will be looked up.  So, you would typically reference DM's as containers,
> within a location that you want to be the base location, e.g.
> /Users/username to be the URL of a particular user object.  Then, you
> define a <content> block for the type of object returned by that DM, that
> contains <view> entries to define what pages are available as sub-locations
> of the user, like /Users/someUser/show (e.g. if you have a view named
> "show" for user objects).
> 
> 
> >This mail was the closer I could get:
> >http://www.eby-sarna.com/pipermail/peak/2004-November/001895.html
> >
> >The problem is the bulletins has a central component the App. How
> >would I access its data managers?
> 
> Well, you can create them directly in the sitemap as is done in that post,
> or you can make a class that subclasses both App and web.Location, then use
> <location class="BulletinsWebApp"> or whatever you called the new
> class.  But there may be easier ways; I'll try to carve out some time this
> weekend to give you a better answer to this email, as I need to go pack for
> my return trip from PyCon.
> 
> 


-- 
Tiago Cogumbreiro <cogumbreiro at users.sf.net>

http://s1x.homelinux.net/



More information about the PEAK mailing list