Al Pacifico wrote:
> class UserRoleBaseClass
>
> class BossClass(UserRoleBaseClass)
> def q_traverse(self,path)
>
> def hireEmployee
>
> 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?
It would be helpful to see the URL tree from the user's perspective. I'm
not sure how these methods relate to URLs, and thats what determines the
appropriate class structure. I start my apps with a comment like:
1 / Main page.
2 /search Search form.
3 /entries List all -or- search results.
4 /add Add an entry.
5 /123/ Show details for entry 123.
6 /123/modify Modify entry 123.
Hyperlinks:
1 -> 2 -> 3 Do search.
1 -> 3 -> 5 View entry.
1 -> 3 -> 5 -> 6 Modify entry. (Then back to 5.)
This would imply a RootDirectory for 1-4 and an EntryDirectoryhave for 5-6.
My applications have a static set of methods, and the permissions merely
determine what links the user sees and which methods cause access errors.
It sounds like your situation is different, that you want each user type
to see a wildly unique set of URLs. In that case I would make the user
classes double as Directories (or have a companion Directory for each user
class). I'm not sure if that's what you meant because your classes have
.._q_traverse but do not inherit from Directory. They don't have to, but
it would make it clearer. If they are *not* directories, ._q_traverse
should be named something else.
Assuming they are directories, if they have a well-known parent you could
do something like this:
# For URL /controlPanel/hireEmployee
class RootDirectory(Directory):
_q_exports = ['controlPanel', ...]
def controlPanel(self):
user = quixote.get_user() # Is a Directory subclass.
return user # Return it as the subdirectory.
If they are directly at the root level, I guess there's two ways. I'm not
quite sure about these.
# For URL /hireEmployee
class RootDirectory(Directory):
def _q_lookup(self, component):
userDirectory = quixote.get_user()
# Or choose the directory indirectly from the user ID.
# Next line can raise AttributeError.
method = getattr(userDirectory, component)
return method()
Or you can delegate from one ._q_traverse to another, which it looks like
you were doing.
# For URL /hireEmployee
class RootDirectory(Directory):
def _q_traverse(self, path):
userDirectory = quixote.get_user()
return userDirectory._q_traverse(path)
That would substitute the other directory's URLs without making it look
like a subdirectory, I think.
--
-- Mike Orr <[EMAIL PROTECTED]>
_______________________________________________
Quixote-users mailing list
[email protected]
http://mail.mems-exchange.org/mailman/listinfo/quixote-users