[Zope3-Users] Utilities

2006-06-05 Thread David Johnson
What is the best to find the nearest utility without using a name? 

zapi.getUtility() seems to require a name (though the documentation
implies otherwise). zapi.getAllRegisiteredUtilitiesFor() works but it
seems to me if you have lots of utilities in other contexts, it would
query those as well, and thereby be slow in a large application.

I come across this problem frequently and haven't figured out the best
way to deal with it.



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


Re: [Zope3-Users] Utilities

2006-06-05 Thread Florian Lindner
Am Montag, 5. Juni 2006 08:14 schrieb David Johnson:
 What is the best to find the nearest utility without using a name?

 zapi.getUtility() seems to require a name (though the documentation
 implies otherwise). zapi.getAllRegisiteredUtilitiesFor() works but it
 seems to me if you have lots of utilities in other contexts, it would
 query those as well, and thereby be slow in a large application.

getUtility does not require a name.

Example:

from zope.app.zapi import getUtility
from zope.app.homefolder.interfaces import IHomeFolderManager
hfm = getUtility(IHomeFolderManager)

Regards,

Florian



 I come across this problem frequently and haven't figured out the best
 way to deal with it.
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Utilities

2006-06-05 Thread Albertas Agejevas
On Mon, Jun 05, 2006 at 01:14:58AM -0500, David Johnson wrote:
 What is the best to find the nearest utility without using a name? 
 
 zapi.getUtility() seems to require a name (though the documentation
 implies otherwise).

The default name is ''.  If you're asking for z.c.getUtility(ISomething),
you'll get that -- the nearest utility with a given interface and name
''.  These used to be called services three years ago.

 zapi.getAllRegisiteredUtilitiesFor() works but it
 seems to me if you have lots of utilities in other contexts, it would
 query those as well, and thereby be slow in a large application.
 
 I come across this problem frequently and haven't figured out the best
 way to deal with it.

If you want to get all utilities with a given interface, use
z.c.getUtilitiesFor(ISomething).  You'll get the nearest utility with
each given name.

Albertas


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


[Zope3-Users] testing using placefulSetUp, zcml and events

2006-06-05 Thread Achim Domma

Hi,

I have a content object I want to set up in a IObjectCreatedEvent event 
handler. I want to use the interactive interpreter to play with this, 
but it looks like my configure.zcml is not parsed and executed if I use 
placefulSetUp.


How do I have to setup my environment to test zcml configured events 
from command line? Basically I want to write something like


some_setup_method()
root[ws]=Workspace() # should trigger and handle IObjectCreatedEvent
for key in root[ws).keys():
print key

to check if the object is setup correctly.

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


Re: [Zope3-Users] Found a (perhaps obvious) page template speedup

2006-06-05 Thread Chris Withers

Stephan Richter wrote:


The point is that I am not interesting in supporting the ZMI at all. I have no 
use for users or developers to ever use the ZMI. In fact, basing my skin on 
the ZMI is bad because it provides all those URLs I (a) do not have control 
over -- thus being a security risk, and (b) are not needed and make the 
system slower.


This is stupid.

One of the big wins for Zope 3 was that you were supposed to be able to 
re-use UI code without having to write it all from scratch.


The ZMI has a lot of widgets that people should want to re-use 
(generically: tree controls, file widgets, directory listings, etc, 
specifically: forms and configuration for the generic parts of zope)


It sounds like you're advocating writing every bit of UI from scratch, 
as you have to in Zope 2 due to the hard-coded nature of the ZMI, but 
I'm hoping I'm mistaken...


Am I?

Chris

--
Simplistix - Content Management, Zope  Python Consulting
   - http://www.simplistix.co.uk
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Utilities

2006-06-05 Thread David Johnson

 getUtility does not require a name.

I've tried getUtility() without a name it never returns an interface and
returns component lookup error.  I've tried in many different instances,
and I've ended up reverting as a work around to
getAllRegisteredUtilitiesFor(), which works just fine.  Once I add the
name it works great. What am I missing? Is there some other requirement?
My code looks the same as what you've listed.  The documentation implies
that it does not need a name.  Is this a possible Zope 3 version issue
or bug? 









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


Re: [Zope3-Users] Found a (perhaps obvious) page template speedup

2006-06-05 Thread Marco Mariani

Chris Withers wrote:

The ZMI has a lot of widgets that people should want to re-use 
(generically: tree controls, file widgets, directory listings, etc, 
specifically: forms and configuration for the generic parts of zope)


It sounds like you're advocating writing every bit of UI from scratch, 
as you have to in Zope 2 due to the hard-coded nature of the ZMI, but 
I'm hoping I'm mistaken...


Am I?


Widgets are in zope.app.form.browser, and those can be use independently 
of ZMI

Forms are in zope.formlib (or zope.app.form), again independent of ZMI

Want menus? Again, they are *used* by ZMI but you can define your own 
with the same machinery..


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


Re: [Zope3-Users] Utilities

2006-06-05 Thread David Johnson
Thanks! That's it exactly!  I was misunderstanding the concept of a
utility with the name ''.  



On Mon, 2006-06-05 at 17:34 +0300, Albertas Agejevas wrote:
 On Mon, Jun 05, 2006 at 09:22:13AM -0500, David Johnson wrote:
  
   getUtility does not require a name.
  
  I've tried getUtility() without a name it never returns an interface and
  returns component lookup error.
 
 Because you haven't registered a single utility with the given
 interface and name ''!
 
  I've tried in many different instances,
  and I've ended up reverting as a work around to
  getAllRegisteredUtilitiesFor(), which works just fine.
 
 getAllRegisteredUtilitiesFor returns even the utilities that are
 overriden by closer utilities with the same name and interface.
 
  Once I add the name it works great. What am I missing? Is there
  some other requirement?  My code looks the same as what you've
  listed.
 
 I suspect you expect getUtility(ISomething) to return a utility with
 *any* name of that interface (that's what
 get(AllRegistered)UtilitiesFor() does).  But getUtility(ISomething)
 returns just the utilities with the name you've passed ('' by default).
 
 I think I already explained that in my previous email.
 
 Albertas
 

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


Re: [Zope3-Users] Time Zones/Internationalization

2006-06-05 Thread David Pratt
Hi David. pytz is a standard python package included in zope that can 
help you manage time zone issues. There are methods to represent time 
that is properly offset according to a large database of global 
timezones. This will help you present the view of time you wish to your 
application's users. Refer to the documentation in the package to give 
you an idea of what is possible.


Regards,
David

David Johnson wrote:

How do you deal with time zones in your applications, in regards to
dates and times entered by users of the application. 


For example consider a content object that represents a store, and
includes the store hours.  A store owner may enter their opening ours as
0800 in their timezone.  Do you store this as 0800? How does locale fit
in both in terms of store owners and store customers (who may be in
different time zones)?




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


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


Re: [Zope3-Users] Custom index implementation

2006-06-05 Thread Tom Dossis
Achim Domma wrote:
 Hi,
 
 I try to implement a custom index to be inserted into a catalog. I look
 at the code and it seems to me, that I only have to derive my interface
 from ICatalogIndex. I have defined my interface like this:
 
 class ITestIndex(zope.app.catalog.interfaces.ICatalogIndex):
 pass
 
 Then I have implemented a class which implements this interface and have
 it registerd like this:
 
 class class=.Workspace.TestIndex
 require
 permission=zope.ManageServices
 interface=.interfaces.ITestIndex
  zope.index.interfaces.IStatistics
 set_schema=.interfaces.ITestIndex
 /
 /class
 
 If I restart zope and go to my catalog, I still can only add FieldIndex
 and TestIndex. What else do I have to do, to implement a custom index?

You need to specify an addMenuItem directive and associated view in
your package browser zcml to enable you to add your index objects via
the ZMI.  Look at zope/app/catalog/browser/configure.zcml as a starting
point, e.g.

addform
name=AddTestIndex
label=Add a test index
schema=..interfaces.ITestIndex
permission=zope.ManageServices
content_factory=..WorkSpace.TestIndex
arguments=field_name
keyword_arguments=interface field_callable
/

 addMenuItem
title=Test Index
description=My Test Index
class=..Workspace.TestIndex
permission=zope.ManageServices
view=AddTestIndex
   /
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Time Zones/Internationalization

2006-06-05 Thread David Johnson
That's great! That does seem to figure that out.  The secrets of Zope.

On Mon, 2006-06-05 at 18:53 -0300, David Pratt wrote:
 Hi David. pytz is a standard python package included in zope that can 
 help you manage time zone issues. There are methods to represent time 
 that is properly offset according to a large database of global 
 timezones. This will help you present the view of time you wish to your 
 application's users. Refer to the documentation in the package to give 
 you an idea of what is possible.
 
 Regards,
 David
 
 David Johnson wrote:
  How do you deal with time zones in your applications, in regards to
  dates and times entered by users of the application. 
  
  For example consider a content object that represents a store, and
  includes the store hours.  A store owner may enter their opening ours as
  0800 in their timezone.  Do you store this as 0800? How does locale fit
  in both in terms of store owners and store customers (who may be in
  different time zones)?
  
  
  
  
  ___
  Zope3-users mailing list
  Zope3-users@zope.org
  http://mail.zope.org/mailman/listinfo/zope3-users
  
 

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


[Zope3-Users] IEndRequestEvent question

2006-06-05 Thread Thierry FLORAC





 Hi,

I'd like to ask several questions about IEndRequestEvent, like :
 - when is this event actually fired ?
 - what can be done exactly after this event is fired (still query components, update database...) ?
 - if possible, are modifications done after this event integrated into the main transaction ?

My goal is to use request annotations to reference several objects that should be treated after the main request process is done, and then to subscribe to this event to fire these final modifications (so that, for example, IObjectModifiedEvent is not fired too many times). Is it the good approach ?

Thanks for any help,
Thierry


-- 
This message has been scanned for viruses and
dangerous content by
MailScanner, and is
believed to be clean.

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