[web2py] Re: has_membership('unicode string') raise an UnicodeDecodeError exception

2019-05-23 Thread Dmitry Mosin
Solution is simple (maybe not so obvious), and caused by newer FreeTDS 
version

So I've changed:
db = DAL('mssql://DSN=APP_DSN;UID=dbuser;PWD=dbpass', db_codec='utf-8', 
to
db = DAL('mssql2://DSN=APP_DSN;UID=dbuser;PWD=dbpass', db_codec='utf-8', 


And everything is OK now/

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/4b302233-3d83-498e-8c80-e1e972ad7f87%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: has_membership('unicode string') raise an UnicodeDecodeError exception

2019-05-23 Thread Dmitry Mosin



perhaps you need to set LANG environment system variables 
> export LC_ALL=C.UTF-8
>

I'll try, but old version still works with LANG=C


> seen many case error during run python 3 apps like this, especially in 
> docker linux container, n cured by set LANG variables
>
There is Python2.7...
 

>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/7e05f555-37c8-48c9-b581-07c8eaa6a932%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] has_membership('unicode string') raise an UnicodeDecodeError exception

2019-05-23 Thread Dmitry Mosin
Hello!

After upgrading the framework from 2.9.5 to 2.18.5 a code like this
auth.has_membership(role='Супервизор') or 
auth.has_membership(auth.id_group('Супервизор'))
leads to UnicodeDecodeError exception.

Even db.auth_group.role == 'Супервизор' in /app/appadmin/select/db throws 
an exception 
(but with db.apt_auth_group.id>0 all records are visible)

Traceback (most recent call last):
  File "/var/www/web2py/applications/app/controllers/appadmin.py", line 245, in 
select
nrows = db(query, ignore_common_filters=True).count()
  File "/var/www/web2py/gluon/packages/dal/pydal/objects.py", line 2385, in 
count
return db._adapter.count(self.query, distinct)
  File "/var/www/web2py/gluon/packages/dal/pydal/adapters/base.py", line 791, 
in count
self.execute(self._count(query, distinct))
  File "/var/www/web2py/gluon/packages/dal/pydal/adapters/__init__.py", line 
67, in wrap
return f(*args, **kwargs)
  File "/var/www/web2py/gluon/packages/dal/pydal/adapters/base.py", line 413, 
in execute
rv = self.cursor.execute(command, *args[1:], **kwargs)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 72: 
ordinal not in range(128)

Any suggestions?

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/2f1f1ac2-30bf-4d69-96c4-cd81c0ef80a5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] A small bug in the RadioWidget class

2013-03-27 Thread Dmitry Mosin
 

Hello, friends.


web2py is 2.4.5-stable+timestamp.2013.03.18.22.46.22

There is a small bug. 

**
*
class RadioWidget(OptionsWidget):
 #...
 def widget(cls, field, value, **attributes):
   #...
   checked = {'_checked': 'checked'} if k == value else {}
*

But *value *is a list. So *checked *is always empty 

Can be fixed same way as done in the CheckboxesWidget()

**
def widget(cls, field, value, **attributes):
  #...
  if isinstance(value, (list,tuple)):
value = value[0] 
  else:
value = str(value)





Thank you for your time
 

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: A small bug in the RadioWidget class

2013-03-27 Thread Dmitry Mosin
The ticket #1411 http://code.google.com/p/web2py/issues/detail?id=1411

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Reference field to string field in a keyed table. MSSQL

2013-03-04 Thread Dmitry Mosin
It works!
Thank you, Denes! 

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] SQLFORM.widgets.autocomplete on a field in a keyed table. MSSQL

2013-03-04 Thread Dmitry Mosin
Hello friends!


When I try something like this
---

db.define_table('m_dsc_cards_copy',
Field('cardid','string',length=20,notnull=True,unique=True),
migrate=False,
fake_migrate=True,
primarykey=['cardid']
)

db.define_table('m_dsc_clients',
Field('cn','string'),
Field('cardid','reference m_dsc_cards_copy.cardid',
  widget = SQLFORM.widgets.autocomplete(request, 
db.m_dsc_cards_copy, id_field=db.m_dsc_cards_copy.cardid, limitby=(0,20), 
min_length=2, keyword='_autocomplete_cardid'),
  ondelete=no action),
primarykey=['cn']
)



I've got an exception, 
---

type 'exceptions.AttributeError' 'Table' object has no attribute 
'tablename'

Frames
File /var/www/py/web2py/gluon/restricted.py in restricted at line 212 
File /var/www/py/web2py/applications/discount/models/db.py in module 
at line 57
File /var/www/py/web2py/gluon/sqlhtml.py in __init__ at line 624 
File /var/www/py/web2py/gluon/dal.py in __getitem__ at line 8256 

Function argument list
(self=Table m_dsc_cards_copy (cardid), key='tablename')


Code listing 

8251.
8252.
8253.
8254.
8255.
8256.

8257.
8258.
8259.
8260.

return rows[0]
return None
elif str(key).isdigit() or 'google' in DRIVERS and isinstance(key, Key):
return self._db(self._id == key).select(limitby=(0,1)).first()
elif key:
return ogetattr(self, str(key))


def __call__(self, key=DEFAULT, **kwargs):
for_update = kwargs.get('_for_update',False)
if '_for_update' in kwargs: del kwargs['_for_update']






How can I resolve that?


-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: SQLFORM.widgets.autocomplete on a field in a keyed table. MSSQL

2013-03-04 Thread Dmitry Mosin
web2py(tm) (2, 4, 1, 'alpha.2', datetime.datetime(2013, 3, 2, 9, 17, 16))

понедельник, 4 марта 2013 г., 22:09:59 UTC+6 пользователь Massimo Di Pierro 
написал:

 which web2py version?


 

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: SQLFORM.widgets.autocomplete on a field in a keyed table. MSSQL

2013-03-04 Thread Dmitry Mosin
web2py(tm) (2, 4, 2, 'stable', datetime.datetime(2013, 3, 3, 21, 22, 42))


Traceback (most recent call last):
  File /var/www/py/web2py/gluon/restricted.py, line 212, in restricted
exec ccode in environment
  File /var/www/py/web2py/applications/discount/models/db.py 
https://hd.asburo.ru/admin/default/edit/discount/models/db.py, line 57, in 
module
widget = SQLFORM.widgets.autocomplete(request, db.m_dsc_cards_copy, 
id_field=db.m_dsc_cards_copy.cardid, limitby=(0,20), min_length=2),
  File /var/www/py/web2py/gluon/sqlhtml.py, line 624, in __init__
self.keyword = keyword % dict(tablename=field.tablename,
  File /var/www/py/web2py/gluon/dal.py, line 8258, in __getitem__
return ogetattr(self, str(key))
AttributeError: 'Table' object has no attribute 'tablename'




вторник, 5 марта 2013 г., 0:02:40 UTC+6 пользователь Dmitry Mosin написал:

 web2py(tm) (2, 4, 1, 'alpha.2', datetime.datetime(2013, 3, 2, 9, 17, 16))

 понедельник, 4 марта 2013 г., 22:09:59 UTC+6 пользователь Massimo Di 
 Pierro написал:

 which web2py version?


  


-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: SQLFORM.widgets.autocomplete on a field in a keyed table. MSSQL

2013-03-04 Thread Dmitry Mosin
вторник, 5 марта 2013 г., 4:34:44 UTC+6 пользователь Massimo Di Pierro 
написал:

 Problem is that you are passing db.m_dsc_cards_copy as second argument and 
 it is a Table. It expects a Field.

  
Oh, I was not attentive
(However, it works for non-keyed tables)


Thank you Massimo!
 

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Reference field to string field in a keyed table. MSSQL

2013-03-02 Thread Dmitry Mosin
Hello, friends

Now it looks like

type 'exceptions.NameError' global name 'table_name' is not defined

806.
807.
808.
809.
810.
811.

812.
813.
814.
815.

ftype = ftype + \
types['reference FK'] % dict(
constraint_name = constraint_name, # should 
be quoted
foreign_key = '%s (%s)' % (rtablename,
   rfieldname),
table_name = table_name,

field_name = field_name,
on_delete_action=field.ondelete)
else:
# make a guess here for circular references



Thank you for you time


суббота, 2 марта 2013 г., 21:17:27 UTC+6 пользователь Massimo Di Pierro 
написал:

 Fixed. please check it. Thanks Denes.

 On Saturday, 2 March 2013 06:12:31 UTC-6, DenesL wrote:

 It seems that the original code for keyed tables was wrongly patched at 
 some point in time.
 That part of the code should read:

   ftype = ftype + \
   types['reference FK'] % dict(
   constraint_name = constraint_name,
   foreign_key = '%s (%s)' % (rtablename,
  rfieldname),
   table_name = table_name,
   field_name = field_name,
   on_delete_action=field.ondelete)


 Denes.

 On Saturday, March 2, 2013 12:11:03 AM UTC-5, Dmitry Mosin wrote:

 Hi

 There is another exception

 type 'exceptions.KeyError' 'field_name'*File 
 /var/www/py/web2py/gluon/dal.py in create_table at line 811*

 806.
 807.
 808.
 809.
 810.
 811.

 812.
 813.
 814.
 815.

 ftype = ftype + \
 types['reference FK'] % dict(
 constraint_name = constraint_name, # 
 should be quoted
 foreign_key = '%s (%s)' % (rtablename,
rfieldname),
 on_delete_action=field.ondelete)

 else:
 # make a guess here for circular references
 if referenced in db:
 id_fieldname = db[referenced]._id.name




-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Reference field to string field in a keyed table. MSSQL

2013-03-01 Thread Dmitry Mosin


 Sorry, I misunderstood when you said:
 m_dsc_clients - is not a legacy table and defined in db.py, 

It's my fault, the explanation was a bit unclear.
 


 This line in dal.py is wrong (it was recently fixed in trunk):

  if rfieldname in hasattr(rtable,'_primarykey') \

 it should read:

 if rfieldname in rtable._primarykey \


 You can either update it manually or use latest trunk.


Thank you! 

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Reference field to string field in a keyed table. MSSQL

2013-03-01 Thread Dmitry Mosin
Hi

There is another exception

type 'exceptions.KeyError' 'field_name'*File 
/var/www/py/web2py/gluon/dal.py in create_table at line 811*

806.
807.
808.
809.
810.
811.

812.
813.
814.
815.

ftype = ftype + \
types['reference FK'] % dict(
constraint_name = constraint_name, # should 
be quoted
foreign_key = '%s (%s)' % (rtablename,
   rfieldname),
on_delete_action=field.ondelete)

else:
# make a guess here for circular references
if referenced in db:
id_fieldname = db[referenced]._id.name


-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Reference field to string field in a keyed table. MSSQL

2013-02-28 Thread Dmitry Mosin


 option 3 is the closest one since references between keyed tables *must* 
 use tablename.fieldname,
 but migrate=False should be added to each table unless it is specified in 
 the DB definition.

 A small clarification

m_dsc_cards - is a legacy table, it can't be changed,
of course 'migrate=False, fake_migrate=True' are set
a primary key is cardid, type is varchar(32)

m_dsc_clients - is not a legacy table and defined in db.py, 
and it must have a reference to m_dsc_cards by m_dsc_cards.cardid

The result of either an exception or the wrong type of field

How can I solve the point?

(sorry for bad english)

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Reference field to string field in a keyed table. MSSQL

2013-02-28 Thread Dmitry Mosin


*File /var/www/py/web2py/gluon/dal.py in create_table at line 772* 
 Function argument list 

(self=gluon.dal.MSSQLAdapter object, table=Table m_dsc_clients (...), 
migrate=True, fake_migrate=False, polymodel=None)
 Code listing 

767.
768.
769.
770.
771.
772.

773.
774.
775.
776.

if hasattr(table,'_primarykey'):
rtablename,rfieldname = referenced.split('.')
rtable = db[rtablename]
rfield = rtable[rfieldname]
# must be PK reference or unique
if rfieldname in hasattr(rtable,'_primarykey') \
or rfield.unique:

ftype = types[rfield.type[:9]] % \
dict(length=rfield.length)
# multicolumn primary key reference?
if not rfield.unique and len(rtable._primarykey)1:


-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Reference field to string field in a keyed table. MSSQL

2013-02-28 Thread Dmitry Mosin


 eyed tables can only reference (or be referenced by) other keyed tables.


But this table is keyed, isn't it?

db.define_table('m_dsc_
clients',
Field('cn','string'),
Field('cardid','reference m_dsc_cards'),
primarykey=['cn'],
)


-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Reference field to string field in a keyed table. MSSQL

2013-02-27 Thread Dmitry Mosin
Hello friends


There are a couple of legacy tables.
I try to create a reference between them.

= 1 == 
db.define_table('m_dsc_cards',
Field('cardid','string',notnull=True,unique=True),
primarykey=['cardid'],
)

db.define_table('m_dsc_clients',
Field('cn','string'),
Field('cardid','reference m_dsc_cards'),
)

class 'pyodbc.ProgrammingError' ('42000', [42000] [FreeTDS][SQL 
Server]Column 'm_dsc_cards.cardid' is not the same data type as referencing 
column 'm_dsc_clients.cardid' in foreign key 
'm_dsc_clients_cardid__constraint'. (1778) (SQLExecDirectW))



= 2 ==
db.define_table('m_dsc_cards',
Field('cardid','string',notnull=True,unique=True),
primarykey=['cardid'],
)

db.define_table('m_dsc_clients',
Field('cn','string'),
Field('cardid','reference m_dsc_cards.cardid'),
)

class 'pyodbc.ProgrammingError' ('42000', [42000] [FreeTDS][SQL 
Server]Foreign key 'm_dsc_clients_cardid__constraint' references invalid 
table 'm_dsc_cards.cardid'. (1767) (SQLExecDirectW))



= 3 ==
db.define_table('m_dsc_cards',
Field('cardid','string',notnull=True,unique=True),
primarykey=['cardid'],
)

db.define_table('m_dsc_clients',
Field('cn','string'),
Field('cardid','reference m_dsc_cards.cardid'),
primarykey=['cn'],
)

type 'exceptions.TypeError' argument of type 'bool' is not iterable


= 4 == 
db.define_table('m_dsc_cards',
Field('cardid','string',notnull=True,unique=True),
primarykey=['cardid'],
)

db.define_table('m_dsc_clients',
Field('cn','string'),
Field('cardid','reference m_dsc_cards'),
primarykey=['cn'],
)

Wow! no exception!
But... field has created with wrong type, INT instead of VARCHAR :(


-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: web2py SQLFORM widget autocomplete and cyrillic letters

2012-12-04 Thread Dmitry Mosin
Fixed in 2.2.1 (2012-12-03 18:01:57) stable.

Thank you, Massimo! 

-- 





[web2py] Re: web2py SQLFORM widget autocomplete and cyrillic letters

2012-11-30 Thread Dmitry Mosin
The ticket

http://code.google.com/p/web2py/issues/detail?id=1198

-- 





[web2py] Re: web2py SQLFORM widget autocomplete and cyrillic letters

2012-11-28 Thread Dmitry Mosin


 2) the encoding of the layout is not set to utf8.

Did you mean the  meta charset tag in the layout.html?
The layout.html taken from welcome app, and meta charset=utf-8 
Web2Py is 2.2.1

-- 





[web2py] web2py SQLFORM widget autocomplete and cyrillic letters

2012-11-27 Thread Dmitry Mosin
Hi there

I've stuck with a small problem with the subject.

There is a table with a fileld like this:
Field('author','reference auth_user',widget = 
SQLFORM.widgets.autocomplete(request, db.auth_user.cn, 
id_field=db.auth_user.id, limitby=(0,20), min_length=2), ondelete=no 
action,label='Автор'),

And there is a line in the controller:
form = SQLFORM(db.sometable)


Dropdown won't search cyrillic letters.
If I type %% in the input - it drops down all values, and I can select 
cyrillic value, and it succesfully gets into the table.

GET looks like
https://xxx.yyy.ru/default/new?_autocomplete_auth_user_cn=%u041C%u043E
and it returns nothing

But if I call it manually, like that
https://xxx.yyy.ru/default/new?_autocomplete_auth_user_cn=%D0%9C%D0%BE
it returns all suitable values.


How can I fix that?


Thanks in advance
(Sorry for bad English)

--