Re: [Zope3-dev] Why z.a.appsetup.bootstrap function do not return the actual object

2006-03-27 Thread Florian Lindner
Hello,
I've changed the code how you described. All tests pass, but some code used in 
startup of Zope and some tests generate deprecation warnings.
Would you like to review the code before I check in? I can try to clean up the 
code and the tests causing the deprecation warnings the next days and checkin 
later.

Regards,

Florian

Am Montag, 20. März 2006 14:27 schrieb Stephan Richter:
 On Wednesday 08 March 2006 08:57, Florian Lindner wrote:
  Hello,
  I'm currently playning with the functions from
  zope.app.appsetup.bootstrap and I'm wondering why the functions that
  create objects
  (addConfigureUtility, addUtility, configureUtility, ensureObject,
  ensureUtility) do return the name of the object added (or None) and not
  the object itself. What is the reason for that?
 
  IMO in most cases you add a Utility you want to change some attributes of
  it afterwards. In order to do that you need the object instance. To get
  it from the name you have to perform a getUtility call. If the functions
  above would return the object you could omit the getUtility.
 
  What do you think about that?

 This is a relic from the early days, when we still had context wrappers. I
 am +1 for the change, but backward-compatibility has to be provided. And
 since the return value changes, this has to be done in two steps:

 1. Create a new option argument to the functions saying ``asObject=False``,
 and only if set to True the object will return. Then deprecate the string
 return value by generating a warning message.

 2. After two releases, remove deprecated string value return and set
 ``asObject=True`` by default. Also deprecate the asObject argument again.

 Regards,
 Stephan
___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com



Re: [Zope3-dev] Why z.a.appsetup.bootstrap function do not return the actual object

2006-03-22 Thread Florian Lindner
Am Montag, 20. März 2006 14:27 schrieb Stephan Richter:
 On Wednesday 08 March 2006 08:57, Florian Lindner wrote:
  Hello,
  I'm currently playning with the functions from
  zope.app.appsetup.bootstrap and I'm wondering why the functions that
  create objects
  (addConfigureUtility, addUtility, configureUtility, ensureObject,
  ensureUtility) do return the name of the object added (or None) and not
  the object itself. What is the reason for that?
 
  IMO in most cases you add a Utility you want to change some attributes of
  it afterwards. In order to do that you need the object instance. To get
  it from the name you have to perform a getUtility call. If the functions
  above would return the object you could omit the getUtility.
 
  What do you think about that?

 This is a relic from the early days, when we still had context wrappers. I
 am +1 for the change, but backward-compatibility has to be provided. And
 since the return value changes, this has to be done in two steps:

 1. Create a new option argument to the functions saying ``asObject=False``,
 and only if set to True the object will return.

Done.

 Then deprecate the string 
 return value by generating a warning message.

Mmmhh... how can I deprecate a function argument conditionally?

def ensureObject(root_folder, object_name, object_type, object_factory, 
asObject=False):
Check that there's a basic object in the site
manager. If not, add one.

Return the name abdded, if we added an object, otherwise None.

if not asObject:
asObject = deprecation.deprecated(asObject, Using asObject=False is 
deprecated)


But that does not do anything


 2. After two releases, remove deprecated string value return and set
 ``asObject=True`` by default. Also deprecate the asObject argument again.

Hope I'll remember that.

Thanks,

Florian
___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com



Re: [Zope3-dev] Why z.a.appsetup.bootstrap function do not return the actual object

2006-03-20 Thread Stephan Richter
On Wednesday 08 March 2006 08:57, Florian Lindner wrote:
 Hello,
 I'm currently playning with the functions from zope.app.appsetup.bootstrap
 and I'm wondering why the functions that create objects
 (addConfigureUtility, addUtility, configureUtility, ensureObject,
 ensureUtility) do return the name of the object added (or None) and not the
 object itself. What is the reason for that?

 IMO in most cases you add a Utility you want to change some attributes of
 it afterwards. In order to do that you need the object instance. To get it
 from the name you have to perform a getUtility call. If the functions above
 would return the object you could omit the getUtility.

 What do you think about that?

This is a relic from the early days, when we still had context wrappers. I am 
+1 for the change, but backward-compatibility has to be provided. And since 
the return value changes, this has to be done in two steps:

1. Create a new option argument to the functions saying ``asObject=False``, 
and only if set to True the object will return. Then deprecate the string 
return value by generating a warning message.

2. After two releases, remove deprecated string value return and set 
``asObject=True`` by default. Also deprecate the asObject argument again.

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



[Zope3-dev] Why z.a.appsetup.bootstrap function do not return the actual object

2006-03-08 Thread Florian Lindner
Hello,
I'm currently playning with the functions from zope.app.appsetup.bootstrap and 
I'm wondering why the functions that create objects (addConfigureUtility, 
addUtility, configureUtility, ensureObject, ensureUtility) do return the name 
of the object added (or None) and not the object itself. What is the reason 
for that?

IMO in most cases you add a Utility you want to change some attributes of it 
afterwards. In order to do that you need the object instance. To get it from 
the name you have to perform a getUtility call. If the functions above would 
return the object you could omit the getUtility.

What do you think about that?

Florian

___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com