[Fwd: Re: [Zope-dev] Problems adding many objects]

2005-09-26 Thread Morten W. Petersen
Oops, one for the list as well.

 Original Message 
Subject: Re: [Zope-dev] Problems adding many objects
Date: Mon, 26 Sep 2005 13:34:50 +0200
From: Morten W. Petersen <[EMAIL PROTECTED]>
To: Chris McDonough <[EMAIL PROTECTED]>
References: <[EMAIL PROTECTED]>
<[EMAIL PROTECTED]>
<[EMAIL PROTECTED]>
<[EMAIL PROTECTED]>

> It doesn't say "returning issue, None"?  My guess is that the if 
> request is not none branch is called and it goes that way.  But  there's
> no way to know for sure without running it.

It says 'returning issue '

> This is a good place to use the Python debugger...  as the first line 
> of this method, insert "import pdb; pdb.set_trace()", then start up 
> Zope in the foreground (runzope or zopectl fg), then cause the method 
> to be invoked through a browser.
> 
> On the console you will see a pdb prompt.  You can step through the 
> code by using "n".  To print the value of a variable type "p 
> ", to step in to a function call press "s".  When  you're
> finished, press "c" to continue or "q" to quit.  This will be  the
> fastest way to see what's happening in this method.

Yep, I'll have a go at this later.  Thanks for describing the debug
process.  :)

-Morten


-- 
Regards,

Morten

Tlf:  +47 45 44 00 69
Blog: http://www.blogologue.com
begin:vcard
fn:Morten Petersen
n:Petersen;Morten
org:Nidelven IT
adr:;;Postboks 923;Trondheim;;7409;Norway
email;internet:[EMAIL PROTECTED]
title:Project Manager
tel;work:+47 45 44 00 69
tel;cell:+47 45 44 00 69
x-mozilla-html:FALSE
url:http://www.nidelven-it.no
version:2.1
end:vcard

___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] Problems adding many objects

2005-09-26 Thread Chris McDonough


On Sep 26, 2005, at 7:21 AM, Morten W. Petersen wrote:


Chris,

the implementation looks like this

def manage_add_issue(self, id=None, title='', contents='',
state='', type='', referrer='', format=None,
REQUEST=None):
"""Add an Issue."""
if id is None:
id = self.get_unique_id()
issue_ = issue(id, title, contents, state, type,
   creator=self.get_user().get_id(),
   owner=self.get_user().get_id(),
   format=format or
self.get_user_preferences().issue_format)
self._setObject(id, issue_)
self.order.append(issue_.id)
self.order = self.order
issue_ = self[id]
issue_.version = self.get_issue_dealer().version
try:
self.index_object()
except AttributeError:
pass
if referrer and REQUEST is not None:
REQUEST.RESPONSE.redirect(referrer)
print 'redirect'
else:
if REQUEST is not None:
if self.inCMF():
print 'admin url'
return self.get_admin_url()
else:
print 'manage_main'
return self.manage_main(self, REQUEST)
else:
print 'returning issue', issue_
return issue_

and before returning none, it says 'returning issue' on stdout.


It doesn't say "returning issue, None"?  My guess is that the if  
request is not none branch is called and it goes that way.  But  
there's no way to know for sure without running it.


This is a good place to use the Python debugger...  as the first line  
of this method, insert "import pdb; pdb.set_trace()", then start up  
Zope in the foreground (runzope or zopectl fg), then cause the method  
to be invoked through a browser.


On the console you will see a pdb prompt.  You can step through the  
code by using "n".  To print the value of a variable type "p  
", to step in to a function call press "s".  When  
you're finished, press "c" to continue or "q" to quit.  This will be  
the fastest way to see what's happening in this method.


- C




-Morten

Chris McDonough wrote:


Hi Morten,

You'd probably need to show us the implementation of whatever
"manage_add_issue" is.

- C


On Sep 25, 2005, at 10:09 AM, Morten W. Petersen wrote:



Hi,

I've created a script that imports XML into the ZODB, using  
regular  TTW
methods - and all is fine, except for when I import large files,  
with

many objects.

After about 288 objects, the import fails when the method that  
adds an
object in the ZODB returns None, instead of the object it added.   
From
what I can tell, the added object is not None before it is   
returned, but

the name object, set via the expression

  object = self.manage_add_issue(...)

is None.  So it looks like somewhere between 'return issue_' in
manage_add_issue and the expression above, the object is lost.

Any ideas what could be happening here?  I've managed to work   
around it

for now, but it is interesting nonetheless.

Regards,

Morten


___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists -
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )









--
Regards,

Morten

Tlf:  +47 45 44 00 69
Blog: http://www.blogologue.com





___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] Problems adding many objects

2005-09-26 Thread Morten W. Petersen
Chris,

the implementation looks like this

def manage_add_issue(self, id=None, title='', contents='',
state='', type='', referrer='', format=None,
REQUEST=None):
"""Add an Issue."""
if id is None:
id = self.get_unique_id()
issue_ = issue(id, title, contents, state, type,
   creator=self.get_user().get_id(),
   owner=self.get_user().get_id(),
   format=format or
self.get_user_preferences().issue_format)
self._setObject(id, issue_)
self.order.append(issue_.id)
self.order = self.order
issue_ = self[id]
issue_.version = self.get_issue_dealer().version
try:
self.index_object()
except AttributeError:
pass
if referrer and REQUEST is not None:
REQUEST.RESPONSE.redirect(referrer)
print 'redirect'
else:
if REQUEST is not None:
if self.inCMF():
print 'admin url'
return self.get_admin_url()
else:
print 'manage_main'
return self.manage_main(self, REQUEST)
else:
print 'returning issue', issue_
return issue_

and before returning none, it says 'returning issue' on stdout.

-Morten

Chris McDonough wrote:
> Hi Morten,
> 
> You'd probably need to show us the implementation of whatever 
> "manage_add_issue" is.
> 
> - C
> 
> 
> On Sep 25, 2005, at 10:09 AM, Morten W. Petersen wrote:
> 
>> Hi,
>>
>> I've created a script that imports XML into the ZODB, using regular  TTW
>> methods - and all is fine, except for when I import large files, with
>> many objects.
>>
>> After about 288 objects, the import fails when the method that adds an
>> object in the ZODB returns None, instead of the object it added.  From
>> what I can tell, the added object is not None before it is  returned, but
>> the name object, set via the expression
>>
>>   object = self.manage_add_issue(...)
>>
>> is None.  So it looks like somewhere between 'return issue_' in
>> manage_add_issue and the expression above, the object is lost.
>>
>> Any ideas what could be happening here?  I've managed to work  around it
>> for now, but it is interesting nonetheless.
>>
>> Regards,
>>
>> Morten
>>
>> 
>> ___
>> Zope-Dev maillist  -  Zope-Dev@zope.org
>> http://mail.zope.org/mailman/listinfo/zope-dev
>> **  No cross posts or HTML encoding!  **
>> (Related lists -
>>  http://mail.zope.org/mailman/listinfo/zope-announce
>>  http://mail.zope.org/mailman/listinfo/zope )
>>
> 
> 


-- 
Regards,

Morten

Tlf:  +47 45 44 00 69
Blog: http://www.blogologue.com
begin:vcard
fn:Morten Petersen
n:Petersen;Morten
org:Nidelven IT
adr:;;Postboks 923;Trondheim;;7409;Norway
email;internet:[EMAIL PROTECTED]
title:Project Manager
tel;work:+47 45 44 00 69
tel;cell:+47 45 44 00 69
x-mozilla-html:FALSE
url:http://www.nidelven-it.no
version:2.1
end:vcard

___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] Problems adding many objects

2005-09-26 Thread Chris McDonough

Hi Morten,

You'd probably need to show us the implementation of whatever  
"manage_add_issue" is.


- C


On Sep 25, 2005, at 10:09 AM, Morten W. Petersen wrote:


Hi,

I've created a script that imports XML into the ZODB, using regular  
TTW

methods - and all is fine, except for when I import large files, with
many objects.

After about 288 objects, the import fails when the method that adds an
object in the ZODB returns None, instead of the object it added.  From
what I can tell, the added object is not None before it is  
returned, but

the name object, set via the expression

  object = self.manage_add_issue(...)

is None.  So it looks like somewhere between 'return issue_' in
manage_add_issue and the expression above, the object is lost.

Any ideas what could be happening here?  I've managed to work  
around it

for now, but it is interesting nonetheless.

Regards,

Morten


___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists -
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )



___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope )


[Zope-dev] Problems adding many objects

2005-09-25 Thread Morten W. Petersen
Hi,

I've created a script that imports XML into the ZODB, using regular TTW
methods - and all is fine, except for when I import large files, with
many objects.

After about 288 objects, the import fails when the method that adds an
object in the ZODB returns None, instead of the object it added.  From
what I can tell, the added object is not None before it is returned, but
the name object, set via the expression

  object = self.manage_add_issue(...)

is None.  So it looks like somewhere between 'return issue_' in
manage_add_issue and the expression above, the object is lost.

Any ideas what could be happening here?  I've managed to work around it
for now, but it is interesting nonetheless.

Regards,

Morten
begin:vcard
fn:Morten Petersen
n:Petersen;Morten
org:Nidelven IT
adr:;;Postboks 923;Trondheim;;7409;Norway
email;internet:[EMAIL PROTECTED]
title:Project Manager
tel;work:+47 45 44 00 69
tel;cell:+47 45 44 00 69
x-mozilla-html:FALSE
url:http://www.nidelven-it.no
version:2.1
end:vcard

___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )