-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I'm trying hard to develop an application in Zope and I'm crashing against brick walls in every step. It seems I still don't get the philosophy of Zope/web application development. How do I know what objects exists when a script I wrote run, and what classes those objects belong to and what methods does classes have... that is, the functionality I have. In php I just had a bunch of variables printable by phpinfo() and/or print_r (a print all command) to inspect structures and so on... dir() doesn't work in zope, so, I don't have the standard python way of doing this. My current questions are: 1) How do I get my username and related information ? 2) How do I add more methadata to users, like name and e-mail ? 3) How do I list folders that are owned by the logged in user ? 4) How do I redirect the browser to another page ? Thanks. - -- Pupeno: pupeno@pupeno.com - http://www.pupeno.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) iD8DBQFBBBlKfW48a9PWGkURAgY2AJ0ZnKuAhEWj9/x/UBG5iV9eIu6KsQCcC8CD sAfXkrx2RoVGrB5hSf5s7Ag= =8DnQ -----END PGP SIGNATURE-----
----- Original Message ----- From: "Pupeno" <pupeno@pupeno.com> To: <zope@zope.org> Sent: Sunday, July 25, 2004 1:34 PM Subject: [Zope] trying to do some developing I'm trying hard to develop an application in Zope and I'm crashing against brick walls in every step. It seems I still don't get the philosophy of Zope/web application development. How do I know what objects exists when a script I wrote run, and what classes those objects belong to and what methods does classes have... that is, the functionality I have. In php I just had a bunch of variables printable by phpinfo() and/or print_r (a print all command) to inspect structures and so on... dir() doesn't work in zope, so, I don't have the standard python way of doing this. My current questions are: 1) How do I get my username and related information ? Pupeno, This will get you your roles and username. <dtml-var "_.SecurityGetUser().getRoles()"> <dtml-var "_.SecurityGetUser().getUserName()"> 2) How do I add more methadata to users, like name and e-mail ? Take a look at Chris Withers' SimpleUserfolder. With it you can store user name, password and anything else in an external database or even stored as folder properties. I easily found this link with a little googling http://www.python.org/wiki/pub/EuroPython2004Slides/attachments/EPC2004-ZUF.... ps - Just do not use it from the Zope Root! Well you can but don't until your getting good results in a test folder and you have a very good reason. 3) How do I list folders that are owned by the logged in user ? An interesting question is "how do I list folders owned by another user". Your question I think is covered by the Zope Tutorial. You might want to read the Zope Book at www.zope.com. 4) How do I redirect the browser to another page ? <dtml-call "RESPONSE.redirect(URL1+'/')"> is an example. Thanks. - --
Pupeno wrote at 2004-7-25 17:34 -0300:
... It seems I still don't get the philosophy of Zope/web application development. How do I know what objects exists when a script I wrote run,
Maybe some background reading could help you. Did you read the Zope Book (2.6/2.7 edition; online). <http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html> might be helpful as well. The most essential existing objects are the one that you see in the ZMI (Zope Management Interface). In many contexts, some of these objects are bound to names such as "context", "container", "request", ... The Zope Book tells you which names are bound to which objects in the various contexts...
and what classes those objects belong to
There is a convention in Zope (not enforced): Zope's web site building classes have an attribute "meta_type" which should be a human readable description of the class. This means: usually "object.meta_type" gives you an indication towards the object's type/class. It is not easy to learn the class itself. You must be in trusted code (External Methods, Python Product code) and you must use some magic: "object.aq_base.__class__".
and what methods does classes have...
"DocFinder[EveryWhere]" can help you with this -- besides the source of course. <http://www.dieter.handshake.de/pyprojects/zope>
... My current questions are: 1) How do I get my username and related information ?
It depends in what context you are. You can access the current user (an instance of "AccessControl.User.BasicUser") in PageTemplate: via the predefined "user" variable PythonScript/External Method/ Python Product code: from AccessControl import getSecurityManager user = getSecurityManager().getUser() in DTML: via "getSecurityUser".
2) How do I add more methadata to users, like name and e-mail ?
The standard UserFolder cannot do this. Extended user folders provide this feature: e.g. SimpeUserFolder, exUserFolder, ...
3) How do I list folders that are owned by the logged in user ?
You must write a script that traverses your site ("ZopeFind" can help you with this) and checks the "local role" "Owner" (read the Zope Book to learn what a "local role" means).
4) How do I redirect the browser to another page ?
You use the "redirect" method of the RESPONSE object. -- Dieter
participants (3)
-
David Hassalevris -
Dieter Maurer -
Pupeno