I have the following code and when I update the edit through the editform interface, then the id in the ZMI does not change. When I try to rename the item, it works as long as the internal and ZMI values are the same, otherwise I get weird errors: 1. If they are different and I rename the id through the ZMI to something new, it stack traces. 2. If they are different and I rename the id through the ZMI to the internal representation, then no error but also no change to the value in the ZMI. Any comments? Thanks, Pieter 46 _editForm=DTMLFile('dtml/edit',globals()) 47 48 security.declareProtected('View management screens','editForm') 49 50 def editForm(self,REQUEST,manage_tabs_message=None): 51 "returns the edit form" 52 return self._editForm(REQUEST,globals()) 53 54 security.declareProtected('Change shopping item','editItem') 55 56 def editItem(self,id,REQUEST=None,RESPONSE=None): 57 "Edit a shopping item" 58 self.id = id 59 if REQUEST is not None: 60 message="Item_updated" 61 return self._editForm(REQUEST,manage_tabs_message=message)
It's a bit of a no-no in Zope to change an object's id after it has been "seated" into an object manager. If you really need to do so use the ObjectManager API, i.e. manage_renameObject(). The reason is that object managers keep an internal list of subobject ids, and when this list disagrees with reality all kind of havoc is caused, as you have discovered. Stefan On Montag, Mai 3, 2004, at 23:27 Europe/Vienna, pieter claassen wrote:
Any comments?
-- The time has come to start talking about whether the emperor is as well dressed as we are supposed to think he is. /Pete McBreen/
I'm using zsql-methods for retriving data from an aida-database suddenly(?) twho of my methods have started showing emty tables. the sql is: (ID and IID is one of the fields in the table) Arguments: ReportID SELECT * FROM Item WHERE ReportID=<dtml-sqlvar ReportID type="int"> AND (IPage ="Sammendrag" OR IPage ="Summary") ORDER BY ID this shows an emty table however: SELECT * FROM Item WHERE ReportID=<dtml-sqlvar ReportID type="int"> AND (IPage ="Sammendrag" OR IPage ="Summary") ORDER BY IID gives me the table (but sorted on the wrong key) Any clues? -- Einar Næss Jensen Avdelingsingeniør IT-HF 735 90750
Checkout what query is sent to your database and try the same queries from the command line. ...very unlikely a Zope problem. -aj --On Dienstag, 4. Mai 2004 14:25 Uhr +0200 Einar Næss Jensen <einar.jensen@hf.ntnu.no> wrote:
I'm using zsql-methods for retriving data from an aida-database suddenly(?) twho of my methods have started showing emty tables. the sql is: (ID and IID is one of the fields in the table)
Arguments: ReportID
SELECT * FROM Item WHERE ReportID=<dtml-sqlvar ReportID type="int"> AND (IPage ="Sammendrag" OR IPage ="Summary") ORDER BY ID
this shows an emty table
however: SELECT * FROM Item WHERE ReportID=<dtml-sqlvar ReportID type="int"> AND (IPage ="Sammendrag" OR IPage ="Summary") ORDER BY IID
gives me the table (but sorted on the wrong key)
Any clues?
Andreas Jung wrote:
Checkout what query is sent to your database and try the same queries from the command line. ...very unlikely a Zope problem.
Maybe. the same query using mysql command-line gives me the correct output, same in phpmyadmin. the mysql log says the query sent was this: select * from Item where ReportID=13489 AND IPage="sammendrag" ORDER BY ID so I'm left with somethin strange in zope/zsql-method W recently switched to zope 2.7.0, and it was after that this "bug" appeared. I "fixed it" by removing the "order by ID"-part. but I still wonder.... -- Einar Næss Jensen Avdelingsingeniør IT-HF 735 90750
Einar Næss Jensen wrote at 2004-5-4 14:25 +0200:
... SELECT * FROM Item WHERE ReportID=<dtml-sqlvar ReportID type="int"> AND (IPage ="Sammendrag" OR IPage ="Summary") ORDER BY ID
this shows an emty table
however: SELECT * FROM Item WHERE ReportID=<dtml-sqlvar ReportID type="int"> AND (IPage ="Sammendrag" OR IPage ="Summary") ORDER BY IID
gives me the table (but sorted on the wrong key)
Are you using "ZODBCDA"? Someone else reported similar incomprehensible differences in SQL results with "ZODBCDA". The problem disappeared when he switch to "mxZODBCDA". -- Dieter
Dieter Maurer wrote:
Einar Næss Jensen wrote at 2004-5-4 14:25 +0200:
... SELECT * FROM Item WHERE ReportID=<dtml-sqlvar ReportID type="int"> AND (IPage ="Sammendrag" OR IPage ="Summary") ORDER BY ID
this shows an emty table
however: SELECT * FROM Item WHERE ReportID=<dtml-sqlvar ReportID type="int"> AND (IPage ="Sammendrag" OR IPage ="Summary") ORDER BY IID
gives me the table (but sorted on the wrong key)
Are you using "ZODBCDA"?
No. Only ZMysqlDa
Someone else reported similar incomprehensible differences in SQL results with "ZODBCDA". The problem disappeared when he switch to "mxZODBCDA".
I reinnstalled Mysql-python.. It now works. (someone else have been innstalling warious adapters for MSSQL, However: Later I ran a check on my tables and it found several duplicate keys (which should be uniqe) for the field i wanted to sort. I think maybe something was wrong with my tables. Best regards EInar Næss Jensen -- Einar Næss Jensen Avdelingsingeniør IT-HF 735 90750
Hi, I use zope 2.7.0. This is a local update document I use to update news items. I store each news item in a separate file. <dtml-with expr="_.getattr(this(),REQUEST.id)"> <dtml-call expr="manage_changeProperties(REQUEST)"> </dtml-with> It updates the news items properly and shows a message saying it was successful. See below. <div id="managebox"> <p>Entry modified.</p> <p><a href="local_edit">Back</a></p> </div> But the message displayed contains strange characters. This affects other parts of the web page. If I press 'Back', it goes back to the parent page and everything is displayed properly. Example: Aktu(illegible) Felv(illegible) Thx in advance, (illegible)lgyesi Tibor
You could try specifying the full path for 'local_edit' eg. <a href="http://www.awebsite.com/local_edit">Back</a> Jonathan
hi! i´m just diving into zope product development and have troubles implementing the example "poll" product from the Zope Developer's Guide: my class looks like this: class PollProduct(SimpleItem, PropertyManager): ... i´am initializing my class attributes like this: def __init__(self, id, question, responses): self.id=id self._question = question self._responses = responses before that i define _properties=( {'id':'question','type':'string','mode':'w'}, {'id':'responses','type':'lines','mode':'w'}, ) and manage_options=( #{'label' : 'Test', 'action' : ''}, ) + SimpleItem.manage_options + PropertyManager.manage_options if i click on the "Properties" Tab in the ZMI i get this error Error Type: AttributeError Error Value: question strange...i compared my product with some existing products and can´t find my mistake, maybe you see it with one look tnx in advance!
def __init__(self, id, question, responses): self.id=id self._question = question self._responses = responses
You have to use self.question, self.response, because these are the attribte names you give in the properties definition:
_properties=( {'id':'question','type':'string','mode':'w'}, {'id':'responses','type':'lines','mode':'w'}, )
Regards, Sandor
that doesn?t work: _properties=( {'id':'self.question','type':'string','mode':'w'}, ) and {'id':self.question,'type':'string','mode':'w'}, neither :( On Wed, 5 May 2004 08:03:44 -0500, <zope@netchan.cotse.net> wrote:
def __init__(self, id, question, responses): self.id=id self._question = question self._responses = responses
You have to use self.question, self.response, because these are the attribte names you give in the properties definition:
_properties=( {'id':'question','type':'string','mode':'w'}, {'id':'responses','type':'lines','mode':'w'}, )
Regards, Sandor
__________ NOD32 1.750 (20040505) Information __________
This message was checked by NOD32 antivirus system. http://www.nod32.com
-- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
that doesn't work: _properties=( {'id':'self.question','type':'string','mode':'w'}, ) and {'id':self.question,'type':'string','mode':'w'}, neither :( On Wed, 5 May 2004 08:03:44 -0500, <zope@netchan.cotse.net> wrote:
def __init__(self, id, question, responses): self.id=id self._question = question self._responses = responses
You have to use self.question, self.response, because these are the attribte names you give in the properties definition:
_properties=( {'id':'question','type':'string','mode':'w'}, {'id':'responses','type':'lines','mode':'w'}, )
Regards, Sandor
You have to change the attribute names in the __init__ method, not in the _properties construct: def __init__(self, id, question, responses): self.id=id self.question = question self.responses = responses
that's also not the solution, but thanks anyway. i will post the whole source, maybe you can find the problem. On Wed, 5 May 2004 08:30:43 -0500, <zope@netchan.cotse.net> wrote:
You have to change the attribute names in the __init__ method, not in the _properties construct:
def __init__(self, id, question, responses): self.id=id self.question = question self.responses = responses
from AccessControl import ClassSecurityInfo from Globals import InitializeClass from OFS.SimpleItem import SimpleItem from OFS.PropertyManager import PropertyManager def manage_addPoll_form(self): """ Returns an HTML form. """ return """<html> <head><title>Add Poll</title></head> <body> <form action="manage_addPoll_function"> id <input type="type" name="id"><br> question <input type="type" name="question"><br> responses (one per line) <textarea name="responses:lines"></textarea> <input type="submit"> </form> </body> </html>""" def manage_addPoll_function(self,id,question,responses,REQUEST=None): """ Create a new poll and add it to myself """ self._setObject(id, PollProduct(id, question, responses)) if REQUEST is not None: return self.manage_main(self, REQUEST) class PollProduct(SimpleItem, PropertyManager): """ Poll product class, implements Poll interface. The poll has a question and a sequence of responses. Votes are stored in a dictionary which maps response indexes to a number of votes. """ meta_type='Poll' security=ClassSecurityInfo() manage_options=( #{'label' : 'Edit', 'action' : 'manage_propertiesForm'}, ) + SimpleItem.manage_options + PropertyManager.manage_options _properties=( #{'id':'id','type':'string','mode':'r'}, #{'id':'title','type':'string','mode':'w'}, {'id':'question','type':'string','mode':'w'}, {'id':'responses','type':'lines','mode':'w'}, ) def __init__(self, id, question, responses): self.id=id self.question = question self.responses = responses self.votes = {} for i in range(len(responses)): self.votes[i] = 0 security.declareProtected('Use Poll', 'castVote') def castVote(self, index): "Votes for a choice" self.votes[index] = self.votes[index] + 1 self.votes = self.votes security.declareProtected('View Poll Results', 'getTotalVotes') def getTotalVotes(self): "Returns total number of votes cast" total = 0 for v in self.votes.values(): total = total + v return total security.declareProtected('View Poll Results', 'getVotesFor') def getVotesFor(self, index): "Returns number of votes cast for a given response" return self.votes[index] security.declarePublic('getResponses') def getResponses(self): "Returns the sequence of responses" return tuple(self.responses) security.declarePublic('getQuestion') def getQuestion(self): "Returns the question" return self.question InitializeClass(PollProduct)
Dominique Lederer wrote:
that's also not the solution, but thanks anyway. i will post the whole source, maybe you can find the problem.
Did you create a new instance before clicking the "properties" tab? An old instance with a ._question property will not have a .question property, unless you take special pains to update the old instance. -- Jim Washington
Did you create a new instance before clicking the "properties" tab?
An old instance with a ._question property will not have a .question property, unless you take special pains to update the old instance.
thanks a lot, that helped! can you explain me in short words, when you use a ._question prop and when a .question prop ? what?s the difference ? i read it has something to do with Acquisition, but i didn't understand it. or maybe a link to a good explanation. greets HakTom
Dominique Lederer wrote:
Did you create a new instance before clicking the "properties" tab?
An old instance with a ._question property will not have a .question property, unless you take special pains to update the old instance.
thanks a lot, that helped!
can you explain me in short words, when you use a ._question prop and when a .question prop ? what?s the difference ? i read it has something to do with Acquisition, but i didn't understand it. or maybe a link to a good explanation.
greets HakTom
I could not find a really good link, and it would be a good idea to look at the source of some of the Zope products out there, to get an idea of "best practice." In Zope2, names with leading underscores are considered private and are not available through the web. You cannot access myObject._myVar in DTML with <dtml-var _myVar>. myObject._myVar also is not available in python script objects. These variables are not completely unreachable, however. You can provide public getter() and setter() methods with appropriate security declarations for access or modification. This may be useful, for example, if Zope's security does not do everything you need, or if you need to do something special before modifying a value. That these names do not participate in (unintended) acquisition may also be good. So, in my opinion, if you need these values to be private, or if they need special control, or if you think "explicit is better than implicit" is a good idea for your product, use a leading underscore in the name. It's less convenient to have to create setters and getters, but the added security and predictability might be worth it. Caveat: The leading-underscore-means-private policy probably will change in Zope3. Hope this helps. -- Jim Washington
Hi guys, Have been thru all optimisations process (caching etc .....) but my zope still runs like a dog. I am fairly confident about my zope set up and start to think the pb is the box itself(i did anaother install on older box with same apache+proxy config and zope proudly flies !!) my config is : Dell poweredge 1750 + redhat SMP 2.4.20 stock kernel. I ve got this in dmesg : "" application bug: python2.3(10123) has SIGCHLD set to SIG_IGN but calls wait(). (see the NOTES section of 'man 2 wait'). Workaround activated """ Dunno if this could be the issue . I try to run another Python (from rpm) but got the same messages) Any one noticing same pb on dell/linux with RH9 boxes ? Anyone could point me out to checks i may have not done yet ? Thanx a lot Seb
RH9 systems have had problems because of the the NPTL. There is all sorts of traffic in the archive. You may also want/need to use CPU affinity to avoid problem with the GIL. On Thu, 6 May 2004, sebastien Pastor wrote:
Hi guys,
Have been thru all optimisations process (caching etc .....) but my zope still runs like a dog. I am fairly confident about my zope set up and start to think the pb is the box itself(i did anaother install on older box with same apache+proxy config and zope proudly flies !!) my config is : Dell poweredge 1750 + redhat SMP 2.4.20 stock kernel.
I ve got this in dmesg : "" application bug: python2.3(10123) has SIGCHLD set to SIG_IGN but calls wait(). (see the NOTES section of 'man 2 wait'). Workaround activated """ Dunno if this could be the issue . I try to run another Python (from rpm) but got the same messages)
Any one noticing same pb on dell/linux with RH9 boxes ? Anyone could point me out to checks i may have not done yet ?
Thanx a lot
Seb
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
sebastien Pastor wrote at 2004-5-6 13:08 +0200:
Have been thru all optimisations process (caching etc .....) but my zope still runs like a dog.
Maybe a profile tells you what is slow. You may try my "ZopeProfiler" product <http://www.dieter.handshake.de/pyprojects/zope> -- Dieter
Thyb wrote at 2004-5-5 10:30 +0200:
This is a local update document I use to update news items. ... It updates the news items properly and shows a message saying it was successful. See below.
<div id="managebox"> <p>Entry modified.</p> <p><a href="local_edit">Back</a></p> </div>
But the message displayed contains strange characters. This affects other parts of the web page. If I press 'Back', it goes back to the parent page and everything is displayed properly.
Example:
Aktuᬩs informᣩ󫼯a> Felv鴥liz?k
Was the output supposed to be in English (i.e. ASCII)? If not, the browser may have got the "charset" wrong. You can specify the charset via <dtml-call "RESPONSE.setHeader('Content-Type','text/html; charset=XXXXXX')"> If this is not the problem, use a TCP-Logger (e.g. Shane's "tcpwatch") to analyse the communication between browser and Zope. This should tell you which part is responsible for the strange characters. -- Dieter
participants (12)
-
Andreas Jung -
Dennis Allison -
Dieter Maurer -
Dominique Lederer -
Einar Næss Jensen -
Jim Washington -
pieter claassen -
sebastien Pastor -
Small Business Services -
Stefan H. Holek -
Thyb -
zope@netchan.cotse.net