RE: "Per-user" polymorphism -- newbie question

"Al Pacifico" <[email protected]>
Newsgroups gmane.comp.web.quixote.user
Message-ID <007f01c59f6c$685c4910$337ba8c0@Laptop8100>
Thanks for the responses.

Mike is right, I should be thinking of _q_traverse.

[I know the bit about the XML/XSLT seemed non-germane, but it implies
mapping URI's to the filesystem is inappropriate if you wish to have a
speedy application. (Carlo Contadini's mod_xslt apache module is coming
close, but it is not fully Apache 2 compatible yet and doesn't cache
stylesheets yet, which led me to Quixote/libxml2/libxslt).]

I had been thinking of something (not really Python code yet) along the
lines of:

class UserRoleBaseClass

class BossClass(UserRoleBaseClass)
	def q_traverse(self,path)

	def hireEmployee

	def fireEmployee

	def praiseEmployee

	def reprimandEmployee

....and...

class myDirectory

	def _q_index

	def q_traverse(self,path)
		if session.user_role:
			return session.user_role._q_lookup

Anyone foresee a problem with this?
-al

Al Pacifico
Seattle, WA

-----Original Message-----
From: Mike Orr [mailto:[email protected]] 
Sent: Thursday, August 11, 2005 9:13 PM
To: Al Pacifico
Cc: [email protected]
Subject: Re: [Quixote-users] "Per-user" polymorphism -- newbie question

[email protected] wrote:

>Al Pacifico wrote:
>
>What I'm thinking of:
>I'd like to make my content served by Quixote essentially polymorphic,
>determined by the role the user takes. This points me in the direction of
>subclassing a base class for each role. I imagine q_lookup() would call a
>method within a class determined by the client's role.
>  
>


If you need _q_lookup anyway.  If you're just using it for permission 
checking, ._q_traverse would be more appropriate.  But if the component 
names have to be calculated from the permissions, or there are so many 
names that having a separate method for each would be 
difficult/impossible, ._q_lookup would be appropriate.

/foo/bar             -- Regular method.
/articles/1234    -- ._q_lookup  (one catchall component, possibly
                         returning a sub-Directory)
/showdate/2005/08/11    -- ._q_traverse   (several catchall components
                         taken as a unit)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.