[Zope3-Users] Re: worldcookery Christmas Dinner

2005-10-03 Thread Joel Moxley
I apologize for my replying to self, but I was re-reading Stephan's
and then Philipp's book and realized that one portion of my email has
been answered.  Thus, I'm hoping to clarify my question to the list.

Looking at the messageboard content class, I then did a grep on
Philipp's worldcookery examples directory for btree -- sure enough,
the last chapter before Expert level (14, aptly titled Containers),
addresses RecipeFolders (what I had called RecipeContainers).  It must
have been late when I read that chapter because it did not reach to
proper location in my memory :)

Bottom line, I will re-summarize my original question below with this
information in mind:

* RecipeFolder Views.  In a RecipeFolder page template file, how would
you view both parameters on the parent RecipeFolder as well as
specific child Recipes within the container?

* RecipeFolder Controllers.  How would you access an external python
method for compiling statistics on this container and then update the
view?

Clearly, I'm still lacking some basic understanding in these areas,
and I'm going to continue to push forward, and any guidance or
suggestions of example code would be hugely appreciated.  Again,
thanks for your understanding and help.

Best,
Joel

On 10/2/05, Joel Moxley [EMAIL PROTECTED] wrote:
 Hello yall,

   I'm a python guy who wanted to provide an interface for some 
 baseball-related code to the web, so I naturally turned to Zope.  I fumbled 
 around for a while, but Philipp and Stephan's books got me on the right track.

   Philipp's book has been wonderful for learning Zope from scratch, I've read 
 and re-read the first fourteen chapters (ie, everything but Expert stuff).  
 In doing so, I created my own worldcookery-esque content management system.

   However, there are two significant holes in my knowledge that I want to 
 address: 1) integrating buttons to run controller style scripts to tabulate 
 and display statistics about multiple content objects, and 2) displaying 
 nested content objects.

   For those of yall familiar with the worldcookery scheme, I wanted to do 
 something along the lines of a Christmas Dinner.  This would be a  new 
 content object, RecipeContainer, which contains the turkey recipe, the 
 sweet potato recipe, and the cornbread recipe content objects.  You would 
 have a page template for displaying all the recipe content objects on a 
 single page (preferably with minimize/maximize capabilities), an add/remove 
 dialog for existing recipes in the database, and a button for accessing an 
 external python script to compile and display statistics (like what would be 
 the total time to prepare all dishes).

  In other words, a user might decide to also cook cornbread for Christmas 
 dinner.  Thus, the user would add a recipe for cornbread in the regular Add 
 Recipe view.  The user would then go to the ChristmasDinner RecipeContainer 
 content object where they would select the cornbread recipe object from a 
 dialog containing a list of possible recipes.  The user would then press a 
 button to access an external python script which would calculate the expected 
 time that cooking Christmas dinner with cornbread in addition to the turkey 
 and sweet potato.  This expected time (and other statistics) would be 
 displayed on the ChristmasDinner view along with the recipes.

  Right now, I'm looking at Stephan's book and the messageboard scheme to get 
 ideas (ie, message content objects inside the messageboard), but I wanted to 
 get input from yall about the best ways to do this.  I realize this will 
 probably seem obvious, but I am a true beginner in the scheme of things, and 
 I'm hoping that my experience might help extend the worldcookery teaching 
 paradigm.


   Many thanks, and go Zope 3!

  Joel
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Re: worldcookery Christmas Dinner

2005-10-03 Thread Duncan McGreggor


On Oct 3, 2005, at 12:32 AM, Joel Moxley wrote:


* RecipeFolder Views.  In a RecipeFolder page template file, how would
you view both parameters on the parent RecipeFolder as well as
specific child Recipes within the container?

* RecipeFolder Controllers.  How would you access an external python
method for compiling statistics on this container and then update the
view?


I think for both of these, what you're looking for is the catalog. It 
might mean writing your own custom index, based on your needs... (but 
you should be able to at least prototype it with just the field and 
text indices that are a part of the catalog by default). If, with your 
content objects, you are storing or annotating the data you want to 
analyze, you'll just need to add indices in your site catalog for those 
schema fields/attributes.


For your first bullet item above... hmm, maybe catalog + checking for 
children? Never done anything directly with the children of a 
particular container before.


For the second one, I think just catalog should do the trick.

What I'd do is

1) create a class in browser (e.g., myproject.browser.stats.Stats) 
where in I write the catalog queries. I put mine in browser because I 
mentally associate my queries with displaying data with page templates. 
Arguably, they might be better the next level up, since data queries 
really should be agnostic as to the final medium (http, webdav, ftp, 
etc.). For every type of processed stats I would want, I'd write a 
method in the Stats class. As Alen and I discussed in a recent thread, 
perhaps something like


from zope.app.publisher.browser import BrowserView
from zope.app.catalog.interfaces import ICatalog
from zope.app import zapi

class Stats(BrowserView):
def getParentAndChildStats(self):
catalog = zapi.getUtility(ICatalog)
results = catalog.searchResults(index_name_for_field=[some, 
list, of, criteria])

# process your results
# do child checks? efficiency issues? I'm sure there's a better 
way...


My queries are typically associated with a particular content type (as 
it sounds like yours will be... particularly RecipeFolder). So then I'd


2) add something like this to the browser/configure.zcml file:

browser:page
for=myproject.containers.IRecipeFolder
name=index.html
template=recipefolderview.pt
class=.stats.Stats
permission=zope.Public /

Then,

3) use view/method_name in your page templates to access the the 
Stats methods you wrote. Data presentation gets messy in HTML/ZPT, so I 
typically separate that out into a macro so I can keep my *view.pt 
files clean. You'd have something like this in your recipefolderview.pt 
(or macro that recipefolderview.pt calls):


ul
tal:stats repeat=stat view/getParentAndChildStats
  !-- display stat and/or its attributes /--
/tal:stats

Hope that helps...

d

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] Override a browser class

2005-10-03 Thread Johan Carlsson


Hi all,
I want to replace the pasteable in 
zope.app.container.browser.contents.Contents

for all content types.

I've created a sub class to Contents which override
the pasteable but I'm not sure how to configure it
to override the default class (if possible)?

Best Regards,
Johan


PS. The reason I want to change pasteable is that it
raises an exception if the paste action is unknown.
I'm implementing a clone action as an extra variation
of copy and it works in my classes but if I point
to a stock object (with anything I want to clone in
the clipbook) I get an error due to the raise.

My override returns False if the paste action is unknown.

Any core developer that has any opinion on this?
Can it be changed in the core or is there a specific
reason for the raise?


Regards,
Johan

--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] Advanced usage of Z3 schemas...

2005-10-03 Thread Andreas Jung


Hi,

I am currently thinking about for a new version of PloneCollectorNG based 
on Zope 3. The currently implementation uses per-instances schemas 
(acquired from a parent object managing the schema). How would you do that 
in Zope 3?
Another question: in Zope 3 we have FieldProperties that automatically 
handle setting and getting values. This implementation stores the values as 
instance attributes. What would be the recommended way to store attributes 
in a RDBMS instead inside the ZODB? By introducing a new RDBMSFieldProperty 
that handles the set/get methods in the same way as the FieldProperty 
implementation?


Thanks,
Andreas

pgpw3NWc08ZET.pgp
Description: PGP signature
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] pau and zope.manager

2005-10-03 Thread Jim Washington
I want to use pau, with session (cookie) based authentication.  No basic 
authentication.


The problem is, when the pau is activated, the zope.manager defined in 
zcml seems to be no longer accessible, effectively locking me out of the 
zmi.


What I think is happening is the pau appends a prefix to the principal 
name, so that the principal, instead of being zope.manager, becomes 
prefixzope.manager, which has no permissions anywhere.


I think my choices are the following.

1.  make pau always look (last) in principalRegistry and return a 
non-prefixed principal if found and validated
2.  have my authentication plugin look in principalRegistry and assign 
the same roles for the principals found in principalRegistry, but with 
the pau prefix.  This would happen when the plugin is created or on demand.
3.  provide methods for my authentication plugin to generate an 
emergency user for one of its valid principals


Or did I miss something in the documentation that gets around this?

-Jim Washington
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] querying the catalog

2005-10-03 Thread Jim Fulton

Duncan McGreggor wrote:


On Sep 30, 2005, at 11:31 PM, Alen Stanisic wrote:


Not sure if it will help but whenever I had to look up a catalog I would
only do zapi.getUtility(ICatalog) and I noticed you are also providing a
name and context.



Yeah, with or without the extra parameters, it always only returns the 
root catalog instance.



I also believe that if you are looking up a catalog by name as you seem
to be doing it is not enought for the catalog object to be named
accumac_catalog but you also have to register it as the name ('Register
As' field in New Utility Registration) during catalog creation.  I
usually leave 'Register As' blank as I only ever needed to get catalog
by ICatalog interface only - zapi.getUtility(ICatalog)



When I created it, I set register as to accumac_catalog. Based on 
the experience you shared, I deleted my catalog and did not give it a 
name upon creation. zapi.getUtility(ICatalog) now works, as it gets the 
sub-site's catalog in the accumac/++etc++site/default directory.


Very strange. If I understood this more, or if there was expert-aided 
interest, I would troubleshoot this. It may not be a bug, but there at 
least seem to be issues of an anti-intuitive nature here...


Alen, thanks again for your assistance in this matter :-)


I suspect there was a problem of some sort with your original registration.
We normally use named local catalogs and haven't had a problem.

BTW, you should not pass the context argument to the component-lookup
functions *unless* you want to find a component in a different site.

Jim

--
Jim Fulton   mailto:[EMAIL PROTECTED]   Python Powered!
CTO  (540) 361-1714http://www.python.org
Zope Corporation http://www.zope.com   http://www.zope.org
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] stuffing the request object in zope3

2005-10-03 Thread Tim Middleton

I've done a few Zope 2 projects, and am trying to wrap my head around Zope 3
now. The style I evolved for putting together Zope 2 applications may not
have been very orthodox. 

Basically I found that I disliked (and mistrusted, maybe because at the time
I didn't understand the security wrappers very well) calling any methods
from within ZPTs. Thus my pattern eventually became that all pages were
themselves methods of my objects, which would do whatever setup is
necessary, stuff the self.REQUEST object with whatever is required, and the
method would then return the ZTP object. Something like this...

  _page = PageTemplateFile('www/somePage.htm', globals())

  def page(self):
do whatever is necessary to set up REQUEST then call template
self.REQUEST.set('some', 'info')
self.REQUEST.set('data', self.inaccessableFromWeb())
return self._page()

It's a fairly straight forward approach really (probably betraying deep and
ugly CGI roots). It may not be the most efficient, but it makes it very
explicit for my templates where info is coming from: it *always* all comes
from the method which returns the template before calling the template.

So, now, Zope 3... somewhat different, to say the least! There is the, if
not 100% enforced, certainly more strongly segregated, view portion of an
app. And perhaps it's time to change. Perhaps I have no choice. Perhaps I
have a choice, but it would be just easier (and better) in the long run to
figure out the more zope3ish ways of doing things.

In the maze of interfaces and frighteningly magical zcml glue, I can't even
figure out how to get ahold of the request object outside of a ZPT. (-:
I've looked through bugtracker and a few other bits of code that have some
slight use of 'self.request', but still can not figure it out (at least
everything i have tried has not worked in my tries at it. And many of the
samples I found seem to get the request via different methods, which is a
bit confusing. Do I implement, adapt, subclass, call... what? I'm sure it
would be possible for me, eventually, figure out how to perpetuate my
pattern in a zope 3 context... (though the paradigm shift has been pretty
brutally painful so far, and I've barely yet begun) and it would make
porting a whole lot faster... (assuming also i can figure out how to get
traversal working, or restructure my code so I don't need it...)

So still, I wonder... how can I get that request object I love so to abuse?

[Sort of a long post, for the simple anti-climatic question. Sorry! But if
anyone read this far and has any thoughts, or pointers to sample code
and/or obscure documentation, pertaining to any of the above ramble, I'd
love to hear about it...]



___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] stuffing the request object in zope3

2005-10-03 Thread Gary Poster


On Oct 3, 2005, at 11:19 AM, Tim Middleton wrote:



I've done a few Zope 2 projects, and am trying to wrap my head  
around Zope 3
now. The style I evolved for putting together Zope 2 applications  
may not

have been very orthodox.

Basically I found that I disliked (and mistrusted, maybe because at  
the time
I didn't understand the security wrappers very well) calling any  
methods
from within ZPTs. Thus my pattern eventually became that all pages  
were

themselves methods of my objects, which would do whatever setup is
necessary, stuff the self.REQUEST object with whatever is required,  
and the

method would then return the ZTP object. Something like this...

  _page = PageTemplateFile('www/somePage.htm', globals())

  def page(self):
do whatever is necessary to set up REQUEST then call  
template

self.REQUEST.set('some', 'info')
self.REQUEST.set('data', self.inaccessableFromWeb())
return self._page()

It's a fairly straight forward approach really (probably betraying  
deep and
ugly CGI roots). It may not be the most efficient, but it makes it  
very
explicit for my templates where info is coming from: it *always*  
all comes
from the method which returns the template before calling the  
template.


So, now, Zope 3... somewhat different, to say the least! There is  
the, if
not 100% enforced, certainly more strongly segregated, view  
portion of an

app. And perhaps it's time to change.


If you write big apps (I'll let you define big :-) then probably  
so.  For small apps I still find it to be a good choice, but YMMV.



Perhaps I have no choice. Perhaps I
have a choice, but it would be just easier (and better) in the long  
run to

figure out the more zope3ish ways of doing things.


You do have a choice.  The recipes are all going to guide you along  
the One True Way of using views, though.


In the maze of interfaces and frighteningly magical zcml glue, I  
can't even
figure out how to get ahold of the request object outside of a ZPT.  
(-:


FWIW, we're trying to reduce the frightening and magical aspect  
of the glue. :-)  That said, glue still has its place, and I think  
zcml is actually working out pretty well overall.


I've looked through bugtracker and a few other bits of code that  
have some
slight use of 'self.request', but still can not figure it out (at  
least
everything i have tried has not worked in my tries at it. And many  
of the
samples I found seem to get the request via different methods,  
which is a
bit confusing. Do I implement, adapt, subclass, call... what? I'm  
sure it

would be possible for me, eventually, figure out how to perpetuate my
pattern in a zope 3 context... (though the paradigm shift has been  
pretty

brutally painful so far, and I've barely yet begun) and it would make
porting a whole lot faster... (assuming also i can figure out how  
to get

traversal working, or restructure my code so I don't need it...)


So, I understand how you came to your Zope 2 approach.  The nice  
thing, from your perspective then, is that you could say that Zope 3  
agrees with you: it's a lot simpler if you just have some Python to  
work with, and you use a template for the stuff that makes sense,  
right off your Python view class.


Yes, you ought to divide up your view code and your model code, but  
your view class can now have multiple templates attached to it; your  
templates can call methods on your view class.  It's nice.


Benji York is working on a quick start for Zope 3.  He wants to do a  
lot more on it, but it already starts from a nice place, I think, and  
it might give some examples of what I'm trying to show.


http://www.benjiyork.com/quick_start.txt

So still, I wonder... how can I get that request object I love so  
to abuse?


Do I answer your question, to show it can be done, and that we want  
to support practical development, rather than stubbornly insist on  
what we believe to be the right way of doing things?  I guess so.   
But, as the comment says...


8
# DON'T DO THIS unless you have a real reason to!!

import zope.security.management
from zope.publisher.interfaces import IRequest

def getRequest():
i = zope.security.management.getInteraction() # raises  
NoInteraction

for p in i.participations:
if IRequest.providedBy(p):
return p
raise RuntimeError('No IRequest in interaction')
8

I hope the view classes work out for you.  :-)

Gary
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] User data / metadata

2005-10-03 Thread James Allwyn
 You could do it directly. In fact, you could even have 'members' as
 regular content objects in the site and write an authentication
 utility which looks up those members and builds a security Principal
 object off of that. I believe this is what Schoolbell does.

This sounds interesting - are you suggesting building a Principal
object 'on the fly' when someone logs in (and throwing it away when
they log out again)? What would be the advantages of having them as a
regular content object, rather than working with Principals?

Thanks,
James
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Advanced usage of Z3 schemas...

2005-10-03 Thread Stephan Richter
On Monday 03 October 2005 10:22, Gary Poster wrote:
  I am currently thinking about for a new version of PloneCollectorNG  
  based on Zope 3. The currently implementation uses per-instances  
  schemas (acquired from a parent object managing the schema). How  
  would you do that in Zope 3?

 It sounds like you want persistent schemas.  Although there is some  
 code in Zope 3 going in that direction, to my knowledge it does not  
 work right now.

Right, we all need to bug Jim to fix that! :-)

Regards,
Stephan
-- 
Stephan Richter
CBU Physics  Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] object has no attribute '_SampleContainer__data'

2005-10-03 Thread Gary Poster


On Oct 3, 2005, at 9:29 PM, Leticia Larrosa wrote:
AttributeError: 'Service' object has no attribute  
'_SampleContainer__data'


Hi Leticia.  It looks like your container overrides __init__ and,  
rather than deferring to the SampleContainer.__init__, you are trying  
to set the __data value in your own class.  If you are not familiar  
with the magic pseudo-private '__*' behavior in Python, maybe you  
should read up on it.  The immediate fix, though, is to change your  
current SampleContainer __init__.


If now it looks something like this:

class SampleContainer(BTreeContainer):
# ...
def __init__(self):
# ...
self.__data = self._newContainerData()
# ...

then delete than instantiation and instead do this:

class SampleContainer(BTreeContainer):
# ...
def __init__(self):
# ...
super(SampleContainer, self).__init__() # this replaces the  
self.__data line

# ...

That should hopefully clear it up.

If you need to change what is made as the data object, override  
_newContainerData (although that's where the btree mix in does its  
work!).


Gary
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


RE: [Zope3-Users] object has no attribute '_SampleContainer__data'

2005-10-03 Thread Leticia Larrosa

Tom and Gary, thanks so much. Tom, was exactly the same problem !!!.
Gary, I will review my knowledge about python following your advice ;)

Regards,
Leticia

-Original Message-
From: Tom Dossis [mailto:[EMAIL PROTECTED] 
Sent: Monday, October 03, 2005 8:09 PM
To: Leticia Larrosa
Cc: zope3-users@zope.org
Subject: Re: [Zope3-Users] object has no attribute '_SampleContainer__data'

Leticia Larrosa wrote:
 When a try to see the view of list of Service of one of the
ServiceList
 I get the following error:
 
 
 'Service' object has no attribute '_SampleContainer__data'
 
 
 I'm newcomer in zope 3 and any idea will be appreciated.
 Thanks in advance.
 
 Leticia Larrosa

In addition to the previous reply; I experienced the above problem when..

I implementend a simple subclass of SampleContainer, then changed to 
subclass BTreeContainer, but forget to delete existing instances created 
in Zope.  A tell tale sign is you can no longer delete the broken 
instance(s)

-Tom








___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] Re: stuffing the request object in zope3

2005-10-03 Thread Tim Middleton
Gary Poster wrote:
 FWIW, we're trying to reduce the frightening and magical aspect
 of the glue. :-)  That said, glue still has its place, and I think
 zcml is actually working out pretty well overall.

I take no small amount of comfort in strange frequency of finding Shane
Hathaway's Zope 3 Frustration blog entry showing up in my various google
search results ... and the term frustration isn't even in my search
terms, honest! (-; I say to myself... if Shane is frustrated... how can I
*not* be at least a little confused? Anyhow, more specifically, his mention
of not being able to find any debugging tools for ZCML I think is fairly a
strong indictment. But that's another topic. 

 http://www.benjiyork.com/quick_start.txt

Ah thanks for this pointer. Can't have too many beginner tutorials. I've
read a few already and considered maybe writing one from a slightly
different perspective than those i've yet seen, if I survive... 

I don't think my problem is so much the code, or even the alien ZCML api
actually... mine seems to me is a conceptual problem (if i may say... and I
believe all of my correspondants on this thread have also have been not shy
at pointing out in their own ways). I understand the theory of the Zope 3
approach... small adaptors rather than big classes/inheritance. I
understand also that this is an approach designed to scale for large
projects, while it may be a bit cumbersome for small things. 

I think i'd have a lot less problem with Zope 3 actually I was coming at it
as a beginner. I'd just accept what I read without reading more into it and
trying to refocus it through the prism of my existing code bases and
experiences. So I wonder if my difficulties aren't in large part due to all
the past coding and structural baggage, so to speak. I just can't seem
(yet) to make the clean divisions the way Zope 3 wants, or see how Zope 3
fits those parts together, despite all of the simple examples I've so far
been exposed to. All of the tutorials and books I've seen so far hit things
from a code/test driven perspective... maybe if i read enough of them
though one day (as was the case with me *finally* for Zope 2) the whole
puzzle will suddenly start to click together. 

I find it interesting though that while the object oriented paradigm seemed
pretty immediately intuitive and practical when I learnt it so many years
ago, for some reason the adaptor paradigm doesn't sink in... but rolls
around in my brain like so many beads of mercury. Again, I understand the
concepts, but the practical usage just doesn't seem to click. (This despite
having read the Shaver/Plug example in the Zope documentation many times
(and the other metaphors in various other documents and docstrings), which
makes perfect sense in the abstract, and perfect sense in the little
examples... yet... when i go to try to use it somehow it slips utility of
it slips away from me...) Perhaps it's just me. But, perhaps not... 

But I ramble again. 

  if IRequest.providedBy(p):

Ha! Something's got to provide an IRequest in there eh. That's wicked. (-; I
fear Andreas Jung may be planning on hunting you down and killing you for
publishing this to the list. Or even worse... he may suggest you doing
something to yourself that involves... PHP. 

Thanks, though.



___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] 3.1 final zeo tests error message

2005-10-03 Thread Alen Stanisic
Hi,

first of all thanks and congratulations to zope3 dev team on the release
of 3.1.

I gave it a try today and when running 'make check' got this message:

The following test left new threads behind:
checkAbortNotCommitting (ZEO.tests.testZEO.MappingStorageTests)
New thread(s): [ConnectThread(Connect([(2, ('localhost', 29172))]),
started daemon)]

At the end of the test run this wasn't reported as a failure:

Ran 6990 tests in 280.231s
OK

I re-ran tests twice after that and did not get the message, all tests
passed ok. 

FWIW I am running python 2.3.5, Debian based Ubuntu Linux 5.04.

Thanks
Alen

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users