Re: [Zope] Instance within Instance

2000-11-30 Thread Tim Cook

Daryl Stultz wrote:
 
 Tim Cook wrote:
 
  Daryl,
 
  Import the DarylProduct.zexp into your Products folder.
  The DarylExample.zexp can go anywhere in you Zope tree.
 
 As luck would have it, the file did not import into Products (File
 /usr/local/Zope/lib/python/OFS/CopySupport.py, line 406, in
 _verifyObjectPaste)
 
 It DID import into the root folder (I did this purely by accident!) I

Well, that shouldn't have happened. At least in previous versions
of Zope you could not import a Product into anything but the
Products folder.

 was then able to recreate the called-for classes and IT WORKED!! I
 haven't figured out HOW yet but I will. Thanks a lot for the help, and

Maybe this worked out better since you had to actually recreate
them g.
You're welcome.

 let me know if you need any fancy Python methods...

I will. s 

-- Tim Cook, President --
Free Practice Management,Inc. | http://FreePM.com
Office: (901) 884-4126
Censorship: The reaction of the ignorant to freedom.

___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )




Re: [Zope] Instance within Instance

2000-11-30 Thread Tim Cook

Daryl Stultz wrote:

 It DID import into the root folder (I did this purely by accident!) I
 was then able to recreate the called-for classes and IT WORKED!! I
 haven't figured out HOW yet but I will. Thanks a lot for the help, and

Maybe we COULD say the how is, "because it creates one object(
the folder) in the first call. Then the second object (the
document) in a seperate call. Since HTTP is stateless it requires
a seperate call for each activity."
The folder doesn't exist until after the first response. So you
can't GET it's context in the same call you create it in.

Make more sense?

-- Tim Cook, President --
Free Practice Management,Inc. | http://FreePM.com
Office: (901) 884-4126
Censorship: The reaction of the ignorant to freedom.

___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )




Re: [Zope] Instance within Instance

2000-11-29 Thread Daryl Stultz

Tim Cook wrote:
 
 Daryl,
 
 Import the DarylProduct.zexp into your Products folder.
 The DarylExample.zexp can go anywhere in you Zope tree.

As luck would have it, the file did not import into Products (File
/usr/local/Zope/lib/python/OFS/CopySupport.py, line 406, in
_verifyObjectPaste)

It DID import into the root folder (I did this purely by accident!) I
was then able to recreate the called-for classes and IT WORKED!! I
haven't figured out HOW yet but I will. Thanks a lot for the help, and
let me know if you need any fancy Python methods...

Cheers.
-- 
"Where is the fancy bread, in the heart or in the head?"

Daryl Stultz - python, zope, blender, robots, really bad harmonica
playing...
[EMAIL PROTECTED]  
RedHat Linux 6.1 - Dual Pentium Pro


___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )




Re: [Zope] Instance within Instance

2000-11-29 Thread Daryl Stultz

Tim Cook wrote:

Well, Tim, I'm sorry to say I am back where I started :-( 
I took your (working) example and modified it. I want to be able to add
the MyClass1/MyClass2 combo from the management interface (the add
product thing). 
I combined all the code into MyClass1_add. If I use this:

   dtml-with "manage_addProduct['DarylExample']"
 dtml-call expr="MyClass2_add(_.None, _, NoRedir=1)"
   /dtml-with

I get a permission denied error. If I remove the with wrapper, I get the
MyClass2 instance, but ALONGSIDE rather than within the MyClass1
instance. This is pretty much the same thing I got before you sent me
the product so I guess I wasn't that far off :-)

I fooled around with permissions as much as I could and couldn't make it
work. Any ideas there?

Thanks again.

-- 
"Where is the fancy bread, in the heart or in the head?"

Daryl Stultz - python, zope, blender, robots, really bad harmonica
playing...
[EMAIL PROTECTED]  
RedHat Linux 6.1 - Dual Pentium Pro

___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )




Re: [Zope] Instance within Instance

2000-11-28 Thread Tim Cook

Daryl Stultz wrote:
 
 Tim Cook wrote:
  The problem here is that even though you set REQUEST, it is a
  string. You need to be in the context of the parent _object_. You
  should try  dtml-with "_.getitem(parent_id)".
 
 What's happening now is that my class2 is getting created at the same
 level as class1. What I want is class2 to be INSIDE class1. So I don't
 want the parent context, I want the class1 context.
 dtml-with "_.getitem(myClass1_id)" gets me the class2 instance at the
 same level...
 
 How can I get a new context of the newly created class1 instance?

This dtml-with should be in a DTML Method, not in your
constructor.  As I recall you are trying to construct the class2
from inside the class1 constructor.  There may be a way to get
that to work, I don't know. But if you use a DTML Method like
this:

--- add_myclass ---
This method contains a form to gather all of your required
property values.
It should POST to add_myclassProcessor.

---


--- add_myclassProcessor --
...
dtml-call expr="REQUEST.set('id', 'MyClass1ID')"
...

dtml-with "manage_addProduct['MyCoolProduct']"
  dtml-call expr="Class1_add(_.None, _, NoRedir=1)"
/dtml-with MyCoolProduct

dtml-with "_.getitem(MyClass1ID)"
...
dtml-call expr="REQUEST.set('id', 'MyClass2ID')"
...

dtml-with "manage_addProduct['MyCoolProduct']"
  dtml-call expr="Class2_add(_.None, _, NoRedir=1)"
/dtml-with MyCoolProduct

/dtml-with MyClass1ID 

---

I guarantee that you will end up with a folder MyClass1ID that
contains MyClass2ID.

This may not be the most spectacular Zope code. There are alot of
things that Zope can do that I don't know yet. But this works and
it's readable when indented properly.

Maybe, someone else can telly you a REALLY COOL way to get it
done from inside the Class1 constructor. But if you want it to
work now. Try this way. s


HTH,

-- Tim Cook, President --
Free Practice Management,Inc. | http://FreePM.com
Office: (901) 884-4126
Censorship: The reaction of the ignorant to freedom.

___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )




Re: [Zope] Instance within Instance

2000-11-28 Thread Dieter Maurer

Daryl Stultz writes:
   "REQUEST.set" to influence where instance is created 

"createInObjectManager" is uninterested in "REQUEST".
It creates the new object (usually, exception when its object
has a special "Destination" attribute) in the parent (aq_parent)
of its object.

Your "dtml-with" should place your "class1" instance correctly
in the "parent position".

I expect, that your "class1" does not inherit form "ObjectManager"
and therefore does not have a "_setObject".

In this case, "createInObjectManager" goes up another step
(another "aq_parent") and reaches the folder containing
the "class1" instance.
It has a "_setObject", the "class2" instance is placed there, too.

  Anymore info (or pointers to better docs) would be great. Thanks.
You can learn about "aq_parent" in the acquisition documentation.

Search "zope.org" for it (acquisition).


Dieter

___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )




Re: [Zope] Instance within Instance

2000-11-28 Thread Dieter Maurer

Daryl Stultz writes:
  Tim Cook wrote:
   The problem here is that even though you set REQUEST, it is a
   string. You need to be in the context of the parent _object_. You
   should try  dtml-with "_.getitem(parent_id)".
  
  Sorry, I thought of more...
  It's my understanding that dtml-with simply pushes a namespace onto the
  stack. What relationship does this have with the context that a new
  ZClass instance is created in?
"class2" is looked up in this namespace.
The top element is asked first for "class2".
"class2" is found (by acquisition) from your "class1" Z instance
(called "i1"). Thus, what is actually called is

(class2 __of__ i1).createInObjectManager()

"createInObjectManager" looks in "(class2 __of__ i1).aq_parent"
(this is "i1") for "_setObject".
Apparently, it does not find it there.
Then it looks at "i1.aq_parent" (this is the folder, "i1" is contained
in). There, it has success and creates the object.


Dieter



___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )




Re: [Zope] Instance within Instance

2000-11-28 Thread Daryl Stultz

Tim Cook wrote:

 I guarantee that you will end up with a folder MyClass1ID that
 contains MyClass2ID.

You've been very helpful, here, Tim, but I simply can't get this to
work. I'm wondering if you might be able to create such a product for me
and send it to me: One product with two classes, creating one class from
the manager creates the first class with the second inside it.

Maybe I can write some Python for you or something in exchange :-)
Thanks.

-- 
"Where is the fancy bread, in the heart or in the head?"

Daryl Stultz - python, blender, robots, really bad harmonica playing...
[EMAIL PROTECTED]  
RedHat Linux 6.1 - Dual Pentium Pro

___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )




Re: [Zope] Instance within Instance

2000-11-28 Thread Tim Cook

Daryl Stultz wrote:
 
 Tim Cook wrote:
 
  I guarantee that you will end up with a folder MyClass1ID that
  contains MyClass2ID.
 
 You've been very helpful, here, Tim, but I simply can't get this to
 work. I'm wondering if you might be able to create such a product for me
 and send it to me: One product with two classes, creating one class from
 the manager creates the first class with the second inside it.

I probably didn't give all of the instructions in a step by step
manner. I think I gathered this info from different HOWTOs. Here
are the changes that I make to each ZClass.

In the class definition add your propertysheet(s). I only ever
use one / class. I think this is a hold over from years of
RDBMS's. I figure if you need more than one propertysheet then
you need a seperate class. s

In the constructor, copy the call to manage_editProperties to a
new one outside of the comment block. Replace the .Basic. with
the name of your property sheet you created.

So:
...
 dtml-call
"propertysheets.Basic.manage_editProperties(REQUEST)"

  /dtml-comment
/dtml-with

Becomes:
...

   dtml-call
"propertysheets.Basic.manage_editProperties(REQUEST)"

  /dtml-comment
  dtml-call
"propertysheets.myclass1_info.manage_editProperties(REQUEST)"

/dtml-with


Then at the bottom of the constructor (I think I got this from
the Job Board HowTo).

Replace everything below the /dtml-comment with:

dtml-if NoRedir
dtml-else

dtml-if DestinationURL

 dtml-call "RESPONSE.redirect(
   DestinationURL+'/manage_workspace')"

dtml-else

dtml-call "RESPONSE.redirect(
   URL2+'/manage_workspace')"
/dtml-if
/dtml-if
/body/html

When we call the constructor we will pass 'NoRedir', this keeps
it from returning to the management interface. 

After setting up REQUEST with our desired values for the
propertysheet we call the first constructor like this:

dtml-call expr="REQUEST.set('id', 'MyClass1ID')"

dtml-with "manage_addProduct['MyCoolProduct']"
  dtml-call expr="MyClass1_add(_.None, _, NoRedir=1)"
/dtml-with

Next we get the newly constructed MyClass1, and setup to call the
MyClass2 constructor:

dtml-with "_.getitem('id')"

  dtml-call expr="REQUEST.set('id', 'MyClass2ID')"

  dtml-with "manage_addProduct['MyCoolProduct']"
dtml-call expr="MyClass2_add(_.None, _, NoRedir=1)"
  /dtml-with

/dtml-with

---
I am sending you a Product and an example folder via seperate
email.

 Maybe I can write some Python for you or something in exchange :-)

Just signup on the FreePM project at SourceForge  mailing list
and I'll be sure to ask real soon now. g

Good Luck,
-- Tim Cook, President --
Free Practice Management,Inc. | http://FreePM.com
Office: (901) 884-4126
Censorship: The reaction of the ignorant to freedom.

___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )




Re: [Zope] Instance within Instance

2000-11-28 Thread Tim Cook

Tim Cook wrote:
 
 Next we get the newly constructed MyClass1, and setup to call the
 MyClass2 constructor:
 
 dtml-with "_.getitem('id')"
 
   dtml-call expr="REQUEST.set('id', 'MyClass2ID')"
 
   dtml-with "manage_addProduct['MyCoolProduct']"
 dtml-call expr="MyClass2_add(_.None, _, NoRedir=1)"
   /dtml-with
 
 /dtml-with
 

There were some details I still left out here. This call to the
second constructor is in another DTML Method. The REQUEST values
are passed through using hidden form variables from the first
DTML Method.
Also in the second DTML MEthod you must be sure that you are
inside the parent folder context first.

dtml-with "PARENTS[0]"
 dtml-with "_.getitem('id')"
 
   dtml-call expr="REQUEST.set('id', 'MyClass2ID')"
 
   dtml-with "manage_addProduct['MyCoolProduct']"
 dtml-call expr="MyClass2_add(_.None, _, NoRedir=1)"
   /dtml-with
 
 /dtml-with
/dtml-with

Then you do a call to index_html or some appropriate Method so
the user isn't left with a blank display.

This will make sense to Daryl in the examples I sent. If anyone
else wants a better explaination maybe I'll do a formal HOW-TO
???


-- Tim Cook, President --
Free Practice Management,Inc. | http://FreePM.com
Office: (901) 884-4126
Censorship: The reaction of the ignorant to freedom.

___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )




Re: [Zope] Instance within Instance

2000-11-27 Thread Dieter Maurer

Daryl Stultz writes:
  I have a product folder called "TestClass" with 2 ZClasses: class1 and
  class2.
  The following is an exerpt from the class1 constructor:
  
  dtml-with "class1.createInObjectManager(REQUEST['id'], REQUEST)"
dtml-call "REQUEST.set('id', 'myClass2')"
dtml-call "class2_add(_.None, _, NoRedir=1)"
  /dtml-with
  
  I want class2 to be created INSIDE of the class 1 instance. Instead,
  class2 (always with an id of "myClass2") is created at the same level as
  the class1 instance. How do I change the namespace to get the class2
  instance inside class1?
You should look at the source of your "class2_add",
especially the constructor that creates the object.

I expect, that you use "class2.createInObjectManager"
to create your "class2" instance.
"C.createInObjectManager" usually uses "C.aq_parent" to
determine the object manager where the new C instance
should be created (unless it has a "Destination" attribute).
This should be your "class1" instance "instance1", more
precisely, an acquisition wrapper for it.

There are two possibilities:

 1. for reasons, I do not understand, "class2.aq_parent"
is not "instance1"

 2. it is "instance1", but "instance1" does not have
a "_setObject" method, i.e. "class1" is not derived
from ObjectManager.


Dieter

___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )




Re: [Zope] Instance within Instance

2000-11-27 Thread Daryl Stultz

 You should look at the source of your "class2_add",
 especially the constructor that creates the object.
 
 I expect, that you use "class2.createInObjectManager"
 to create your "class2" instance.
 "C.createInObjectManager" usually uses "C.aq_parent" to
 determine the object manager where the new C instance
 should be created (unless it has a "Destination" attribute).
 This should be your "class1" instance "instance1", more
 precisely, an acquisition wrapper for it.

Wowsers! This is all a little over my head...

I've scoured the docs and I can't find anything on aq_parent. (And
createInObjectManager is weak...) Wouldn't the object manager (to add
object to) be determined by the URL? I've done
REQUEST.set('URL','...myClass1/') but that doesn't help. Isn't there
SOMETHING in the REQUEST object that tells it where things should get
created?

Anymore info (or pointers to better docs) would be great. Thanks.

Daryl Stultz - python, blender, robots, really bad harmonica playing...
[EMAIL PROTECTED]  
RedHat Linux 6.1 - Dual Pentium Pro

___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )




Re: [Zope] Instance within Instance

2000-11-26 Thread Tim Cook

Daryl Stultz wrote:
 
 I want class2 to be created INSIDE of the class 1 instance. Instead,
 class2 (always with an id of "myClass2") is created at the same level as
 the class1 instance. How do I change the namespace to get the class2
 instance inside class1?

NOT TESTED, but simialr to something I do:

dtml-call expr="class1.createInObjectManager(REQUEST['id'],
REQUEST)"
dtml-with "_.getitem(id)"
  dtml-call "REQUEST.set('id', 'myClass2')"
  dtml-call "class2_add(_.None, _, NoRedir=1)"
/dtml-with

HTH,
-- Tim Cook, President --
Free Practice Management,Inc. | http://FreePM.com
Office: (901) 884-4126
Censorship: The reaction of the ignorant to freedom.

___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )




Re: [Zope] Instance within Instance

2000-11-26 Thread Daryl Stultz

Tim Cook wrote:

 NOT TESTED, but simialr to something I do:
 
 dtml-call expr="class1.createInObjectManager(REQUEST['id'],
 REQUEST)"
 dtml-with "_.getitem(id)"
   dtml-call "REQUEST.set('id', 'myClass2')"
   dtml-call "class2_add(_.None, _, NoRedir=1)"
 /dtml-with

Hmmm, doesn't seem to be working (also results in class1 and class2
being at same level). I'll take a look at some other examples.

Thanks for the help (and quick replies).



___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )