[sqlalchemy] Re: setattr and mapped ORM

2009-10-24 Thread laurent FRANCOIS

On Wed, 2009-10-21 at 09:24 -0700, David Gardner wrote:
 Using setattr() shouldn't be a problem, however the __dict__ attribute
 also has other things in there like _sa_instance_state that I don't
 believe you 
 want to copy to the new item. Try this instead:
 
 for col in object_mapper(update):
 setattr(proxy,col.key,getattr(update,col.key))
 

Hum hum 

Object Mapper is not Callable

So I don't understand what you mean.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: setattr and mapped ORM

2009-10-24 Thread laurent FRANCOIS

On Wed, 2009-10-21 at 09:24 -0700, David Gardner wrote:
 Using setattr() shouldn't be a problem, however the __dict__ attribute
 also has other things in there like _sa_instance_state that I don't
 believe you 
 want to copy to the new item. Try this instead:
 
 for col in object_mapper(update):
 setattr(proxy,col.key,getattr(update,col.key))

OK thanks. After doing some introspection:

 proxy
User record: None None 
 update
User record: francois tretre 
 for c in user_mapper.c:
... setattr(proxy, c.key, getattr(update, c.key))
... 
 proxy 
User record: francois tretre 

And of course user_mapper = mapper(User, user_table)

L.FRANCOIS


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: can't import ARRAY from dialects.postgresql

2009-10-24 Thread sector119

The latest trunk.

 from sqlalchemy.dialects.postgresql import ARRAY
Traceback (most recent call last):
  File console, line 1, in module
ImportError: cannot import name ARRAY

 from sqlalchemy.dialects.postgresql.base import ARRAY

 from sqlalchemy.dialects import postgresql

 'ARRAY' in dir(postgresql)
False

We have no ARRAY at sqlalchemy/dialects/postgresql/__init__.py __all__
list...

% grep ARRAY dialects/postgresql/__init__.py
%

The same for orm, sql, can't import tham from sqlalchemy.. Should make
from sqlalchemy.orm import mapper, relation, ... not just from
sqlalchemy import orm :/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] UnicodeDecodeError with pg8000 postgresql.conf client_encoding=utf8, engine encoding=utf-8

2009-10-24 Thread sector119

Hi All.

I've got UnicodeDecodeError: 'ascii' codec can't decode byte 0xa1 in
position 3: ordinal not in range(128)
Why it can happen? I use client_encoding=utf8 at postgresql.conf and
encoding=utf-8 at create_engine.

File 'string', line 2 in submit
File '/home/sector119/devel/eps_env/lib/python2.6/site-packages/
Pylons-0.9.7-py2.6.egg/pylons/decorators/__init__.py', line 207 in
wrapper
  return func(self, *args, **kwargs)
File '/home/sector119/devel/eps_env/src/eps/eps/controllers/login.py',
line 39 in submit
  user = meta.Session.query(User).options(eagerload
('locality')).filter_by(username=username).first()
File '/home/sector119/devel/eps_env/lib/python2.6/site-packages/
SQLAlchemy-0.6beta1dev_r0-py2.6.egg/sqlalchemy/orm/query.py', line
1250 in first
  ret = list(self[0:1])
File '/home/sector119/devel/eps_env/lib/python2.6/site-packages/
SQLAlchemy-0.6beta1dev_r0-py2.6.egg/sqlalchemy/orm/query.py', line
1171 in __getitem__
  return list(res)
File '/home/sector119/devel/eps_env/lib/python2.6/site-packages/
SQLAlchemy-0.6beta1dev_r0-py2.6.egg/sqlalchemy/orm/query.py', line
1311 in __iter__
  return self._execute_and_instances(context)
File '/home/sector119/devel/eps_env/lib/python2.6/site-packages/
SQLAlchemy-0.6beta1dev_r0-py2.6.egg/sqlalchemy/orm/query.py', line
1314 in _execute_and_instances
  result = self.session.execute(querycontext.statement,
params=self._params, mapper=self._mapper_zero_or_none())
File '/home/sector119/devel/eps_env/lib/python2.6/site-packages/
SQLAlchemy-0.6beta1dev_r0-py2.6.egg/sqlalchemy/orm/session.py', line
739 in execute
  clause, params or {})
File '/home/sector119/devel/eps_env/lib/python2.6/site-packages/
SQLAlchemy-0.6beta1dev_r0-py2.6.egg/sqlalchemy/engine/base.py', line
975 in execute
  return Connection.executors[c](self, object, multiparams, params)
File '/home/sector119/devel/eps_env/lib/python2.6/site-packages/
SQLAlchemy-0.6beta1dev_r0-py2.6.egg/sqlalchemy/engine/base.py', line
1037 in _execute_clauseelement
  return self.__execute_context(context)
File '/home/sector119/devel/eps_env/lib/python2.6/site-packages/
SQLAlchemy-0.6beta1dev_r0-py2.6.egg/sqlalchemy/engine/base.py', line
1060 in __execute_context
  self._cursor_execute(context.cursor, context.statement,
context.parameters[0], context=context)
File '/home/sector119/devel/eps_env/lib/python2.6/site-packages/
SQLAlchemy-0.6beta1dev_r0-py2.6.egg/sqlalchemy/engine/base.py', line
1120 in _cursor_execute
  self.dialect.do_execute(cursor, statement, parameters,
context=context)
File '/home/sector119/devel/eps_env/lib/python2.6/site-packages/
SQLAlchemy-0.6beta1dev_r0-py2.6.egg/sqlalchemy/engine/default.py',
line 181 in do_execute
  cursor.execute(statement, parameters)
File 'build/bdist.linux-i686/egg/pg8000/dbapi.py', line 243 in _fn
File 'build/bdist.linux-i686/egg/pg8000/dbapi.py', line 312 in execute
File 'build/bdist.linux-i686/egg/pg8000/dbapi.py', line 317 in
_execute
File 'build/bdist.linux-i686/egg/pg8000/interface.py', line 303 in
execute
File 'build/bdist.linux-i686/egg/pg8000/interface.py', line 108 in
__init__
File 'build/bdist.linux-i686/egg/pg8000/protocol.py', line 918 in _fn
File 'build/bdist.linux-i686/egg/pg8000/protocol.py', line 1069 in
parse
File 'build/bdist.linux-i686/egg/pg8000/protocol.py', line 975 in
_send
File 'build/bdist.linux-i686/egg/pg8000/protocol.py', line 121 in
serialize
UnicodeDecodeError: 'ascii' codec can't decode byte 0xa1 in position
3: ordinal not in range(128)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: can't import ARRAY from dialects.postgresql

2009-10-24 Thread Michael Bayer

its missing.  use sqlalchemy.dialects.postgresql.base.ARRAY.



On Oct 24, 2009, at 6:19 AM, sector119 wrote:


 The latest trunk.

 from sqlalchemy.dialects.postgresql import ARRAY
 Traceback (most recent call last):
  File console, line 1, in module
 ImportError: cannot import name ARRAY

 from sqlalchemy.dialects.postgresql.base import ARRAY

 from sqlalchemy.dialects import postgresql

 'ARRAY' in dir(postgresql)
 False

 We have no ARRAY at sqlalchemy/dialects/postgresql/__init__.py __all__
 list...

 % grep ARRAY dialects/postgresql/__init__.py
 %

 The same for orm, sql, can't import tham from sqlalchemy.. Should make
 from sqlalchemy.orm import mapper, relation, ... not just from
 sqlalchemy import orm :/
 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---