setting properties - some basic questions
Hello I have been studying Caseman's excellent How-To ideas for clean handling of Javascripts in Zope: http://www.zope.org/Members/Caseman/client_script_howto [Thank You!] So now I have a boolean property 'admin' for my site folders and DTMLDocuments. When admin is 'ON' various Methods are rendered on the pages some simple <dtml-if> statements such as: <dtml-if admin> admin = <dtml-var admin><br> <dtml-var showjavascripts> <dtml-else> admin is OFF </dtml-if> Please, can anyone teach me how to: Q1. set 'admin' on or off by a button on the same page? Q2. set 'admin' on or off by a button on another page? Q3. toggle 'admin' to its oppposite state via a button? Q4. perform 1, 2, 3 above via a DTML/Python method I can call from anywhere? ..my documents also have a 'scripts' property [type = 'Lines']. 'scripts' lists the names of various javascript functions wrapped as DTMLmethods. Q5. How can I edit the text in different lines of such a a property? This is my 'showjavascripts' DTMLmethod: The script properties of this DTMLdocument are:<br><br> <dtml-in scripts> <dtml-var sequence-item><br> </dtml-in> #note: scripts is a type='lines' property as above Q6. How do to create and set a property for whole lot of documents using DTML and/or Python? For example, I have a folder 'NEWARTISTS' and I want to add 'admin' and 'scripts' properties for all documents and folders within those... Q7. How to make this all work so that qualified users can login into 'admin' pages inside certain folders which will then turn 'on' the admin property flag automatically for everythign below that? Presumably 1, 2, 3, 5, 6, 7 will all use 4... I imagine this is all incredibly simple, but I need a little help to reach the aaha!! moment :-) +FINALLY, I have want to apply the same approach setting 'scripts' and 'admin' for index_html, but since it is a method it has no properties. If I apply 'scripts' and folder properties it to its parent folder it will then apply to everyhting below there by acquisition. This is handy but often I need finer grained control than that. Changing index_html to be a DTMLdocument does not work. Any suggestions for Thinking Zope here? Thanks - Jason ___________________________________________________________ Jason CUNLIFFE = NOMADICS['Interactive Art and Technology']
Jason, To my mind your thinking about it the wrong way. The pages don't suddenly become admin pages, the anonymous users become admin users so the pages should change their rendered view based on a property of the user. something like: <dtml-if "AUTHENTICATED_USER.has_role(['Manager','some_other_admin_role'])> admin = <dtml-var admin><br> <dtml-var showjavascripts> <dtml-else> admin is OFF </dtml-if> hth Phil phil.harris@zweb.co.uk ----- Original Message ----- From: "Jason Cunliffe" <jasonic@nomadicsltd.com> To: <zope@zope.org> Sent: Friday, March 02, 2001 12:43 PM Subject: [Zope] setting properties - some basic questions
Hello
I have been studying Caseman's excellent How-To ideas for clean handling of Javascripts in Zope: http://www.zope.org/Members/Caseman/client_script_howto [Thank You!]
So now I have a boolean property 'admin' for my site folders and DTMLDocuments. When admin is 'ON' various Methods are rendered on the pages some simple <dtml-if> statements such as:
<dtml-if admin> admin = <dtml-var admin><br> <dtml-var showjavascripts> <dtml-else> admin is OFF </dtml-if>
Please, can anyone teach me how to:
Q1. set 'admin' on or off by a button on the same page?
Q2. set 'admin' on or off by a button on another page?
Q3. toggle 'admin' to its oppposite state via a button?
Q4. perform 1, 2, 3 above via a DTML/Python method I can call from anywhere?
..my documents also have a 'scripts' property [type = 'Lines']. 'scripts' lists the names of various javascript functions wrapped as DTMLmethods.
Q5. How can I edit the text in different lines of such a a property?
This is my 'showjavascripts' DTMLmethod:
The script properties of this DTMLdocument are:<br><br> <dtml-in scripts> <dtml-var sequence-item><br> </dtml-in>
#note: scripts is a type='lines' property as above
Q6. How do to create and set a property for whole lot of documents using DTML and/or Python?
For example, I have a folder 'NEWARTISTS' and I want to add 'admin' and 'scripts' properties for all documents and folders within those...
Q7. How to make this all work so that qualified users can login into 'admin' pages inside certain folders which will then turn 'on' the admin property flag automatically for everythign below that?
Presumably 1, 2, 3, 5, 6, 7 will all use 4...
I imagine this is all incredibly simple, but I need a little help to reach the aaha!! moment :-)
+FINALLY, I have want to apply the same approach setting 'scripts' and 'admin' for index_html, but since it is a method it has no properties. If I apply 'scripts' and folder properties it to its parent folder it will then apply to everyhting below there by acquisition. This is handy but often I need finer grained control than that. Changing index_html to be a DTMLdocument does not work.
Any suggestions for Thinking Zope here?
Thanks
- Jason ___________________________________________________________ Jason CUNLIFFE = NOMADICS['Interactive Art and Technology']
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Phil Harris <phil.harris@zope.co.uk> wrote:
To my mind your thinking about it the wrong way.
The pages don't suddenly become admin pages, the anonymous users become admin users so the pages should change their rendered view based on a property of the user.
something like:
<dtml-if "AUTHENTICATED_USER.has_role(['Manager','some_other_admin_role'])> admin = <dtml-var admin><br> <dtml-var showjavascripts> <dtml-else> admin is OFF </dtml-if>
Phil Thanks for the alternative[lateral_think] heads up. hmm... Yes. You are of course right about user-role oriented logic. But there are some good reasons why, right now, I want to explore this direction in Zope of variable property nuances. I practice I can well imagine using a hybrid of approaches to be more efficient, depending on where the specific need is system or user[context]- oriented logic. Ironically it is precisely because I am trying to develop a very user-oreiented approach that I want to master proprties in Zope! I am trying to develop a super user-friendly design which couples Zope with Flash5+ to do smart-client and smasrt-server scripting. Part of my plan is to use local Zopes [running transparently I hope] on users client machines linked to a public 24/7 remote web Zopesite. I believe that Flash5 offers some very interesting parallels to Zope __if__ designed and programmed right. Some major advantages I see of Flash over HTML are: - advanced screen layout and interactivity control - advanced user feedback capabilities - better use of client machine processing resources - reduced network traffic and server demand - powerful object-oriented 'container' metaphor [matches Zope quite well] - Flash's timeline + keyframe paradigm allows natural sequencing of user interface elements This last point is crucial imho. Web[HTML] has no implicit notion of sequencing, yet this is exactly what people experience and what site/applications designers often need to implement. I have been using frame and container properties in Flash Actionscript, and it makes for nice clean portable code. My design goal calls for maximum symmetry between client and server [Flash to Zope adn vice versa]. I am using Flash5 as rapid prototyping tool to directly model user interface and I hope very soon to directly model Zopesite also. My hope is to develop Zope-side code simultanously, and allow both systems to pass data and object structures to the other. Simple tests have alrady shown this to be quite workable. Flash does not have an equivalent of "AUTHENTICATED_USER.has_role(['Manager','some_other_admin_role'])> but your post provokes me to implement something like it. Setting properties in Flash is easy and does allow for logical design including making it easy to nest components independently to build up logic. For example depending user action or program flow I can set various flags in Actionscript: if (admin) if (login) if (colorchanged) if (returning) etc.. Permutations of these are quite easy to plot and functions can be built and tested rapidly without disturbing previous work. Likewise setting values in dictionaries for such attributes offers even more subtle ways to maintain state, keep history etc. After I get the basics of Zope properties down, I want to explore more fully this use of dictionaries as type='Tokens'. I tested soem of this with Gerard Mulot's help last summer. He used folder properties to hold data templates structured as dictionaries. The Database we used was Berkeley Storage, which Gerrard wrote a small Zope product wrapper for. As proof of concept, this worked very nicely, allowing us to minimize Zope calls, and it was fast and efficient cross platform database solution. We were working with Flash4 at the time, which was painful and very restrictive because its limited scripting. Flash5 is major advance for programmers, including XML tools. Among the main criticisms of Flash are lack of any well considered usability and code bloat. It is my contention that highly object-oriented Zope-inspired Flash can remedy both of these problems. To take a trivial but crucial example, many dotcomera-developed flash sites do not have the euqivalent of the Browser's 'BACK' button, or offer status message feedback on mouse rollover of what effect a mouseclick will have or goto. In fact Flash5 is brilliantly equipped to do much more than HTML and Web browsers in this regard, and without a lot of server calls or thick javascript. But it does call for an elegant an inspired paradigm new[re]think. To me Zope is part of this newthink. So I want now to learn to do same in Zope. Hopefully my experiences over coming months will improve my coding on both systems and evolve in highly re-usable modular code. Zope alrady makes me approach Flash in novel ways and I hope Flash allows me to be likewise craetive with Zope. At the very least it is interesting and fun! Your comments most welcome. - Jason ___________________________________________________________ Jason CUNLIFFE = NOMADICS['Interactive Art and Technology']
participants (2)
-
Jason Cunliffe -
Phil Harris