[web2py] Re: [OT] Ubuntu 12.10 will no longer ship with Python 2

2012-09-10 Thread Rakesh Singh
Arch Linux has switched to Python 3 as default for some time now and it's 
not much of a problem.
It all depends on how the Ubuntu packagers manage the change.
I expect things like wicd to break when Arch made the change, but 
everything worked smoothly.
For my scripts, I just make sure my python symlink to version 2 is always 
ahead in my path, so that #!/usr/bin/env python always gets v2.
Although I should also be changing them to call python2 for scripts that 
cannot switch to 3 yet.

 

-- 





[web2py] Re: framework benchmarks - web2py surprisingly slow?

2012-09-30 Thread Rakesh Singh
I've been playing with the Tornado web server recently, and it's quite 
impressive (size, performance and feature wise).
Although perhaps an overkill for web2py?

-- 





[web2py] Web2py.com Online Demo redirect error

2012-02-28 Thread Rakesh Singh
Hi all,

The Online Demo application on web2py.com generates an error in Firefox.

Error : The page isn't redirecting properly
  Firefox has detected that the server is redirecting the request 
for this address in a way that will never complete.
  This problem can sometimes be caused by disabling or refusing to 
accept
  cookies.

Browser : Firefox 10.0.2
Operating System : Arch Linux, Kernel 3.2.7

Other Browser tested : Opera 11.60
Result : Displays  "You are being redirected 
here" but does not follow. Clicking 
'here' returns back to the same display.

Thanks.

Regards,

Rakesh





[web2py:32193] Re: web2py + pyjamas desktop = a desktop framework?

2009-10-04 Thread Rakesh Singh

I mentioned Prism to Don.
I've been using it for a couple of weeks now.

"Prism is an application that lets users split web applications
out of their browser and run them directly on their desktop"

http://prism.mozilla.com/

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



[web2py] Menu links with target attribute

2018-06-07 Thread Rakesh Singh
Hello,

I have been trying to add external links to the menu system, but they 
result in malformed or invalid URL's when setting the target attribute.
There are some old posts in the group regarding this, but none of the 
suggestions have worked.

Web2py version : 2.16.1-stable

Example:
response.menu += [
('External Links', False, '#', [
('Icinga', False, URL('icinga'), []),
# Works
# SRC: Icinga
('Google', False, google, []),
# Works
# SRC: https://www.google.com";>Google

# Change target...
('', False, A('Icinga', _href=URL('icinga'), _target="_blank"), []),
# Does not work; Menu item displays "Icinga\n>"
# SRC: Icinga">
]
)
]


I have added a 'dirty' workaround in my layout.html that changes the target 
to '_blank' if the URL contains the string 'http'


  {{for _subitem in _item[3]:}}
  {{if _subitem[2].__contains__('http'):}}
{{_target = '_blank'}}
{{_rel = 'noopener'}}
  {{else:}}
{{_target = '_self'}}
{{_rel = 'preconnect '}}
  {{pass}}
  {{=_subitem[0]}}


Is there something incorrect in my code when specifying the target?

Thank you.


-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Menu links with target attribute

2018-06-09 Thread Rakesh Singh
I have tried to find the cause of this issue, and believe it occurs due to 
the fact that A is a subclass of DIV.
The ```isinstance(link, DIV)``` test then evaluates to True when ```link``` 
is an object of type A.
I could not find an option to change the behaviour of ```isinstance()``` 
and resorted to changing the following lines in html.py


diff --git a/gluon/html.py b/gluon/html.py
index 4adf287c..180f39a4 100644
--- a/gluon/html.py
+++ b/gluon/html.py
@@ -2526,14 +2526,16 @@ class MENU(DIV):
 ul.append(item)
 else:
 (name, active, link) = item[:3]
-if isinstance(link, DIV):
+if isinstance(link, DIV) and not isinstance(link, A):
 li = LI(link)
 elif 'no_link_url' in self.attributes and 
self['no_link_url'] == link:
 li = LI(DIV(name))
 elif isinstance(link, dict):
 li = LI(A(name, **link))
-elif link:
+elif link and not isinstance(link, A):
 li = LI(A(name, _href=link))
+elif link and isinstance(link, A):
+li = LI(name, link)
 elif not link and isinstance(name, A):
 li = LI(name)
 else:
(END)






On Thursday, 7 June 2018 11:55:05 UTC+2, Rakesh Singh wrote:
>
> Hello,
>
> I have been trying to add external links to the menu system, but they 
> result in malformed or invalid URL's when setting the target attribute.
> There are some old posts in the group regarding this, but none of the 
> suggestions have worked.
>
> Web2py version : 2.16.1-stable
>
> Example:
> response.menu += [
> ('External Links', False, '#', [
> ('Icinga', False, URL('icinga'), []),
> # Works
> # SRC:  href="/Rakesh_Singh/default/icinga">Icinga
> ('Google', False, google, []),
> # Works
> # SRC: https://www.google.com
> ">Google
>
> # Change target...
> ('', False, A('Icinga', _href=URL('icinga'), _target="_blank"), 
> []),
> # Does not work; Menu item displays "Icinga\n>"
> # SRC: Icinga">  
>   
> ]
> )
> ]
>
>
> I have added a 'dirty' workaround in my layout.html that changes the 
> target to '_blank' if the URL contains the string 'http'
>
> 
>   {{for _subitem in _item[3]:}}
>   {{if _subitem[2].__contains__('http'):}}
> {{_target = '_blank'}}
> {{_rel = 'noopener'}}
>   {{else:}}
> {{_target = '_self'}}
> {{_rel = 'preconnect '}}
>   {{pass}}
>target="{{=_target}}" rel="{{=_rel}}">{{=_subitem[0]}}
>
>
> Is there something incorrect in my code when specifying the target?
>
> Thank you.
>
>
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Smartgrid search for NULL values

2019-02-06 Thread Rakesh Singh
Hello,

I have been trying to search for entries using a smartgrid where a column 
is null.

users.email_address = "NULL"
users.email_address = 'NULL'
users.email_address = NULL
etc.

The result is always 0 records.
If I run the SQL on my SQL Client, I do get records.

ie.
select * 
from users 
where email_address is NULL;

Is there a way to retrieve these records using a Smartgrid search?

Thank you.


-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Web service calling controller function with argument

2015-07-09 Thread Rakesh Singh
Hello,

Please could you assist with the following issue.

I am attempting to create a web service, and have defined a function in 
default.py that accepts an argument.
I notice that whenever I define a function which requires an argument, it 
disappears from the the "exposes" list of default.py.

*Example1 that works.*

def count():
session.counter = (session.counter or 0) + 1
return dict(counter=session.counter, now=request.now)

default.py 

 exposes index , user 
, download 
, call 
, count 
Calling web service works fine.

*Example2 that does not work*

def count(id):
session.counter = (session.counter or 0) + 1
return dict(counter=session.counter, now=request.now)

default.py 

 exposes index , user 
, download 
, call 

Calling web service returns : 
invalid function (default/count)

Web2py 2.10.3-stable+timestamp.2015.04.02.21.42.07 running on Solaris 10

Any idea what I am missing?

Thank you.

Regards,

Rakesh



-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] RESOLVED: Web service calling controller function with argument

2015-07-09 Thread Rakesh Singh
Thank you, Stifan and Anthony



On Thursday, 9 July 2015 11:34:19 UTC+2, Rakesh Singh wrote:
>
> Hello,
>
> Please could you assist with the following issue.
>
> I am attempting to create a web service, and have defined a function in 
> default.py that accepts an argument.
> I notice that whenever I define a function which requires an argument, it 
> disappears from the the "exposes" list of default.py.
>
> *Example1 that works.*
>
> def count():
> session.counter = (session.counter or 0) + 1
> return dict(counter=session.counter, now=request.now)
>
> default.py 
> <https://sshipappldm1:8000/admin/peek/HiOnline/controllers/default.py?id=controllers__default__py>
>  exposes index <https://sshipappldm1:8000/>, user 
> <https://sshipappldm1:8000/user>, download 
> <https://sshipappldm1:8000/download>, call 
> <https://sshipappldm1:8000/call>, count <https://sshipappldm1:8000/count>
> Calling web service works fine.
>
> *Example2 that does not work*
>
> def count(id):
> session.counter = (session.counter or 0) + 1
> return dict(counter=session.counter, now=request.now)
>
> default.py 
> <https://sshipappldm1:8000/admin/peek/HiOnline/controllers/default.py?id=controllers__default__py>
>  exposes index <https://sshipappldm1:8000/>, user 
> <https://sshipappldm1:8000/user>, download 
> <https://sshipappldm1:8000/download>, call 
> <https://sshipappldm1:8000/call>
>
> Calling web service returns : 
> invalid function (default/count)
>
> Web2py 2.10.3-stable+timestamp.2015.04.02.21.42.07 running on Solaris 10
>
> Any idea what I am missing?
>
> Thank you.
>
> Regards,
>
> Rakesh
>
>
>
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: sub sub menu in newest version

2015-07-20 Thread Rakesh Singh
Hi

Apologies for resurrecting an old topic, but I have not used web2py in 
quite a while and found myself asking the same question.

The application I intend to create needs to have 3rd level menus (perhaps 
even 4th)
Without it, my menu structure will be a real mess and there would be no way 
to logically group menu items making it would be difficult for the user to 
even find the option.
(This is a large application!)
All users are PC users on the LAN/WAN, so we don't care about mobile 
support.
What would be the recommended way to implement this with the current web2py?

Thank you...



 

On Sunday, April 26, 2015 at 1:18:53 PM UTC+2, 黄祥 wrote:
>
> hi,
>
> i realize that web2py sub sub menu in newest version is not work as 
> expected (no error occured but the result is not expected).
> *models/menu.py*
> response.menu = [
> (T('Menu'), False, URL('default', 'index'), [
> (T('Sub Menu 1'), False, URL('default', 'index'), [
> (T('Sub Menu 2'), False, URL('default', 'index'), []),
> ]),
> ]), 
> ]
>
> *result in html browser*
> 
> 
> Sub Menu 1
> 
> 
> Sub Menu 2
> 
> 
> 
> 
>
> how can i have the sub sub menu in web2py newest version? the previous 
> version (bootstrap 2) is worked as expected
>
> thanks and best regards,
> stifan
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Oracle drivers.

2015-12-04 Thread Rakesh Singh
My guess is that this is a permission issue.
cx_Oracle may be accessible to Web2Py, but the Oracle libraries may be 
readable by your nginx user

What are the permissions your ORACLE_HOME directory and files within it?

/usr/include/oracle/11.1


On Wednesday, 7 October 2015 00:37:10 UTC+2, Michael M wrote:
>
> 2.12.3-stable+timestamp.2015.08.19.00.18.03
> (Running on Apache/2.4.16 (Fedora) OpenSSL/1.0.1k-fips mod_wsgi/4.4.8 
> Python/2.7.10, Python 2.7.10)
>
> So "import cx_Oracle" works in python console but when I tried using it in 
> web2py it errors out.  (Cannot import 
> module 'applications.test2.modules.cx_Oracle')
>
> the only thing i have found is that the file structure looks different 
> from cx_Oracle to another import i use.
>
> pysnmp works in web2py and straight python:
> >>> import pysnmp
> >>> pysnmp.__file__
> '/usr/lib/python2.7/site-packages/pysnmp/__init__.pyc'
>
> cx_Oracle doesnt work in web2py but works in py files.
> >>> import cx_Oracle
> >>> cx_Oracle.__file__
> '/usr/lib/python2.7/site-packages/cx_Oracle.so'
>
>
> the only difference I saw was that its a .so file instead of __init__.pyc
>
> Any thoughts.  Trying to get this to work in Fedora 22.  Thanks!
>
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Conditional Fields

2012-03-20 Thread Rakesh Singh
Hi All,

Apologies if this has been covered before but I cannot seem to find the
appropriate solution in the archives or in the web2py book.

I am using SQLFORM.grid to generate an interface into my table.
Some of my fields in the table are only required based on other inputs.
As a simple example, if the user is an individual, the Identity Number
field must be completed.
But if it is a business, the Company Registration Number field must be
completed.

I read the Conditional Field section in the book, but I cannot seem to get
it to work on my form.
Also, my table name and columns have quite a few underscores, so I'm not
sure if this is affecting the jQuery syntax.
eg. NCS_SARS_DECLARANT is the table, RECORD_TYPE is the column
If I understand correctly, I should have :
jQuery('#NCS_SARS_DECLARANT_RECORD_TYPE__row').hide() ?

What is the suggested way in achieving this?

Many thanks.

Regards,

Rakesh

Running Web2py Version 1.99.7


[web2py] Re: Conditional Fields

2012-03-21 Thread Rakesh Singh
Hi Richard,

My tables are pretty large (30-60 columns each), so let me use another
test table.

Let's say we have a table called survey.
If the user selects "Male" in the "Sex" field, "Favourite Car" and
"Favourite Sport" must not be empty.
"Favourite Perfume" and "Favourite Soapie" can be empty.
If the user selects "Female" then the opposite applies.

I was initially trying to hide the fields, and only unhide the
appropriate ones bases on the user input.
But it is not necessary. I don't mind displaying all fields, as long
as they are validated based on user input.


I initially tried SQLFORM.grid and smartgrid, but what I want to
achieve does not seem possible.
I thought of splitting the input form into multiple forms, but due to
the number of conditions, it won't be feasible to the user.

Thank you for any advice/suggestions.

Regards,

Rakesh


#-- TABLE DEFINITION
db.define_table('survey',
Field('fname',
'string',
length=25,
required=True,
requires=[IS_NOT_EMPTY(), IS_UPPER()],
label='First Name'),
Field('sname',
'string',
length=80,
required=True,
requires=[IS_NOT_EMPTY(), IS_UPPER()],
label='Surname'),
Field('sex',
'string',
length=1,
required=True,
requires=[IS_NOT_EMPTY(), IS_UPPER(), IS_IN_SET(['F', 'M'])],
label='Sex'),
Field('fav_perfume',
'string',
length=20,
required=False,
requires=IS_UPPER(),
label='Favourite Perfume'),
Field('fav_soapie',
'string',
length=20,
required=False,
requires=IS_UPPER(),
label='Favourite Soapie'),
Field('fav_car',
'string',
length=20,
required=False,
requires=IS_UPPER(),
label='Favourite Car'),
Field('fav_sport',
'string',
length=20,
required=False,
requires=IS_UPPER(),
label='Favourite Sport')
)



On Mar 20, 11:46 am, Richard Vézina 
wrote:
> We will need more code to help you...
>
> Regards
>
> Richard
>
> On Tue, Mar 20, 2012 at 10:15 AM, Rakesh Singh 
> wrote:
>
>
>
>
>
>
>
> > Hi All,
>
> > Apologies if this has been covered before but I cannot seem to find the
> > appropriate solution in the archives or in the web2py book.
>
> > I am using SQLFORM.grid to generate an interface into my table.
> > Some of my fields in the table are only required based on other inputs.
> > As a simple example, if the user is an individual, the Identity Number
> > field must be completed.
> > But if it is a business, the Company Registration Number field must be
> > completed.
>
> > I read the Conditional Field section in the book, but I cannot seem to get
> > it to work on my form.
> > Also, my table name and columns have quite a few underscores, so I'm not
> > sure if this is affecting the jQuery syntax.
> > eg. NCS_SARS_DECLARANT is the table, RECORD_TYPE is the column
> > If I understand correctly, I should have :
> > jQuery('#NCS_SARS_DECLARANT_RECORD_TYPE__row').hide() ?
>
> > What is the suggested way in achieving this?
>
> > Many thanks.
>
> > Regards,
>
> > Rakesh
>
> > Running Web2py Version 1.99.7


[web2py] Re: new feature in trunk: full auditing

2012-04-08 Thread Rakesh Singh
Hi,

I have received the same error as Tom on MySQL (5.5.22) when adding a user 
to the auth_user table via the Database Administration screen.
(1452, u'Cannot add or update a child row: a foreign key constraint fails)

Reverting back to "signature=False" resulted in an error  (Trace below) :

InternalError: (1025, u"Error on rename of './web2py_dev/#sql-415a_13' to 
'./web2py_dev/auth_user' (errno: 150)")


When using SQLite, you can use the database administrator to add a user 
without being logged in to your application.
With the MySQL connection, you must be logged in so that the 'Createed By' 
and 'Modified By' fields are correctly populated with a valid entry.

Once you register and login, the database administration tool can be used 
as normal.

Thanks

Rakesh


Traceback (most recent call last):
  File "/data/source/web2py_src/web2py/gluon/restricted.py", line 205, in 
restricted
exec ccode in environment
  File "/data/source/web2py_src/web2py/applications/web2py_test/models/db.py" 
, line 23, 
in 
auth.define_tables(username=True, signature=False)
  File "/data/source/web2py_src/web2py/gluon/tools.py", line 1356, in 
define_tables
format='%(username)s'))
  File "/data/source/web2py_src/web2py/gluon/dal.py", line 6621, in define_table
polymodel=polymodel)
  File "/data/source/web2py_src/web2py/gluon/dal.py", line 784, in create_table
fake_migrate=fake_migrate)
  File "/data/source/web2py_src/web2py/gluon/dal.py", line 883, in migrate_table
self.execute(sub_query)
  File "/data/source/web2py_src/web2py/gluon/dal.py", line 1446, in execute
return self.log_execute(*a, **b)
  File "/data/source/web2py_src/web2py/gluon/dal.py", line 1440, in log_execute
ret = self.cursor.execute(*a, **b)
  File "/data/source/web2py_src/web2py/gluon/contrib/pymysql/cursors.py", line 
108, in execute
self.errorhandler(self, exc, value)
  File "/data/source/web2py_src/web2py/gluon/contrib/pymysql/connections.py", 
line 184, in defaulterrorhandler
raise errorclass, errorvalue
InternalError: (1025, u"Error on rename of './web2py_dev/#sql-415a_13' to 
'./web2py_dev/auth_user' (errno: 150)")




On Sunday, 8 April 2012 17:04:14 UTC+2, Massimo Di Pierro wrote:
>
> Can you try again with mysql, delete the database and replace:
>
> auth.define_tables(signature=True)
> with
> auth.define_tables(signature=False)
>
> Does the problem does away? It looks like it does not like the self 
> reference in auth_user. 
>
> On Saturday, 7 April 2012 22:09:31 UTC-5, tomt wrote:
>>
>> Hi,
>>
>> I tried using your new versioning feature in trunk.
>> I created an app using a mysql database:
>> db = DAL('mysql://version:version@localhost/version')
>> When I used the admin function to define a new user
>> I received the following error:
>> 
>>  
>> (1452, u'Cannot add or update a child row: a foreign key constraint fails 
>> (`version/auth_user`, CONSTRAINT `auth_user_ibfk_1` 
>> FOREIGN KEY (`created_by`) REFERENCES `auth_user` (`id`) ON DELETE 
>> CASCADE)')
>> 
>>
>> I rebuilt the app to use sqlite instead of mysql:
>> db = DAL('sqlite://storage.sqlite')
>>
>> I was then able to add a user without the error
>>
>> I was using MySQL client version: 5.0.84
>>
>> - any suggestions?  - Tom
>>
>> On Thursday, April 5, 2012 4:16:04 PM UTC-6, Massimo Di Pierro wrote:
>>>
>>> This is how it works:
>>>
>>> # define auth 
>>> auth = Auth(db, hmac_key=Auth.get_or_create_key())
>>> auth.define_tables(username=True,signature=True)
>>>
>>> # define your own tables like
>>> db.define_table('mything',Field('name'),auth.signature)
>>>
>>> # than do:
>>> auth.enable_record_versioning(db)
>>>
>>> how does it work? every table, including auth_user will have an 
>>> auth.signature including created_by, created_on, modified_by, modified_on, 
>>> is_active fields. When a record of table mything (or any other table) is 
>>> modified, a copy of the previous record is copied into mything_archive 
>>> which references the current record. When a record is deleted, it is not 
>>> actually deleted but is_active is set to False, all records with 
>>> is_active==False are filtered out in searches except in appadmin.
>>>
>>> Pros:
>>> - your app will get full record archival for auditing purposes
>>> - could not be simpler. nothing else to do. Try with 
>>> SQLFORM.grid(db.mything) for example.
>>> - does not break references and there is no need for uuids
>>> - does not slow down searches because archive is done in separate 
>>> archive tables
>>>
>>> Cons:
>>> - uses lots of extra memory because every version of a record is stored 
>>> (it would be more efficient to store changes only but that would make more 
>>> difficult to do auditing).
>>> - slows down db(...).update(...) for multi record because it needs to 
>>> copy all records needing update from the original table to the archive 
>>>

Re: [web2py] Re: new feature in trunk: full auditing

2012-04-10 Thread Rakesh Singh
Hi Massimo,

Regarding the MySQL error,  re-created the database and started a new app 
with auth.signature=True

Here is the auth_user creation log on MySQL followed by the insert that 
generates the error :

CREATE TABLE auth_user(
id INT AUTO_INCREMENT NOT NULL,
first_name VARCHAR(128),
last_name VARCHAR(128),
email VARCHAR(255),
username VARCHAR(128),
password VARCHAR(255),
registration_key VARCHAR(255),
reset_password_key VARCHAR(255),
registration_id VARCHAR(255),
is_active CHAR(1),
created_on DATETIME,
created_by INT, INDEX created_by__idx (created_by), FOREIGN KEY 
(created_by) REFERENCES auth_user(id) ON DELETE CASCADE,
modified_on DATETIME,
modified_by INT, INDEX modified_by__idx (modified_by), FOREIGN KEY 
(modified_by) REFERENCES auth_user(id) ON DELETE CASCADE,
PRIMARY KEY(id)
) ENGINE=InnoDB CHARACTER SET utf8
3 QueryCOMMIT

  
INSERT INTO 
auth_user(username,first_name,last_name,modified_by,is_active,registration_id,created_by,
reset_password_key,created_on,modified_on,password,registration_key,email) 
VALUES ('rakesh','Rakesh','Singh',0,'T','',0,'','2012-04-10 
20:47:09','2012-04-10 20:47:09',
'0835d7189a6927648202bd9d8a8562a8','','rakeshsingh...@gmail.com')
6 QueryROLLBACK

Manually executing the insert returns:
ERROR 1452 (23000): Cannot add or update a child row: a foreign key 
constraint fails (`web2py_dev`.`auth_user`, CONSTRAINT `auth_user_ibfk_1` 
FOREIGN KEY (`created_by`) REFERENCES `auth_user` (`id`) ON DELETE CASCADE)


Which makes sense, since the value for created_by (and modified_by) 
defaults to 0 and that ID does not exist in auth_user.id
Modifying the created_by and modified_by values to NULL allows this record 
to be inserted.

Thank you for your help once again.

Regards,

Rakesh









>> On Tue, Apr 10, 2012 at 9:33 AM, Massimo Di Pierro <
>> massimo.dipie...@gmail.com> wrote:
>>
>>> Actually I was wrong. this is not the problem. Web2py does the right 
>>> thing. Is there any way you can look into the mysql logs what is the sql 
>>> string that causes the problem?
>>>
>>>
>>> On Tuesday, 10 April 2012 08:23:03 UTC-5, Massimo Di Pierro wrote:
>>>>
>>>> I figured this out. The table has a self reference and web2py inserts a 
>>>> zero in it instead of NULL. Works for sqlite but not MySQL.
>>>> Changing zero with NULL may be treated as a bug fix it will constitute 
>>>> a minor change of backward compatibility in case you incorrectly do 
>>>>
>>>> db(db.table.reference_field==**0).select()
>>>>
>>>> while the correct thing to do would be 
>>>>
>>>> db(~(db.table.reference_field>**0)).select() 
>>>>
>>>> I will try fix it and then will ask for comments.
>>>>
>>>> On Monday, 9 April 2012 18:29:10 UTC-5, tomt wrote:
>>>>>
>>>>> I have declared the table in db.py with auth.signature, and 
>>>>> uncommented auth.enable_record_versioning(**db), but the _archive 
>>>>> table isn't created.
>>>>>  - Tom
>>>>>
>>>>> On Monday, April 9, 2012 8:33:18 AM UTC-6, Massimo Di Pierro wrote:
>>>>>>
>>>>>> the signature=True only adds a signature to the auth_* tables so that 
>>>>>> if a user creates an account for another user or creates a group, you 
>>>>>> can 
>>>>>> keep track of who did it.
>>>>>>
>>>>>> The mything_archive table should be created by:
>>>>>>
>>>>>> auth.enable_record_versioning(**db)
>>>>>>
>>>>>> This should be called after the mything table is defined. Does it 
>>>>>> work?
>>>>>>
>>>>>> On Sunday, 8 April 2012 22:08:47 UTC-5, tomt wrote:
>>>>>>>
>>>>>>> Hi,
>>>>>>> Thanks for your response.  I deleted the database as you suggested 
>>>>>>> and changed signature=False.  The problem did go away and I was able to 
>>>>>>> add 
>>>>>>> users without the error.  
>>>>>>> I then reverted to signature=True.  While subsequent modifications 
>>>>>>> did show the signature, the 'mything_archive' was never created.
>>>>>>>
>>>>>>> - Tom
>>>>>>>
>>>>>>> On Sunday, April 8, 2012 9:04:14 AM UTC-6, Massimo 

Re: [web2py] Re: new feature in trunk: full auditing

2012-04-11 Thread Rakesh Singh
Thanks Massimo. Will do.
I'll test it against Oracle today as well.



On Wednesday, 11 April 2012 06:40:56 UTC+2, Massimo Di Pierro wrote:
>
> This helps a lot. WIll check this asap. To make sure I do not foget and it 
> tracked, plase open an issue in google code.
>
>
> On Tuesday, 10 April 2012 14:12:38 UTC-5, Rakesh Singh wrote:
>>
>> Hi Massimo,
>>
>> Regarding the MySQL error,  re-created the database and started a new app 
>> with auth.signature=True
>>
>> Here is the auth_user creation log on MySQL followed by the insert that 
>> generates the error :
>>
>> CREATE TABLE auth_user(
>> id INT AUTO_INCREMENT NOT NULL,
>> first_name VARCHAR(128),
>> last_name VARCHAR(128),
>> email VARCHAR(255),
>> username VARCHAR(128),
>> password VARCHAR(255),
>> registration_key VARCHAR(255),
>> reset_password_key VARCHAR(255),
>> registration_id VARCHAR(255),
>> is_active CHAR(1),
>> created_on DATETIME,
>> created_by INT, INDEX created_by__idx (created_by), FOREIGN KEY 
>> (created_by) REFERENCES auth_user(id) ON DELETE CASCADE,
>> modified_on DATETIME,
>> modified_by INT, INDEX modified_by__idx (modified_by), FOREIGN KEY 
>> (modified_by) REFERENCES auth_user(id) ON DELETE CASCADE,
>> PRIMARY KEY(id)
>> ) ENGINE=InnoDB CHARACTER SET utf8
>> 3 QueryCOMMIT
>>
>>   
>> INSERT INTO 
>> auth_user(username,first_name,last_name,modified_by,is_active,registration_id,created_by,
>> reset_password_key,created_on,modified_on,password,registration_key,email) 
>>
>> VALUES ('rakesh','Rakesh','Singh',0,'T','',0,'','2012-04-10 
>> 20:47:09','2012-04-10 20:47:09',
>> '0835d7189a6927648202bd9d8a8562a8','','rakeshsingh...@gmail.com')
>> 6 QueryROLLBACK
>>
>> Manually executing the insert returns:
>> ERROR 1452 (23000): Cannot add or update a child row: a foreign key 
>> constraint fails (`web2py_dev`.`auth_user`, CONSTRAINT `auth_user_ibfk_1` 
>> FOREIGN KEY (`created_by`) REFERENCES `auth_user` (`id`) ON DELETE CASCADE)
>>
>>
>> Which makes sense, since the value for created_by (and modified_by) 
>> defaults to 0 and that ID does not exist in auth_user.id
>> Modifying the created_by and modified_by values to NULL allows this 
>> record to be inserted.
>>
>> Thank you for your help once again.
>>
>> Regards,
>>
>> Rakesh
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>>> On Tue, Apr 10, 2012 at 9:33 AM, Massimo Di Pierro <
>>>> massimo.dipie...@gmail.com> wrote:
>>>>
>>>>> Actually I was wrong. this is not the problem. Web2py does the right 
>>>>> thing. Is there any way you can look into the mysql logs what is the sql 
>>>>> string that causes the problem?
>>>>>
>>>>>
>>>>> On Tuesday, 10 April 2012 08:23:03 UTC-5, Massimo Di Pierro wrote:
>>>>>>
>>>>>> I figured this out. The table has a self reference and web2py inserts 
>>>>>> a zero in it instead of NULL. Works for sqlite but not MySQL.
>>>>>> Changing zero with NULL may be treated as a bug fix it will 
>>>>>> constitute a minor change of backward compatibility in case you 
>>>>>> incorrectly 
>>>>>> do 
>>>>>>
>>>>>> db(db.table.reference_field==**0).select()
>>>>>>
>>>>>> while the correct thing to do would be 
>>>>>>
>>>>>> db(~(db.table.reference_field>**0)).select() 
>>>>>>
>>>>>> I will try fix it and then will ask for comments.
>>>>>>
>>>>>> On Monday, 9 April 2012 18:29:10 UTC-5, tomt wrote:
>>>>>>>
>>>>>>> I have declared the table in db.py with auth.signature, and 
>>>>>>> uncommented auth.enable_record_versioning(**db), but the _archive 
>>>>>>> table isn't created.
>>>>>>>  - Tom
>>>>>>>
>>>>>>> On Monday, April 9, 2012 8:33:18 AM UTC-6, Massimo Di Pierro wrote:
>>>>>>>>
>>>>>>>> the signature=True only adds a signature to the auth_* tables so 
>>>>>>>> that if a user creates an account for another user or creates a 

[web2py] ORA-00910 on table creation

2012-04-23 Thread Rakesh Singh
Hi,

I am having a lot of trouble implementing on Oracle.
When I run my app on SQLite or MySQL, but I am having lots of different
errors on Oracle.
One problem I have is that when an error is returned, the application hangs.
I can view the admin app and browse the error ticket, but the thread that
is doing the database operation seems to hang. I have to kill -9 and
restart.

My 1st table created correctly, but my 2nd gave me errors with floats, so I
changed to decimal and finally integer, but I still get errors.
Again, on sqlite and MySQL, it works perfectly, so I'm not sure where the
problem could be.

What I haven't done on the 2nd table is used the "requires" validators as
the user may not have all the required information during the capturing
process.


Error : DatabaseError: ORA-00910: specified length too long for its datatype

Traceback


Traceback (most recent call last):
  File "/data/source/dtos/web2py/gluon/restricted.py", line 205, in
restricted
exec ccode in environment
  File "/data/source/dtos/web2py/applications/dtos/models/db.py", line 470,
in 
label='Start Date'),
  File "/data/source/dtos/web2py/gluon/dal.py", line 6320, in define_table
polymodel=polymodel)
  File "/data/source/dtos/web2py/gluon/dal.py", line 633, in create_table
precision, scale = map(int,field.type[8:-1].split(','))
ValueError: invalid literal for int() with base 10: ''




Here is my model :

db.define_table('DT_SARS_DECLARANT',
Field('SECTION_ID',
'string',
length=1,
default='B',
required=True,
requires=[IS_UPPER(), IS_NOT_EMPTY()],
label='Section Identifier'),
Field('RECORD_TYPE',
'string',
length=6,
default='DD',
required=True,
#requires=[IS_UPPER(), IS_ALPHANUMERIC(), IS_NOT_EMPTY()],
requires=[IS_UPPER(), IS_ALPHANUMERIC()],
label='Record Type'),
Field('RECORD_STATUS',
'string',
length=2,
default='N',
required=True,
requires=[IS_UPPER(), IS_NOT_EMPTY()],
label='Record Status',
comment='''Indicates the status of the record, whether it is
a new record, an adjusted record or a record that must be deleted
from the declaration.'''),
Field('UNIQUE_NUM',
'string',
required=True,
requires=[IS_UPPER(), IS_ALPHANUMERIC(), IS_NOT_EMPTY()],
label='Unique Number',
comment='''The submitting entity’s system will have a unique
identifier for each record. This is the number that must be entered
into this field.'''),
Field('ROW_NUMBER',
'integer',
required=True,
requires=IS_INT_IN_RANGE(0, 99),
label='Row Number',
comment='''A sequential number to indicate the row number
in the file.'''),
Field('TRANS_DUE_DATE',
'date',
required=True,
requires=IS_DATE(),
label='Transaction Due Date',
comment='This is the due date of the transactionthat pertains to
this record.'),
Field('DIV_DECLARANT',
'string',
length=1,
required=True,
requires=[IS_NOT_EMPTY(), IS_UPPER()],
label='Divident Declarant',
comment='Indicates if the entity submitting the file also declared
the dividend for this record.'),
# @TODO, There is a field that is missing in the Excel sheet.
# Confirmation if this is not required, else, it will go here...
Field('NATURE',
'string',
length=33,
required=True,
requires=[IS_UPPER(), IS_NOT_EMPTY()],
label='Dividend Declarant: Nature Of Person',
comment='The type/category of the divident declarant.'),
Field('REG_NAME',
'string',
length=150,
required=True,
requires=[IS_UPPER(), IS_NOT_EMPTY()],
label='Dividend Declarant: Registered Name',
comment='The name of the divident declarant.'),
Field('TRADE_NAME',
'string',
length=150,
required=True,
requires=[IS_UPPER(), IS_NOT_EMPTY()],
label='Trading Name',
comment='The name the devidend declaring entity is trading.'),
Field('REG_NUM',
'string',
length=15,
required=False,
requires=[IS_UPPER(), IS_ALPHANUMERIC()],
label='Registration Number',
comment='The registration number of the divedent declaring
entity.'),
Field('ISIN_NUM',
'string',
length=12,
required=False,
requires=[IS_UPPER(), IS_ALPHANUMERIC()],
label='ISIN Number',
comment='The international security identification number.'),
# @TODO The following Income Tax number field is marked 'On Announcemnt.
# Confirmation required is this field is to be included. Is is for
now...
Field('INC_TAX_NUM',
'integer',
required=False,
requires=IS_INT_IN_RANGE(),
label='Income Tax Reference Number',
comment='The entity\'s 

Re: [web2py] ORA-00910 on table creation

2012-04-24 Thread Rakesh Singh
Thank you Richard.
I shall try your suggestions this morning.


On Monday, 23 April 2012 17:12:36 UTC+2, Richard wrote:
>
> Also, since you have a lot of column, you may start with fewer column and 
> identify the exact column that trigger the error.
>
> I will be easier to help you with simpler model, you then can generalize 
> after we had found the problem.
>
> Richard
>
> On Mon, Apr 23, 2012 at 11:10 AM, Richard Vézina <
> ml.richard.vez...@gmail.com> wrote:
>
>> It should not be the problem, but to make sure you set not null at the 
>> backend level you need : notnull=True if I remember.
>>
>> Richar
>>
>>
>> On Mon, Apr 23, 2012 at 10:40 AM, Rakesh Singh 
>> wrote:
>>
>>> Hi,
>>>
>>> I am having a lot of trouble implementing on Oracle.
>>> When I run my app on SQLite or MySQL, but I am having lots of different 
>>> errors on Oracle.
>>> One problem I have is that when an error is returned, the application 
>>> hangs.
>>> I can view the admin app and browse the error ticket, but the thread 
>>> that is doing the database operation seems to hang. I have to kill -9 and 
>>> restart.
>>>
>>> My 1st table created correctly, but my 2nd gave me errors with floats, 
>>> so I changed to decimal and finally integer, but I still get errors.
>>> Again, on sqlite and MySQL, it works perfectly, so I'm not sure where 
>>> the problem could be.
>>>
>>> What I haven't done on the 2nd table is used the "requires" validators 
>>> as the user may not have all the required information during the capturing 
>>> process.
>>>
>>>
>>> Error : DatabaseError: ORA-00910: specified length too long for its 
>>> datatype
>>>
>>> Traceback
>>>  
>>>
>>> Traceback (most recent call last):
>>>   File "/data/source/dtos/web2py/gluon/restricted.py", line 205, in 
>>> restricted
>>> exec ccode in environment
>>>   File "/data/source/dtos/web2py/applications/dtos/models/db.py", line 
>>> 470, in 
>>> label='Start Date'),
>>>   File "/data/source/dtos/web2py/gluon/dal.py", line 6320, in 
>>> define_table
>>> polymodel=polymodel)
>>>   File "/data/source/dtos/web2py/gluon/dal.py", line 633, in create_table
>>> precision, scale = map(int,field.type[8:-1].split(','))
>>> ValueError: invalid literal for int() with base 10: ''
>>>
>>>
>>>
>>>
>>> Here is my model :
>>>
>>> db.define_table('DT_SARS_DECLARANT',
>>> Field('SECTION_ID',
>>> 'string',
>>> length=1,
>>> default='B',
>>> required=True,
>>> requires=[IS_UPPER(), IS_NOT_EMPTY()],
>>> label='Section Identifier'),
>>> Field('RECORD_TYPE',
>>> 'string',
>>> length=6,
>>> default='DD',
>>> required=True,
>>> #requires=[IS_UPPER(), IS_ALPHANUMERIC(), IS_NOT_EMPTY()],
>>> requires=[IS_UPPER(), IS_ALPHANUMERIC()],
>>> label='Record Type'),
>>> Field('RECORD_STATUS',
>>> 'string',
>>> length=2,
>>> default='N',
>>> required=True,
>>> requires=[IS_UPPER(), IS_NOT_EMPTY()],
>>> label='Record Status',
>>> comment='''Indicates the status of the record, whether it is 
>>> a new record, an adjusted record or a record that must be 
>>> deleted 
>>> from the declaration.'''),
>>> Field('UNIQUE_NUM',
>>> 'string',
>>> required=True,
>>> requires=[IS_UPPER(), IS_ALPHANUMERIC(), IS_NOT_EMPTY()], 
>>> label='Unique Number',
>>> comment='''The submitting entity’s system will have a unique 
>>> identifier for each record. This is the number that must be 
>>> entered 
>>> into this field.'''),
>>> Field('ROW_NUMBER',
>>> 'integer',
>>> required=True,
>>> requires=IS_INT_IN_RANGE(0, 99),
>>> label='Row Num

Re: [web2py] ORA-00910 on table creation

2012-04-24 Thread Rakesh Singh
I've reduced the number of columns on the second table and I did not get an 
error starting up.
But then I started getting errors on the first table after I changed a 
column.
It seems to occur whenever I modify the database layout in any way.
I also see that I am generating a bunch of weird triggers each time (before 
web2py deadlocks)

I am a bit worried about using Oracle at this stage - but it is the 
'standard' database in the organisation.
Maybe I should create the tables, triggers and sequences manually as I have 
to complete dev by Thursday and I'm already a day behind :-)
Other option may be to finish development on MySQL or sqlite and only move 
to Oracle when 100% complete.

The trigger names are all resemble the name BIN$vlh/Lcs+QAbgQwqTAUZABg==$0
create or replace
TRIGGER "BIN$vlh/Lcs+QAbgQwqTAUZABg==$0" BEFORE INSERT ON 
BIN$vlh/Lcs/QAbgQwqTAUZABg==$0 FOR EACH ROW BEGIN SELECT 
auth_permission_sequence.nextval INTO :NEW.id FROM DUAL; END;

My current error is as follows.
 'unique_num'
I changed UNIQUE_NUM by removing required=True and got the error.

Traceback (most recent call last):
  File "/data/source/dtos/web2py/gluon/restricted.py", line 205, in restricted
exec ccode in environment
  File "/data/source/dtos/web2py/applications/dtos/models/db.py" 
<http://localhost:8000/admin/default/edit/dtos/models/db.py>, line 251, in 

comment='The amount of tax paid to SARS in respect of In Specie dividends.')
  File "/data/source/dtos/web2py/gluon/dal.py", line 6320, in define_table
polymodel=polymodel)
  File "/data/source/dtos/web2py/gluon/dal.py", line 742, in create_table
fake_migrate=fake_migrate)
  File "/data/source/dtos/web2py/gluon/dal.py", line 797, in migrate_table
and not isinstance(table[key].type, SQLCustomType) \
  File "/data/source/dtos/web2py/gluon/dal.py", line 6714, in __getitem__
return dict.__getitem__(self, str(key))
KeyError: 'unique_num'





On Tuesday, 24 April 2012 09:24:10 UTC+2, Rakesh Singh wrote:
>
> Thank you Richard.
> I shall try your suggestions this morning.
>
>
> On Monday, 23 April 2012 17:12:36 UTC+2, Richard wrote:
>>
>> Also, since you have a lot of column, you may start with fewer column and 
>> identify the exact column that trigger the error.
>>
>> I will be easier to help you with simpler model, you then can generalize 
>> after we had found the problem.
>>
>> Richard
>>
>> On Mon, Apr 23, 2012 at 11:10 AM, Richard Vézina <
>> ml.richard.vez...@gmail.com> wrote:
>>
>>> It should not be the problem, but to make sure you set not null at the 
>>> backend level you need : notnull=True if I remember.
>>>
>>> Richar
>>>
>>>
>>> On Mon, Apr 23, 2012 at 10:40 AM, Rakesh Singh >> > wrote:
>>>
>>>> Hi,
>>>>
>>>> I am having a lot of trouble implementing on Oracle.
>>>> When I run my app on SQLite or MySQL, but I am having lots of different 
>>>> errors on Oracle.
>>>> One problem I have is that when an error is returned, the application 
>>>> hangs.
>>>> I can view the admin app and browse the error ticket, but the thread 
>>>> that is doing the database operation seems to hang. I have to kill -9 and 
>>>> restart.
>>>>
>>>> My 1st table created correctly, but my 2nd gave me errors with floats, 
>>>> so I changed to decimal and finally integer, but I still get errors.
>>>> Again, on sqlite and MySQL, it works perfectly, so I'm not sure where 
>>>> the problem could be.
>>>>
>>>> What I haven't done on the 2nd table is used the "requires" validators 
>>>> as the user may not have all the required information during the capturing 
>>>> process.
>>>>
>>>>
>>>> Error : DatabaseError: ORA-00910: specified length too long for its 
>>>> datatype
>>>>
>>>> Traceback
>>>>  
>>>>
>>>> Traceback (most recent call last):
>>>>   File "/data/source/dtos/web2py/gluon/restricted.py", line 205, in 
>>>> restricted
>>>> exec ccode in environment
>>>>   File "/data/source/dtos/web2py/applications/dtos/models/db.py", line 
>>>> 470, in 
>>>> label='Start Date'),
>>>>   File "/data/source/dtos/web2py/gluon/dal.py", line 6320, in 
>>>> define_table
>>>> polymodel=polymodel)
>>>>   File "/data/source/dtos/web2py/gluon/dal.py", line 633,

[web2py] Re: Strange import problem

2012-05-01 Thread Rakesh Singh
I had a similar issue with another application some time back.
Eventually I found this article and moved my imports around which resolved 
my issue :

http://codingrecipes.com/python-importerror-cannot-import-name-x

Hope that helps you.





On Tuesday, 1 May 2012 06:06:51 UTC+2, Bruce Wade wrote:
>
>
> applications/advertisement/modules/util.py
> from gluon import *
>
> def make_page_breadcrumbs(page_breadcrumbs_items):   
> page_breadcrumbs_items_buffer = [ DIV(SPAN("", 
> _class="breadcrumbs-arrow"),SPAN(crumb)) for crumb in 
> page_breadcrumbs_items ]
> return DIV(page_breadcrumbs_items_buffer)
>
> def make_page_title(page_title, icon):
> return SPAN(IMG(_src=icon), H6(page_title))
>
> class pageIcon:
> UNION = "/advertisement/static/images/union_icon_55x55.png"
>
> controllers/union.py
> def index():
> from util import make_page_title
> ...
>
> Error:
>
> Traceback (most recent call last):
>
>   File 
> "/home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/restricted.py", 
> line 205, in restricted
>
> exec ccode in environment
>
>   File 
> "/home/bruce/Development/bossteam_dev/projects/yaw_dev/applications/advertisement/controllers/union.py"
>  , line 
> 346, in 
>
>   File 
> "/home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/globals.py", 
> line 173, in 
>
> self._caller = lambda f: f()
>
>   File 
> "/home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/tools.py", line 
> 2575, in f
>
> return action(*a, **b)
>
>   File 
> "/home/bruce/Development/bossteam_dev/projects/yaw_dev/applications/advertisement/controllers/union.py"
>  , line 
> 5, in index
>
> from util import make_page_title
>
> ImportError: cannot import name make_page_title
>
> I have no idea why in the world this is happening, any suggestions?
> -- 
> -- 
> Regards,
> Bruce Wade
> http://ca.linkedin.com/in/brucelwade
> http://www.wadecybertech.com
> http://www.fittraineronline.com - Fitness Personal Trainers Online
> http://www.warplydesigned.com
>
>  

[web2py] Re: V 2.2.1 linked_tables broken in smartgrid?

2012-12-01 Thread Rakesh Singh
Hi,

I also removed "db.table.column.readable = False" to enable the column to 
be displayed in the smartgrid.
However, when searching the linked column for a value in the smartgrid, an 
error is encountered :

 invalid literal for int() with base 10: 'JHB'

In this case, JHB was the value I searched for. Using its numeric ID worked 
and displayed the correct result.

Will the fix in trunk also address this issue?

Many thanks


Rakesh


-- 





[web2py] Re: V 2.2.1 linked_tables broken in smartgrid?

2012-12-04 Thread Rakesh Singh
Hi 

Apologies for the delayed response.

The workaround suggested by the OP has worked in displaying the referenced 
column.
My 2nd query may be un-related to this thread so I will post separately.


Thanks

Rakesh

-- 





[web2py] Smartgrid searching a referenced column

2012-12-04 Thread Rakesh Singh
Hi,

I am having an issue querying a referenced column using the smartgrid
search widget.

Let's say I have a table defined as follows:

db.define_table('countries',
Field('country_name', 'string', unique=True, required=True),
format='%(country_name)s')

Data
1  Austria
2  Brazil
5  China etc.

The second table is as follows:

db.define_table('users',
Field('user_name', 'string'),
Field('country', db.countries))

db.users.country.writeable = False


The controller is as follows:

def user_list():
grid = SQLFORM.smartgrid(db.users, linked_tables=['db.countries'])
return dict(grid=grid)


Using the grid search function, click on the Search field, and select
Country from the drop down field.
Choose = 'China' and Add.
This will result in an error. You would have to search for the numeric ID,
5 in this case.
(Incidentally, the same will occur if you choose ID form the dropdown, but
search for a string instead of a numeric')
 invalid literal for int() with base 10:
'BOT'So the question is :
- As in the example, what is the correct way to search for all users from
China?
- Any way to prevent an error if a user enters a string where a numeric is
expected in the search?

NB. I typed in the above code directly into the email, so there may be
typos.

Thanks a lot.

Regards,

Rakesh

-- 





Re: [web2py] Re: Smartgrid searching a referenced column

2012-12-05 Thread Rakesh Singh
Thanks guys.
>
>
> https://groups.google.com/forum/?fromgroups=#!topic/web2py/xN0813r58N
>
> Tried to look at this thread, but the topic ID seems to be invalid or no 
longer available.
But no worries, I was just checking if I was doing something incorrectly.

Thanks again.

Regards,

Rakesh


--