[Zope-DB] ConnectionStateError when accessing properties

2010-05-05 Thread robert rottermann
Hi there,

in a plone site where Data is partially maintained in a mysql db, I get a
ConnectionStateError when I try to access properties on the sit.

the error is as follows:

Time2010/04/25 15:10:28.998 GMT+2
User Name (User Id) beat (beat)
Request URL
http://www.energie-plattform.ch/data_folders/save_company_changes/save_company_changes
Exception Type  ConnectionStateError
Exception Value Shouldn't load state for 0x1cbe82 when the connection 
is closed

Traceback (innermost last):

* Module ZPublisher.Publish, line 119, in publish
* Module ZPublisher.mapply, line 88, in mapply
* Module ZPublisher.Publish, line 42, in call_object
* Module wrapper, line 5, in wrapper
* Module kss.core.actionwrapper, line 238, in apply
* Module energiecluster.addresses.browser.company, line 465, in
save_company_changes
* Module energiecluster.addresses.Flag, line 400, in handleFlags
* Module energiecluster.addresses.Flag, line 542, in delFlagsFromObject
* Module energiecluster.addresses.Flag, line 572, in updateHooks
* Module energiecluster.addresses.Newsletteremail, line 248, in hookupFlags
* Module energiecluster.addresses.Newsletteremail, line 188, in 
_hockedupFlags
* Module energiecluster.addresses.Newsletteremail, line 216, in 
getHookedFlags
* Module ZODB.Connection, line 758, in setstate

ConnectionStateError: Shouldn't load state for 0x1cbe82 when the connection is
closed

the code that produces the error is the line
if not ep.hasProperty('newsletter_hooked_flags'):

in a call of the following method:

def getHookedFlags(self):
if not self.context:
return
pt = self.context.portal_properties
ep = getattr(pt.aq_inner.aq_self, 'energiecluster_properties', None)
if not ep:
ep = SimpleItemWithProperties(id='energiecluster_properties',
  title='energiecluster_properties')
pt._setObject('energiecluster_properties', ep)

if not ep.hasProperty('newsletter_hooked_flags'): - error here
values = [
'#language:Type:Flag1',
'#where type 0 = html, type 1 = text',
'de:0:ad_newsletter_de_html',
'de:1:ad_newsletter_de_text',
'fr:0:ad_newsletter_fr_html',
'fr:1:ad_newsletter_fr_text',
]
ep.manage_addProperty(id='newsletter_hooked_flags',
value=values, type='lines')
return  ep.getProperty('newsletter_hooked_flags')

unfortunately this happens only on the life site. I can not reproduce the error
in our test environment.

I would very much appreciate a hint how to circumvent that error.
thanks
robert
___
Zope-DB mailing list
Zope-DB@zope.org
https://mail.zope.org/mailman/listinfo/zope-db


___
Zope-DB mailing list
Zope-DB@zope.org
https://mail.zope.org/mailman/listinfo/zope-db


[Zope-DB] ConnectionStateError when accessing properties

2010-04-26 Thread robert rottermann
Hi there,

in a plone site where Data is partially maintained in a mysql db, I get a
ConnectionStateError when I try to access properties on the sit.

the error is as follows:

Time2010/04/25 15:10:28.998 GMT+2
User Name (User Id) beat (beat)
Request URL
http://www.energie-plattform.ch/data_folders/save_company_changes/save_company_changes
Exception Type  ConnectionStateError
Exception Value Shouldn't load state for 0x1cbe82 when the connection 
is closed

Traceback (innermost last):

* Module ZPublisher.Publish, line 119, in publish
* Module ZPublisher.mapply, line 88, in mapply
* Module ZPublisher.Publish, line 42, in call_object
* Module wrapper, line 5, in wrapper
* Module kss.core.actionwrapper, line 238, in apply
* Module energiecluster.addresses.browser.company, line 465, in
save_company_changes
* Module energiecluster.addresses.Flag, line 400, in handleFlags
* Module energiecluster.addresses.Flag, line 542, in delFlagsFromObject
* Module energiecluster.addresses.Flag, line 572, in updateHooks
* Module energiecluster.addresses.Newsletteremail, line 248, in hookupFlags
* Module energiecluster.addresses.Newsletteremail, line 188, in 
_hockedupFlags
* Module energiecluster.addresses.Newsletteremail, line 216, in 
getHookedFlags
* Module ZODB.Connection, line 758, in setstate

ConnectionStateError: Shouldn't load state for 0x1cbe82 when the connection is
closed

the code that produces the error is the line
if not ep.hasProperty('newsletter_hooked_flags'):

in a call of the following method:

def getHookedFlags(self):
if not self.context:
return
pt = self.context.portal_properties
ep = getattr(pt.aq_inner.aq_self, 'energiecluster_properties', None)
if not ep:
ep = SimpleItemWithProperties(id='energiecluster_properties',
  title='energiecluster_properties')
pt._setObject('energiecluster_properties', ep)

if not ep.hasProperty('newsletter_hooked_flags'): - error here
values = [
'#language:Type:Flag1',
'#where type 0 = html, type 1 = text',
'de:0:ad_newsletter_de_html',
'de:1:ad_newsletter_de_text',
'fr:0:ad_newsletter_fr_html',
'fr:1:ad_newsletter_fr_text',
]
ep.manage_addProperty(id='newsletter_hooked_flags',
value=values, type='lines')
return  ep.getProperty('newsletter_hooked_flags')

unfortunately this happens only on the life site. I can not reproduce the error
in our test environment.

I would very much appreciate a hint how to circumvent that error.
thanks
robert
___
Zope-DB mailing list
Zope-DB@zope.org
https://mail.zope.org/mailman/listinfo/zope-db


[Zope-DB] assigning db engine dynamically/conditionally in tests

2009-01-15 Thread robert rottermann
Hi there,
I am using z3c.saconfig and zope.sqlalchemy to access an relational db.

Now I would like to use a different db schema for the test than for the real
thing.
I am usin a zcml stanza to define the the db:
configure xmlns=http://namespaces.zope.org/zope;
xmlns:browser=http://namespaces.zope.org/browser;
xmlns:five=http://namespaces.zope.org/five;
xmlns:i18n=http://namespaces.zope.org/i18n;
xmlns:db=http://namespaces.zope.org/db;
i18n_domain=energiecluster

  db:engine name=addresses.database url=mysql://r...@localhost/energie_3 /
  db:session name=energiecluster.addresses engine=addresses.database /

/configure

here my questions:
Is there a way to load such a stanza conditionally?

or can I just assign a new new engine to a session?

or is there an other way to achieve my goal?

thanks
robert
___
Zope-DB mailing list
Zope-DB@zope.org
http://mail.zope.org/mailman/listinfo/zope-db


[Zope-DB] how to access database declared in configure.zcml

2008-10-31 Thread robert rottermann
Hi there,

I am using collective tin.
the new version users z3c.saconfig.

to use it I have to declare the database in the configure.zcl like this:
db:engine name=declarations.database
url=mysql://[EMAIL PROTECTED]/energie echo=True /
db:session name=energiecluster.eccontent.platforms   
engine=declarations.database /

I need this database at some place in my code.
How can I access it.

What I am looking for is some kind of getUtilitty(db)

second question:
where would I find what is defined in:
xmlns:db=http://namespaces.zope.org/db

http://namespaces.zope.org is not a valid link..


thanks for any pointers
robert

___
Zope-DB mailing list
Zope-DB@zope.org
http://mail.zope.org/mailman/listinfo/zope-db


Re: [Zope-DB] Help me.

2008-03-11 Thread robert rottermann
Cu Vinh Loc schrieb:
   Dear friends,
 
   I am using plone for deploying the website, but I have some problems
 such as:
- Using relational (internal) database Gadfly database: I do not know
 where the database is stored in the Zope. Can I manipulate directly
 this database visual?
- Users and groups: How to assign this permissions to my website.
 
   Could you show me how to implement that easily.
 
   Cheers,
   Cu Vinh Loc.
 
 
 
 ___
 Zope-DB mailing list
 Zope-DB@zope.org
 http://mail.zope.org/mailman/listinfo/zope-db
 
 
gadfly is stored in the var directory of your zope instance.
however I belive it is not supported anymore.

user and groups:
in your instance go to confiration  (using your browser to access a
running plone).
there you find users ang groups.

for every object (a document, a folder) you can define who (what
user/group) has what permission. this you do using the sharing tab.

robert
___
Zope-DB mailing list
Zope-DB@zope.org
http://mail.zope.org/mailman/listinfo/zope-db


Re: [Zope-DB] Please help me about driver adapter

2007-02-15 Thread robert rottermann
I do not think any one of us can help you unless you tell us what
exactly your problem with installing pymssql ist.
by the way: do you mean MySQLdb?

there is very good  documentation on using Z SQL in the zope book:
http://www.plope.com/Books/2_7Edition/RelationalDatabases.stx

there you find examples how to use a query with like.
robert

Nguyen Viet Minh Quang wrote:
 Dear Dieter and All,

 Thank you for your mail.

 I have now a trial version of mxODBC. However I don't really like it
 because it's not free. I would like to use pymssql and another one,
 although I try to install it more times but it's not working. Can you
 help me to install it?

 Moreover,  I'm testing my product with mxODBC. I have a problem about
 query. I want to use keyword 'LIKE' and '%' inside SQL query but I
 don't know how to do it. In the current, I use dtml-sqlvar and
 dtml-sqltest to do it. Do you know about my problem and can help me to
 solve it?

 Further, How can I format the text to get from database, about HTML tag?

 Thank you for your help.

 Best regards,
 

 ___
 Zope-DB mailing list
 Zope-DB@zope.org
 http://mail.zope.org/mailman/listinfo/zope-db
   

begin:vcard
fn:robert  rottermann
n:rottermann;robert 
email;internet:[EMAIL PROTECTED]
tel;work:031 333 10 20
tel;fax:031 333 10 23
tel;home:031 333 36 03
x-mozilla-html:FALSE
version:2.1
end:vcard

___
Zope-DB mailing list
Zope-DB@zope.org
http://mail.zope.org/mailman/listinfo/zope-db


Re: [Zope-DB] Can I change the ZSQL max_rows default value?

2007-02-06 Thread robert rottermann
Robert-Reinder Nederhoed wrote:
 Good day,
 
 
 We use Zope 2.8, still from ZMI. We ran into the 1000 limit several
 times. Instead of remembering to set it to a higher value, I would like
 to change the ZSQL max_rows default to 5000.
 
 Is it possible to do this?
 
 
 Friendly greetings, Robert-Reinder
 
 -- 
 
 ___
 Zope-DB mailing list
 Zope-DB@zope.org
 http://mail.zope.org/mailman/listinfo/zope-db
 
in your zsql object there is aan advanced tab. there you can set the limit. 
if you set it to 0  all rows will be returned.
robert
begin:vcard
fn:robert  rottermann
n:rottermann;robert 
email;internet:[EMAIL PROTECTED]
tel;work:031 333 10 20
tel;fax:031 333 10 23
tel;home:031 333 36 03
x-mozilla-html:FALSE
version:2.1
end:vcard

___
Zope-DB mailing list
Zope-DB@zope.org
http://mail.zope.org/mailman/listinfo/zope-db


Re: [Zope-DB]found reason: sql query works in database connector but not in ZSQL method

2007-01-18 Thread robert rottermann
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

hi there,

I think I found the reason, for my problems with stored procedures.
it seems that on can not call a stored MySQL 5.0x procedure from zope
that returns a data set.
when I call the body of the stored procedure everything works fine.

what I now do as an interim solution, I call the read only procedures
directly from python.
procedures that alter data i call from a zope connector.

I would be glad to here of any reason not to do this.

thanks for your help.

robert
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.5 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org

iD8DBQFFr6c9GaryJ0T9kUYRAlkiAJ9TZ3rKw3iiTHuZ1fiQuJE6Sdoa0wCfZr63
uNOpVr8pc+rYV6jwbZ9l6sI=
=p3jD
-END PGP SIGNATURE-
___
Zope-DB mailing list
Zope-DB@zope.org
http://mail.zope.org/mailman/listinfo/zope-db


[Zope-DB] sql query works in database connector but not in ZSQL method

2007-01-17 Thread robert rottermann
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi there,

I try the following statement:
CALL selectVertexProperties(1, @error2)

when I execute this directly in the test window of the database
connection, it works fine.
when i execute the same line in the test window of a ZSQL Method
then I get an error:

Error, Products.mxODBCZopeDA.ZopeDA.ReplayTransaction: OperationalError
on : ('HYT00', 2014, [unixODBC][MySQL][ODBC 3.51
Driver][mysqld-5.0.26]Commands out of sync; you can't run this command
now, 6113) SQL used:

CALL selectVertexProperties(1, @error2)

when I call this method from plain python, it works fine also.

Any pointers what could be the reason would be greatly appreciated.

robert
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.5 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org

iD8DBQFFrjW8GaryJ0T9kUYRAj3iAJ0ccFcfy/y3q4eQs+80ZfDhQFuyfwCePLG+
wjLmLUZmHOvnkEkygo82HJA=
=Jq1+
-END PGP SIGNATURE-
___
Zope-DB mailing list
Zope-DB@zope.org
http://mail.zope.org/mailman/listinfo/zope-db


Re: [Zope-DB] sql query works in database connector but not in ZSQL method

2007-01-17 Thread robert rottermann
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Charlie Clark schrieb:
 Am 17.01.2007, 15:42 Uhr, schrieb robert rottermann [EMAIL PROTECTED]:
 
 Hi there,
 I try the following statement:
 CALL selectVertexProperties(1, @error2)
 when I execute this directly in the test window of the database
 connection, it works fine.
 when i execute the same line in the test window of a ZSQL Method
 then I get an error:
 Error, Products.mxODBCZopeDA.ZopeDA.ReplayTransaction: OperationalError
 on : ('HYT00', 2014, [unixODBC][MySQL][ODBC 3.51
 Driver][mysqld-5.0.26]Commands out of sync; you can't run this command
 now, 6113) SQL used:
 
 Robert,
 
 you might have to call this using the callproc() method of the DA in an
 ExternalMethod.
 
 Charlie
 

If tried that, but somehow I did not get it rigth:
questions:
- - the first parameter is an integer, how do I force that?
- - the second parameter is an out parameter, how do I specify that ?

thanks
robert

('23000', 1064, [unixODBC][MySQL][ODBC 3.51 Driver][mysqld-5.0.26]You
have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near '{call
selectVertexProperties('1')}' at line 1, 6088)
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.5 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org

iD8DBQFFrktyGaryJ0T9kUYRAv7xAJ9fTQ819q6dpQELO4Y3Ix/LB7ARjgCfTmRx
tA3og1VuWZnRmDqpcjhUqdY=
=S1mn
-END PGP SIGNATURE-
___
Zope-DB mailing list
Zope-DB@zope.org
http://mail.zope.org/mailman/listinfo/zope-db


Re: [Zope-DB] sql query works in database connector but not in ZSQL method

2007-01-17 Thread robert rottermann
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Kevin Campbell schrieb:
 On Wed, Jan 17, 2007 at 03:42:04PM +0100, robert rottermann wrote:
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1

 Hi there,

 I try the following statement:
 CALL selectVertexProperties(1, @error2)

 when I execute this directly in the test window of the database
 connection, it works fine.
 when i execute the same line in the test window of a ZSQL Method
 then I get an error:

 Error, Products.mxODBCZopeDA.ZopeDA.ReplayTransaction: OperationalError
 on : ('HYT00', 2014, [unixODBC][MySQL][ODBC 3.51
 Driver][mysqld-5.0.26]Commands out of sync; you can't run this command
 now, 6113) SQL used:

 CALL selectVertexProperties(1, @error2)

 when I call this method from plain python, it works fine also.

 Any pointers what could be the reason would be greatly appreciated.
 
 Robert,
 
 Can you give an example of how you call this in plain python? It may be
 that in using plain python you are starting a new transaction, and there
 are previous sql commands which are causing problems. Perhaps some more
 details of the sql statements issued would be helpful also.
 
 Kevin
 
thanks for your answer,
 here is what I do in a plain python script (using MySQLdb):

def findUser(username):
query = CALL selectVertexIdFromLogin('%s', @id, @error1); \
CALL selectVertexProperties(@id, @error2) % username
cursor.execute(query)
cursor.nextset()
print cursor.fetchall()

this is what I try to do in a method in a Zope product of ours:
def getUserDataById(self, userid=''):
return base user data for user. if userid is not given use
looged in user
db = self.redscout_tool.scout_connection()
sql_delimiter = self.sql_delimiter
if not userid:
userid = self.portal_membership.getAuthenticatedMember().getId()
query = CALL selectVertexIdFromLogin('%s', @id, @error); select
@error, @id % userid
result = db.query((query).replace(';', sql_delimiter))
if result:
result = result[1][0]
error = int(result[0])
if error:
handle error
return 'fehler'
else:
dbid = int(result[1])
query =  CALL selectVertexProperties(%s, @error2) % dbid
- - result = db.query((query).replace(';', sql_delimiter))
return result


thanks for your help
robert
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.5 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org

iD8DBQFFrkw9GaryJ0T9kUYRArRdAJ9KR+vSS8oF8zIdmkSXEdBJ3d4p9wCfaVtb
e1vDt07FPzJMYh0T4PqgEl4=
=NbWY
-END PGP SIGNATURE-
___
Zope-DB mailing list
Zope-DB@zope.org
http://mail.zope.org/mailman/listinfo/zope-db


Re: [Zope-DB] sql query works in database connector but not in ZSQL method

2007-01-17 Thread robert rottermann
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Charlie Clark schrieb:
 Am 17.01.2007, 17:14 Uhr, schrieb robert rottermann [EMAIL PROTECTED]:
 
 If tried that, but somehow I did not get it rigth:
 questions:
 - - the first parameter is an integer, how do I force that?
 
 int(para) ?
 
I of course can send them into the interface as integer, but the
procedure is called with a sting (at least the error suggests that)
- --{call selectVertexProperties('1')}' at line 1, 6088)
robert
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.5 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org

iD8DBQFFrlVcGaryJ0T9kUYRAsKbAJoCrwSuF6YBYJpTUZazIlD/66rRqgCeOBhR
N5uulcNxNGEpY7qjrKzdacI=
=mBgs
-END PGP SIGNATURE-
___
Zope-DB mailing list
Zope-DB@zope.org
http://mail.zope.org/mailman/listinfo/zope-db


Re: [Zope-DB] sql query works in database connector but not in ZSQL method

2007-01-17 Thread robert rottermann
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1


 
 Robert,
 
 Looks very much like an issue due to transactions. Are you using auto-commit 
 on either the MySQLdb connection or the zope database adapter? Perhaps
 you could test the issue by placing get_transaction().commit() before
 the start of your zope database code, and get_transaction().commit() at
 the end. Please don't do this in production code, this is just to
 isolate the issue.
 
 Regards,
 Kevin
 

I tried that, it did not help BUT, I then looked at the console output.
this is what I get (without the extra commit())


2007-01-17 17:59:41 CRITICAL txn.1082132800 A storage error occurred
during the second phase of the two-phase commit.  Resources may be in an
inconsistent state.
eGenix mxODBC Zope DA: WARNING:
Products.mxODBCZopeDA.ZopeDA.DatabaseConnection DSN=myodbc thread
1082132800/1082132800 at 0x5b24710 could not rollback the transaction -
the data source does not support transactions; this may result in data
inconsistencies !
2007-01-17 17:59:41 ERROR Zope.SiteErrorLog
http://localhost:9880/scout/scout/AAUserInfo
Traceback (innermost last):
  Module ZPublisher.Publish, line 115, in publish
  Module ZPublisher.mapply, line 88, in mapply
  Module ZPublisher.Publish, line 41, in call_object
  Module Shared.DC.Scripts.Bindings, line 311, in __call__
  Module Shared.DC.Scripts.Bindings, line 348, in _bindAndExec
  Module Products.PythonScripts.PythonScript, line 325, in _exec
  Module None, line 2, in AAUserInfo
   - PythonScript at /scout/scout/AAUserInfo
   - Line 2
  Module Products.RedScout.RedScoutTool, line 96, in getUserDataById
  Module transaction._transaction, line 380, in commit
  Module transaction._transaction, line 378, in commit
  Module transaction._transaction, line 441, in _commitResources
  Module transaction._transaction, line 563, in tpc_finish
  Module Shared.DC.ZRDB.TM, line 60, in tpc_finish
  Module Products.mxODBCZopeDA.ZopeDA, line 1126, in _finish
  Module Products.mxODBCZopeDA.ZopeDA, line 999, in errorhandler
OperationalError: ('HYT00', 2014, [unixODBC][MySQL][ODBC 3.51
Driver]Commands out of sync; you can't run this command now, 1199)

so it seems to be a transaction error caused by zope.
I *think*, autocommit is not enabled.

however, the odcb driver complains that the datasource does not support
transactions. I just wonder if I have to enable that specifically.
(my odbc knowledge i VERRY small).

robert
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.5 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org

iD8DBQFFrlxwGaryJ0T9kUYRAiqGAJ4x12oZMQs4geNvw4LCVJT7prRuGQCfUEUV
2GJ5vG0NjtOP+Gz7hyEko9Q=
=2okG
-END PGP SIGNATURE-
___
Zope-DB mailing list
Zope-DB@zope.org
http://mail.zope.org/mailman/listinfo/zope-db


[Zope-DB] [Zope] ZSQL Methods and transaction control

2007-01-10 Thread robert rottermann
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi there,

I am implementing a tool to handle userdata that is stored in a MySQL
db. The underlaying logic of the stored procedures used to maintain the
db content dictate that I have to control the transactions myself.

I understand that there is a way to handle transaction control in the
ZMySQL methods. However I find no documentation at all on how to use it.

Without using ZMySQL methods I would be using the following piece of code:
db = mysql.connect(host=localhost ...)
cursor = db.cursor()
query = CALL insertUser('%s', '$xxx$', @id, @error);select @id, \
@error % 'JohnTheUser')
cursor.execute(query)
# get the next resultset, it has the result of the select
cursor.nextset()
result = cursor.fetchall()[0]
error = int(result[1])
if error:
print error %s when trying to add user %s % (ERRRORS[error],\
'JohnTheUser')
db.rollback()
continue #we are in a loop actually
..
db.commit()

How can I mimic that using ZSQL Methods

thanks for any pointers
Robert


-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.5 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org

iD8DBQFFpNVkGaryJ0T9kUYRAhWfAJ9MTOqEu2PXnUQlVJRfof8hj5zXcgCeJoCt
Dij5NsSXbjc6FWYE5i9nMTE=
=6Qql
-END PGP SIGNATURE-
___
Zope-DB mailing list
Zope-DB@zope.org
http://mail.zope.org/mailman/listinfo/zope-db