Re: Zope View Tutorial

Joe Bigler <[email protected]> Sat, 13 Jul 2013 15:41:17 +0000
Newsgroups gmane.comp.web.zope.plone.documentation
Message-ID <[email protected]>
Mike,

I got this to work.  I see the data in the console.  That was a big help.  I think it is starting to come together.  I am going to work with this some more today and see what I can come up with.  I appreciate you taking the time to write the code and provide the explanations. 

Joe Bigler

-----Original Message-----
From: Joe Bigler 
Sent: Saturday, July 13, 2013 10:08 AM
To: 'Mike Cullerton'
Cc: [email protected]
Subject: RE: [Plone-docs] Zope View Tutorial

Mike,

Thanks for taking the time to write the code.  I will try this out this morning and reply back.  

Joe Bigler

-----Original Message-----
From: Mike Cullerton [mailto:plone-Jyq08SUepVWvlIlDamLRIwC/[email protected]]
Sent: Saturday, July 13, 2013 9:41 AM
To: Joe Bigler
Cc: [email protected]
Subject: Re: [Plone-docs] Zope View Tutorial

Hey Joe,

You don't ask a specific question. Did you try something and get an error?

I suggest starting your view without restricting the views/interfaces, and worrying about that when you have all the other logic working.

Here's what it takes to get the example you referenced at http://developer.plone.org/members/member_basics.html#list-users-within-all-groups running.

First you tell Plone about your entry point. In the browser directory, in configure.zcml, add

    <browser:page
        for="*"
        name="test_user_view"
        class=".common.TestUserView"
        permission="zope2.View"
        />

This says when someone goes to the url test_user_view, run the code in the class common.TestUserView.

To create the class, create a file called common.py in the browser directory, and in common.py, add

from Products.Five import BrowserView
from Products.CMFCore.utils import getToolByName import logging
logger=logging.getLogger("MyLogger: ")

class TestUserView:

    def __call__(self):
        """Testing views"""
        logger.info("TestUserView: __call__: ")
        acl_users = getToolByName(self.context, 'acl_users')
        groups_tool = getToolByName(self.context, 'portal_groups')
        groups = acl_users.source_groups.getGroupIds()
        for group_id in groups:
            group = groups_tool.getGroupById(group_id)
            if group is None:
                continue
            logger.info("TestUserView: __call__: group: %s" % str(group))
            members = group.getGroupMembers()
            member_emails = [m.getProperty('email') for m in members]
            logger.info("TestUserView: __call__: member_emails: %s" % str(member_emails))


Notice that I added some logging to their example. 

You can access that code at http:blahblahblah/yourplonesite/test_user_view

Hope this helps,
Mike

On Jul 12, 2013, at 2:07 PM, Joe Bigler <[email protected]> wrote:

> Mike,
> 
> Here is what I am trying to do.  I need to access information from the Plone database.   I am trying to implement the examples at http://developer.plone.org/members/member_basics.html#list-users-within-all-groups because we are primarily interested in user information at this time.   Here are some of the things I have been tasked to do:
> 
> - email blast to all editors in the site
> - generate a report with names and email addresses for all editors
> - generate a list of all groups with their editors listed.
> 
> I have tried to build a view for this, but not sure how to proceed.  I 
> worked through the developer.plone.org "Hello World" tutorial at 
> https://developer.plone.org/reference_manuals/active/helloworld/index.
> html
> 
> I installed the product on my test site and got it to work for the tutorial.  I have also looked at the Professional Plone 4 Development book, and posted the question in the Nabble forum.  I understand the basic idea of a view,   but determining the interface, the class, and the python code to get the examples on http://developer.plone.org/members/member_basics.html#list-users-within-all-groups to work is something I just don't see yet.  I understand Zope browser views are an important part on Plone 4 and I need to understand how to use them, but I am frankly stuck.  I don't want to have to ask someone to build every one of these I need.  I need to get the principals down so I can build them on my own.  Any suggestions?
> 
> I have been working with Plone since 2006.   We made the jump from Plone 2.5.3 to Plone 4.1 last year.  I only know Python from what little I have used it in Plone.  I am working on that.  I don't have any experience with an object oriented programming language.  I have been programming web pages since 1998, mostly with ColdFusion and database applications since the 1990's with Visual Basic and SQL Server.  I am the web administrator for the College of Education at Penn State University.  You can see our site at http://www.ed.psu.edu.  
> 
> I am hoping that if I can understand views to add a tutorial to the http://developer.plone.org/members/member_basics.html#list-users-within-all-groups page.  I know of several administrators that would like to be able to do what I am doing, but have a similar background and are stuck as well.
> 
> Any thoughts or suggestions would be appreciated.
> 
> Joseph E. Bigler
> Web Administrator
> Carrara Education Technology Center
> [email protected]
> 814-865-1560
> 233B Chambers Building
> University Park, PA 16802
> 
> 
> 
> -----Original Message-----
> From: Mike Cullerton [mailto:plone-Jyq08SUepVWvlIlDamLRIwC/[email protected]]
> Sent: Thursday, July 11, 2013 10:43 AM
> To: Joe Bigler
> Cc: [email protected]
> Subject: Re: [Plone-docs] Zope View Tutorial
> 
> Hey Joe,
> 
> I don't know which tutorial you are referring to, but the Hello World tutorial has a secion of views.
> 
> https://developer.plone.org/reference_manuals/active/helloworld/index.
> html
> 
> If that's not what you are interested in, you can find all the 
> tutorials listed at https://developer.plone.org/
> 
> Mike
> 
> On Jul 11, 2013, at 8:38 AM, Joe Bigler <[email protected]> wrote:
> 
>> I am looking for the zope view tutorial referenced in the Plone 
>> Developer Manual Documentation.  It is listed on page 77, section 1.2 
>> Programming Plone in the latest version I have, April 03, 2013.
>> 
>> When I click on the link, it redirects me to 
>> http://developer.plone.org/moved_content.html.  This tells me the 
>> documentation has been moved to another location, but it doesn't list 
>> where it is.  I tried checking the links on that page, but I could not find it.
>> The link it originally went to is
>> http://plone.org/documentation/tutorial/borg/zope-3-views.
>> 
>> I have tried multiple searches, but cannot find it.  Can anyone help 
>> with this or point me to a good zope view tutorial?
>> 
>> 
>> 
>> --
>> View this message in context: 
>> http://plone.293351.n2.nabble.com/Zope-View-Tutorial-tp7566584.html
>> Sent from the Documentation Team mailing list archive at Nabble.com.
>> 
>> ---------------------------------------------------------------------
>> -
>> -------- See everything from the browser to the database with 
>> AppDynamics Get end-to-end visibility with application monitoring 
>> from AppDynamics Isolate bottlenecks and diagnose root cause in seconds.
>> Start your free trial of AppDynamics Pro today!
>> http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.
>> c lktrk _______________________________________________
>> Plone-docs mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/plone-docs
> 


------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk