Re: [Repoze-dev] Folder event subscriber not called

2010-05-03 Thread Chris McDonough
On Mon, 2010-05-03 at 23:33 -0400, Chris McDonough wrote:
> On Mon, 2010-05-03 at 12:55 -0700, Sam Brauer wrote:
> > Hi there!  I'm a long-time Zope 2 user finally trying to do a demo project 
> > with Repoze.bfg.  
> > First
> > off, congratulations to everyone developing Repoze!  You've really
> > cherry picked the best concepts from Zope and packaged them in a lean
> > modern framework.
> > 
> > My demo project was going along very well
> > until I tried to wire up some subscribers for repoze.folder events; my
> > subscriber callbacks don't seem to be firing.  After trying a few days
> > to figure out the problem, I think I need to ask for help.  I've tried
> > to come up with a small example to demonstrate the problem, and I'd be
> > very grateful for any help.  I feel like I'm missing something that
> > should be obvious.
> > 
> 
> Hi Sam,
> 
> The events sent by repoze.folder are "object events", which are events
> dispatched based on *two* interfaces (the context interface and the
> event interface).  Here's an example from KARL:
> 
>  for="repoze.lemonade.interfaces.IContent
>repoze.folder.interfaces.IObjectAddedEvent"
>   handler=".subscribers.index_content"/>
> 
> Hopefully this helps, 

Sorry, I should have also provided the "subscribers.index_content"
function so you could see its argument list:

def index_content(obj, event):
""" Index content (an IObjectAddedEvent subscriber) """
catalog = find_catalog(obj)
if catalog is not None:
for node in postorder(obj):
if is_content(obj):
path = model_path(node)
docid = getattr(node, 'docid', None)
if docid is None:
docid = node.docid = catalog.document_map.add(path)
else:
catalog.document_map.add(path, docid)
catalog.index_doc(docid, node)


___
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev


Re: [Repoze-dev] Folder event subscriber not called

2010-05-03 Thread Chris McDonough
On Mon, 2010-05-03 at 12:55 -0700, Sam Brauer wrote:
> Hi there!  I'm a long-time Zope 2 user finally trying to do a demo project 
> with Repoze.bfg.  
> First
> off, congratulations to everyone developing Repoze!  You've really
> cherry picked the best concepts from Zope and packaged them in a lean
> modern framework.
> 
> My demo project was going along very well
> until I tried to wire up some subscribers for repoze.folder events; my
> subscriber callbacks don't seem to be firing.  After trying a few days
> to figure out the problem, I think I need to ask for help.  I've tried
> to come up with a small example to demonstrate the problem, and I'd be
> very grateful for any help.  I feel like I'm missing something that
> should be obvious.
> 

Hi Sam,

The events sent by repoze.folder are "object events", which are events
dispatched based on *two* interfaces (the context interface and the
event interface).  Here's an example from KARL:

  

Hopefully this helps, 

- C


___
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev


Re: [Repoze-dev] BFG and semi-structured databases (a rant)

2010-05-03 Thread Chris McDonough
Hi Luciano, 

On Sun, 2010-05-02 at 18:03 -0300, Luciano Ramalho wrote:
> BACKGROUND
> 
> I was attracted to Zope in 1998 because it freed us from the
> clumsiness of the first normal form.
> 
> Many in the Zope community can also boast membership of the NoSQL "old-guard".
> 
> The ZODB is great, but it, and all other OODBs, have a serious
> problem: the data is tied too closely to the application.

I appreciate the explanation of your thoughts.

I don't know of any bindings specifically for BFG to "semistructured"
databases.  Mostly this is because the BFG community is still pretty
small.  I'd like to see folks build some reusable parts.  I have heard
rumblings of various people using CouchDB and BigTable and Mongo with
BFG, but I don't think anything reusable has come of it yet.

- C


___
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev


[Repoze-dev] Folder event subscriber not called

2010-05-03 Thread Sam Brauer
Hi there!  I'm a long-time Zope 2 user finally trying to do a demo project with 
Repoze.bfg.  
First
off, congratulations to everyone developing Repoze!  You've really
cherry picked the best concepts from Zope and packaged them in a lean
modern framework.

My demo project was going along very well
until I tried to wire up some subscribers for repoze.folder events; my
subscriber callbacks don't seem to be firing.  After trying a few days
to figure out the problem, I think I need to ask for help.  I've tried
to come up with a small example to demonstrate the problem, and I'd be
very grateful for any help.  I feel like I'm missing something that
should be obvious.

I'm setting up a bfg_zodb project following
the instructions in the repoze tutorials.  (For what it's worth, I'm
using Python 2.5.4 on Ubuntu.)

$  virtualenv --no-site-packages folder_event_test
$  cd folder_event_test/
$  bin/easy_install -i http://dist.repoze.org/bfg/current/simple repoze.bfg
$  bin/easy_install -i http://dist.repoze.org/bfgsite/simple repoze.tm 
repoze.zodbconn repoze.who nose coverage
$  bin/easy_install repoze.catalog repoze.folder
$  bin/paster create -t bfg_zodb foo
$  cd foo
$  ../bin/python setup.py develop

My models.py contains a trivial subclass of Persistent and an application root 
that
subclasses Folder.  It also has a function subscriber_test() that
simply prints any events it receives.
--
import repoze.folder
import persistent

class Content(persistent.Persistent):
def __init__(self):
persistent.Persistent.__init__(self)

class Site(repoze.folder.Folder):
def __init__(self):
repoze.folder.Folder.__init__(self)

def appmaker(zodb_root):
if not 'app_root' in zodb_root:
app_root = Site()
zodb_root['app_root'] = app_root
import transaction
transaction.commit()
return zodb_root['app_root']

def subscriber_test(event):
print "subscriber_test event=%s" % repr(event)
--

My configure.zcml registers subscriber_test() for all events.
--
http://namespaces.repoze.org/bfg";>
  
  

--

Then I run bfgshell and add an instance of my Content class to the root object, 
which subclasses Folder.
--
$ ../bin/paster  --plugin=repoze.bfgbfgshell foo.inizodb
subscriber_test event=
Python 2.5.4 (r254:67916, Jan 20 2010, 21:45:54) 
[GCC 4.3.3] on linux2
Type "help" for more information. "root" is the BFG app root object.
>>> root

>>> import foo.models
>>> root['test'] = foo.models.Content()
>>> root['test'].__name__
u'test'
>>> root['test'].__parent__

>>> 
--
Note that subscriber_test() was called with a WSGIApplicationCreatedEvent as 
bfg started up.
When
I added a Content instance to the Site object, I expected to see my
subscriber_test() function called once with an ObjectWillBeAddedEvent
and again with an ObjectAddedEvent, but neither appeared to happen. 
Nothing was printed to stdout anyway.

Please let me know if you can help me out.
Thanks so much,
Sam



  
___
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev


[Repoze-dev] [issue144] Small typo on Unit and Integration Testing chapter

2010-05-03 Thread Nuno Teixeira

New submission from Nuno Teixeira :

Index: docs/narr/unittesting.rst

===
--- docs/narr/unittesting.rst   (revision 9323)
+++ docs/narr/unittesting.rst   (working copy)
@@ -115,7 +115,7 @@
 of a :term:`Configurator`, including its ``begin`` and ``end``
 methods.
 
-If you also want to make :func:`repoze.bfg.get_current_registry`
+If you also want to make :func:`repoze.bfg.get_current_request`
 return something other than ``None`` during the course of a single
 test, you can pass a :term:`request` object into the

--
messages: 403
nosy: nteixeira
priority: bug
status: unread
title: Small typo on Unit and Integration Testing chapter
topic: bfg book

__
Repoze Bugs 

__
___
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev