[web2py] Re: Grid export csv

2016-08-04 Thread Kostas M

As you said, it works again now, by setting: entity_quoting=False

Thanks Niphlod!

-- 
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: Grid export csv

2016-08-01 Thread Kostas M
I have the same problem with the CSV, HTML, TSV export buttons. The Ticket 
for the CSV is pasted below. The problem at least with the csv export 
button seems to be with the REGEX_TABLE_DOT_FIELD. Normally, this constant 
is defined in regex.py as:

REGEX_TABLE_DOT_FIELD = re.compile('^(\w+)\.([^.]+)$')

and previous web2py versions used it.

However, now it takes the REGEX_TABLE_DOT_FIELD definition from the base.py:

obj.REGEX_TABLE_DOT_FIELD = re.compile(
r'^' + quot % regex_ent + r'\.' + quot % regex_ent + r'$')


which is a totally different regex and it doesn't much with the table field 
names...


Ticket ID 

127.0.0.1.2016-08-01.14-36-35.a05a56c8-5b22-42c3-a3e3-385322b5f0fe
 Version 
web2py™ Version 2.14.5-stable+timestamp.2016.04.14.03.26.16 
Python Python 2.7.6: /home/kmouts/Envs/prolims2_venv/bin/python2.7 (prefix: 
/home/kmouts/Envs/prolims2_venv) Traceback 

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.

Traceback (most recent call last):
  File "/home/kmouts/PycharmProjects/prolims2/web2py/gluon/restricted.py", line 
227, in restricted
exec ccode in environment
  File 
"/home/kmouts/PycharmProjects/prolims2/web2py/applications/prolims2/controllers/muser.py"
 , line 
187, in 
  File "/home/kmouts/PycharmProjects/prolims2/web2py/gluon/globals.py", line 
417, in 
self._caller = lambda f: f()
  File "/home/kmouts/PycharmProjects/prolims2/web2py/gluon/tools.py", line 
4258, in f
return action(*a, **b)
  File 
"/home/kmouts/PycharmProjects/prolims2/web2py/applications/prolims2/controllers/muser.py"
 , line 
49, in my_analyses
exportclasses=dict(csv_with_hidden_cols=False, tsv_with_hidden_cols=False)
  File "/home/kmouts/PycharmProjects/prolims2/web2py/gluon/sqlhtml.py", line 
3102, in smartgrid
user_signature=user_signature, **kwargs)
  File "/home/kmouts/PycharmProjects/prolims2/web2py/gluon/sqlhtml.py", line 
2473, in grid
raise HTTP(200, oExp.export(), **response.headers)
  File "/home/kmouts/PycharmProjects/prolims2/web2py/gluon/sqlhtml.py", line 
3514, in export
self.rows.export_to_csv_file(s, represent=True)
  File 
"/home/kmouts/Envs/prolims2_venv/local/lib/python2.7/site-packages/pydal/objects.py",
 line 2446, in export_to_csv_file
row.append(record._extra[col])
  File 
"/home/kmouts/Envs/prolims2_venv/local/lib/python2.7/site-packages/pydal/objects.py",
 line 91, in __getattr__
raise AttributeError
AttributeError


-- 
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: web2py Complete Reference Manual

2015-04-03 Thread Kostas M
+1

By the way, is there a time frame for the 6th edition?

-- 
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: Web2py Rocks ... Again :)

2014-07-04 Thread Kostas M


+1

-- 
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: wiki_page.render problem after update to 2.6.4

2013-10-01 Thread Kostas M

Ok I sorted it out:

A new column has been added at the wiki_page table, and so *migrate *should 
be set to *True*, at least at the first time after the upgrade as to get 
DAL to change the table schema...


>
>

-- 
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/groups/opt_out.


[web2py] wiki_page.render problem after update to 2.6.4

2013-10-01 Thread Kostas M
I have this function in my controller:
def help():
return 
auth.wiki(render='markmin',menu_groups=['wiki_editor'],manage_permissions
=True)
and I have created some wiki pages.


After updating to 2.6.4 (from 2.5.1), I am getting this Ticket. How it 
could be fixed??
Error ticket for myapp Ticket ID 

10.31.1.23.2013-10-01.15-48-35.5897c826-3166-4256-a2ae-8bb92eb32a6b
 no such column: wiki_page.render Version  
web2py™ Version 2.6.4-stable+timestamp.2013.09.22.01.43.37  Python Python 
2.6.6: /usr/bin/python (prefix: /usr)  Traceback 

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.

Traceback (most recent call last):
  File "/opt/web-apps/web2py/gluon/restricted.py", line 217, in restricted
exec ccode in environment
  File "/opt/web-apps/web2py/applications/prolims/models/menu.py" 
,
 line 80, in 
wikimenu = Wiki(auth).menu(controller="utils", function="help")
  File "/opt/web-apps/web2py/gluon/tools.py", line 5706, in menu
menu_page = db.wiki_page(slug='wiki-menu')
  File "/opt/web-apps/web2py/gluon/dal.py", line 8579, in __call__
return self._db(query).select(limitby=(0,1),for_update=for_update, 
orderby=orderby, orderby_on_limitby=False).first()
  File "/opt/web-apps/web2py/gluon/dal.py", line 10071, in select
return adapter.select(self.query,fields,attributes)
  File "/opt/web-apps/web2py/gluon/dal.py", line 2301, in select
return super(SQLiteAdapter, self).select(query, fields, attributes)
  File "/opt/web-apps/web2py/gluon/dal.py", line 1748, in select
return self._select_aux(sql,fields,attributes)
  File "/opt/web-apps/web2py/gluon/dal.py", line 1713, in _select_aux
self.execute(sql)
  File "/opt/web-apps/web2py/gluon/dal.py", line 1833, in execute
return self.log_execute(*a, **b)
  File "/opt/web-apps/web2py/gluon/dal.py", line 1827, in log_execute
ret = self.cursor.execute(command, *a[1:], **b)
OperationalError: no such column: wiki_page.render

-- 
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/groups/opt_out.


[web2py] Restful Services & Book

2013-09-03 Thread Kostas M
  
According to: 
http://web2py.com/books/default/chapter/29/10/services#Restful-Web-Services, 
for the given controller api() the following example should be working:

$ curl -d "name=Tim" http://127.0.0.1:8000/myapp/default/api/friend.json
{"errors": {}, "id": 1}


   1. The first line I think it should be: 
  - 
  
  '$ curl -d "name=Tim" 
http://127.0.0.1:8000/myapp/default/api/*person*.json'
  
  - as the *parse_as_rest *of the example applies only to the GET 
  requests.
  - The respond from '$ curl -d "name=Tim" 
  http://127.0.0.1:8000/myapp/default/api/friend.json' is '400 BAD REQUEST'
  2. The response from the insertion of a new record after issuing the 
   (1) is: 'errorsid' instead of ' {"errors": {}, "id": 1}'. The creation 
   of the new record is OK, but the 'return locals()' from the POST definition 
   seems to bring only the keys as a response. Is there something broken?
   
I use the web2py Version: 2.5.1-stable+timestamp.2013.06.06.15.39.19



-- 

--- 
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: How to limit record readability to only auth_user creator?

2013-08-05 Thread Kostas M
This grid indicates that db.auth_user has a 'created_by' column. Is this 
your case?
Anyway, trying your code at a different table having a 'created_by' column 
worked fine to me (buttons Edit and Delete are there).



On Sunday, August 4, 2013 5:17:40 AM UTC+1, Alex Glaros wrote:
>
> This looks like it should work, using grid, but the "edit" button doesn't 
> appear. only the view button.
>
> @auth.requires_login() 
> def manage_user_profile(): 
> is_owner = (lambda row: row.created_by == auth.user_id) if auth.user 
> else False
> grid = SQLFORM.grid(db.auth_user.id == auth.user_id, 
> editable=is_owner,create=False, deletable=is_owner, user_signature=True), 
> return dict(grid=grid) 
>  
>

-- 

--- 
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: impersonate any user

2013-06-17 Thread Kostas M
Just for the record, these two issues have been fixed at the latest 
revision.

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

-- 

--- 
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: impersonate any user

2013-04-11 Thread Kostas M
Even worse, the impersonate action is never logged in the auth_event.

It seems that in the impersonate definition (tools.py), the self.log_event 
is not reached, due to the callback above it, which is a
redirect_after_login ..
It seems like a bug to me. 


if onaccept:
form = Storage(dict(vars=self.user))
if not isinstance(onaccept,(list, tuple)):
onaccept = [onaccept]
for callback in onaccept:
*callback(form)*
log = self.messages.impersonate_log
self.log_event(log, dict(id=current_id, other_id=auth.user.id))

if the logging action goes directly after the onaccept evaluation, the 
impersonation logging works properly:
if onaccept:
*log = self.messages.impersonate_log
self.log_event(log, dict(id=current_id, other_id=auth.user.
id))*
form = Storage(dict(vars=self.user))
if not isinstance(onaccept,(list, tuple)):
onaccept = [onaccept]
for callback in onaccept:
callback(form)

And here is the correct logging (auth_event), after moving up those 2 lines 
of code:
*"id", "time_stamp", "client_ip", "user_id", "origin", "description"*
"84", "2013-04-11 12:26:41", "127.0.0.1", "9", "auth", "User 9 Logged-in"
"85", "2013-04-11 12:27:10", "127.0.0.1", "7", "auth", "User 9 is 
impersonating 7"

On Wednesday, April 10, 2013 5:07:54 PM UTC+1, Kostas M wrote:
>
> Is the reversion back to the initial user working properly?
>
> I can impersonate a user, entering a user id in the 
> http://.../user/impersonate form, 
> but when I go back to that form, and entering 0 , although it seems 
> momentarily to change the user name greeting in the upper right of the app,
> if I go to the http://.../user/profile or anywhere else, still the 
> impersonated user appears.
>
> Have anyone noticed this behaviour?
>
>
> On Tuesday, April 19, 2011 10:30:47 PM UTC+1, Massimo Di Pierro wrote:
>>
>> First at some point do 
>>
>> gid = auth.add_group('impersonators') 
>> auth.add_permission(gid,'impersonate','auth_user') 
>> auth.add_membership(gid,your_authuser_id) 
>>
>> then just visit 
>>
>> http://.../user/impersonate 
>>
>> and it prompt you a form about which user you want to impersonate. 0 
>> for reverting back to yourself. 
>>
>>
>>

-- 

--- 
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: impersonate any user

2013-04-10 Thread Kostas M
Is the reversion back to the initial user working properly?

I can impersonate a user, entering a user id in the 
http://.../user/impersonate form, 
but when I go back to that form, and entering 0 , although it seems 
momentarily to change the user name greeting in the upper right of the app,
if I go to the http://.../user/profile or anywhere else, still the 
impersonated user appears.

Have anyone noticed this behaviour?


On Tuesday, April 19, 2011 10:30:47 PM UTC+1, Massimo Di Pierro wrote:
>
> First at some point do 
>
> gid = auth.add_group('impersonators') 
> auth.add_permission(gid,'impersonate','auth_user') 
> auth.add_membership(gid,your_authuser_id) 
>
> then just visit 
>
> http://.../user/impersonate 
>
> and it prompt you a form about which user you want to impersonate. 0 
> for reverting back to yourself. 
>
>
>

-- 

--- 
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] Edit only specific fields from a Table

2013-03-26 Thread Kostas M
I have extended the auth_user table with an extra field:
auth.settings.extra_fields['auth_user']=[
 Field('isactive','boolean', default
=True,
   readable=False, writable=
False),
 ]
And I would like a web page listing only specific fields:
def lab_managers():
dba = db.auth_user
dba.islm.readable=dba.islm.writable=True
grid=SQLFORM.grid((dba.isactive==True),
  fields=[dba.username, dba.isactive],
  deletable=False,
  onvalidation=enter_user
  )
return dict(grid=grid)
where enter_user is a function checking and entering a user in respect to 
Ldap directories.

Now, I would like the 'Add' and the 'Edit' functions to present to the user 
only the 2 fields 'username' and 'isactive'. Not all the Fields of the 
auth_user table. 
Is this possible?




-- 

--- 
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 appadmin bad to use,is there appadmin easy to use? linke the django admin

2013-03-14 Thread Kostas M
I have found web2admin very useful, especially looking at the way actions 
are implemented in the first column of the table grid.

-- 

--- 
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: smartgrid selectable comments

2013-02-26 Thread Kostas M
Niphlod thank you very much for your reply.

I implemented the 2nd option you mentioned, using jquery to add a textarea 
in the  tags. In the controller, I use the request.vars.textareaname 
to retrieve the contents of the
textarea and then I insert them into the proper table. Just a thought: Are 
the request.vars.textareaname contents sanitized or should I take some 
extra measures?

>
>

-- 

--- 
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] smartgrid selectable comments

2013-02-22 Thread Kostas M
I have implemented an SQLFORM.smartgrid with a selectable lambda function 
for handling the rows the user has selected. The proper
action for the selected rows, is again selected by the user through an 
'actions' pulldown menu on the first column of the table's header.

What I would like next, is a comments textarea below the smartgrid, where 
the user can add some comments on the action he is performing.
Since smartgrid is a form on its own, with its Submit button etc, which is 
the recommended way to add and handle this comments box in the produced 
smartgrid form?


-- 

--- 
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] Uploaded files, and Cascade delete

2013-01-30 Thread Kostas M
It seems that cascade deletion of uploaded files works fine only if there 
is no definition of 'uploadfolder'.

At db.py
db.define_table('person',
Field('name', requires=IS_NOT_EMPTY(), required=True),
Field('nickname', 'string', required=True  ),
format = '%(name)s'
)

def define_folder_name():
up_folder =  os.path.join(request.folder,'uploads')
if request.args(1)=='files.person' and request.args(2):
up_folder =  os.path.join(up_folder, 
db.person(request.args(2)).nickname 
)
return up_folder
db.define_table('files',
Field('person',db.person,label='Analysis Request',
  ondelete='CASCADE', required=True, writable=False,
  represent=lambda anID,row: db.person(anID).nickname  
  ),
Field('myfile','upload',length=100, required=True,autodelete
=True,
  uploadfolder=define_folder_name(), 
  uploadfield=True, # keeps file in folders, not into 
 DB blogs
  label='File',
  ),
Field('description','text', required=True, label=
'Description',
  ),
)

At default.py:
def test():
grid = SQLFORM.smartgrid(db.person, linked_tables=['files'] )
return dict(grid=grid)

If a user is created, let's say: name='Tom' and nickname='Tom',
and a file is uploaded to his 'files', then a directory Tom is being 
created under 'uploads' dir.
If we now delete the user Tom pressing the 'Delete' button, the records are 
removed by the database form tables person and files, but the 
uploads/Tom/files.myfile..bin
is still there.

If we define the upload field 'myfile' without the uploadfolder attribute, 
then the file is deleted properly from the general 'uploads' directory.


-- 

--- 
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.




Re: [web2py] Re: SQLFORM.grid callbacks

2013-01-16 Thread Kostas M
OK, thanks, I think I have cleared up now how it goes.


>>>
>>>

-- 





Re: [web2py] Re: SQLFORM.grid callbacks

2013-01-15 Thread Kostas M
OK fine, then why, in continuation of the above example,

def test():
grid = SQLFORM.smartgrid(db.person, linked_tables=['dog'], ondelete=dict
( dog=ondelete_test ))
return dict(grid=grid)

def ondelete_test(table_involved, id_of_the_deleted_record):
print table_involved
print id_of_the_deleted_record


ondelete=dict( dog=ondelete_test ) doesn't fire  (nothing is printed, one 
dog row is removed but on refresh is back), 
while 
ondelete=ondelete_test   does fire, prints the values, and removes 
permantly the rows

ondelete doesn't belong to both grid and smartgrid? Or this is a bug?


On Tuesday, January 15, 2013 1:30:12 AM UTC, Massimo Di Pierro wrote:
>
> The rule is simple. All options that belong to both grid and smartgrid 
> (except args) can take a dictionary in smartgrid. If a dictionary is 
> passed, the value is passed the grid, in correspondance to a key == 
> tablename.
>
>
>

-- 





Re: [web2py] Re: SQLFORM.grid callbacks

2013-01-14 Thread Kostas M

Fantastic! 
And since we are on the topic, can we clarify also the use of dictionaries 
for the callbacks in the case of smartgrid? Which options can take a dict 
of functions, and which not? E.g. it seems ondelete can't take a 
dictionary, while editable can:

grid=SQLFORM.smartgrid(db.person,linked_tables=['dog'],
editable=dict(person=person_edit, dog=dog_edit),
)




-- 





[web2py] Re: SQLFORM.smartgrid create callback

2013-01-14 Thread Kostas M

Awesome!
(and I will keep repeating the mantra in my mind =) )

>
>

-- 





[web2py] Re: SQLFORM.smartgrid create callback

2013-01-14 Thread Kostas M
Thanks for the clarification.

In my case, I have two tables:


db.define_table('analyses',Field('info'),Field('status')
db.define_table('samples',db.analyses,Field('sample_info')


and I use:

grid=SQLFORM.smartgrid(db.analyses,linked_tables=['samples'])

I want when the status of an Analysis is 'Submitted', the user to
not be able to create new, edit, or delete the submitted samples of an
Analysis. So,I am using the callback functions for the SQLFORM.smartgrid 
options of

editable and deletable, to control these options, eg:

deletable=dict(analyses=is_open, samples=is_open),

Since create is not a callback,
how, could I control whether the 'Add' button at Samples should be 
available,
only if the parent Analysis has not yet been submitted?

-- 





Re: [web2py] Re: SQLFORM.grid callbacks

2013-01-14 Thread Kostas M

Editable and deletable are functionalities also provided by *grid though*...
On Monday, January 14, 2013 7:45:45 PM UTC, Derek wrote:
>
> ondelete is functionality provided by *grid* and not *smartgrid*. So the 
> documentation for *grid* applies, not the documentation for *smartgrid*.
>>
>>
>>

-- 





Re: [web2py] Re: SQLFORM.grid callbacks

2013-01-14 Thread Kostas M
Sorry, I don't understand what you mean.

*ondelete* isn't supposed to take dictionaries in smartgrid, as editable and 
deletable do?



On Monday, January 14, 2013 7:32:21 PM UTC, Derek wrote:
>
> You must have missed this part:
>
> The smartgrid takes the same arguments as a grid and some more with some 
> caveats:
>
>

-- 





Re: [web2py] Re: SQLFORM.grid callbacks

2013-01-14 Thread Kostas M
The exact 
phraseis:
  "All the arguments but the table, 
args, linked_tables and user_signatures can be dictionaries as explained 
below."


What book are you looking at? I can't find that phrase anywhere in the book.
>
>
>>>

-- 





[web2py] SQLFORM.smartgrid create callback

2013-01-14 Thread Kostas M
I have a hard time with these grid/smartgrid callbacks. Now regarding the 
'create' option:

If I put grid = SQLFORM.smartgrid(db.mytable,  ,create=False), then 
correctly, the '+Add' button doesn't appear on the web application.
But if I put a lambda callback there:
grid = SQLFORM.smartgrid(db.mytable,  ,create=lambda row:False)
the 'Add' button appears!

-- 





[web2py] DAL _after_delete vs _before_delete

2013-01-14 Thread Kostas M
According to the book, in the DAL chapter, subtitle: 'before and after 
callbacks', we can use:

>>> db.person._before_delete.append(lambda s: pprint(s))
>>> db.person._after_delete.append(lambda s: pprint(s))
where: 
s is the Set object used for update or delete.

However,
def person_before_delete(s): #s a Set object
anid=s.select()[0].name

def person_after_delete(s): #s a Set object 
anid=s.select()[0].name

The first function, actually can get this name value, whereas the second 
cannot. In the second case, the
len(s.select()) returns 0 rows. Is this the expected behaviour?
I need the 'name' value of the deleted row, for some further actions, and now I 
am using both "_before_delete"
to get the value I want and set some global variable in my db.py, and then 
"_after_delete" to trigger an update
function of the actual count of the persons left, using the stored global 
variable. But this way, doesn't look
so right to me.


-- 





Re: [web2py] Re: SQLFORM.grid callbacks

2013-01-14 Thread Kostas M

What I have found out  about not firing at all is that in SQLFORM.smartgrid,
ondelete and oncreate callbacks should not be dictionaries!

Although the book says: "All the arguments but the table, args, 
linked_table and user_signatures can be dictionaries ..'',
and in my case e.g: 
deletable=dict(analyses=is_open, samples=is_open),
works fine, if I declare:
ondelete=dict( samples=my_sample_delete )
doesn't fire the event. Whereas, 

ondelete=my_sample_delete


fires it, and prints a sample message...

>
>
>

-- 





Re: [web2py] Re: SQLFORM.grid callbacks

2013-01-14 Thread Kostas M
I still have problems with the SQLFORM.smartgrid callbacks. I don't 
understand what is the correct usage of these functions. There are many 
different conflicting examples in the wiki.

I define my ondelete callback:

ondelete=dict( samples=my_sample_delete )

and  I define the function:

def my_sample_delete():
print "In callback"  

Is this the correct format for the arguments of ' my_sample_delete'?. Why I 
never get this print message in the web2py console? How could I debug this 
function? The book says, it takes no arguments. In other posts, I have seen 
it as :

def my_sample_delete(table, record_id):

Either way, clicking the 'Delete' button, the row disappears, but having a 
browser refresh, the deleted line appears again! 

What is the problem?

(I am using now trunk Version 2.4.1-alpha.2+timestamp.2013.01.13.13.14.47, 
since the last correction on the ajax Delete function was recently fixed by 
Niphod I think)
)


-- 





Re: [web2py] Re: SQLFORM.grid callbacks

2013-01-13 Thread Kostas M
Sorry about the duplicate posts...  It seems they have been posted on the 
mails, but still not appearing on the web interface... 



> I got all four copies, fwiw.
>
>
>

-- 





[web2py] SQLFORM.grid callbacks

2013-01-11 Thread Kostas M
I see there are many questions on the workings of ondelete and oncreate 
callbacks of the grid and smartgrid, but I can't find a valid answer.
The book says that all but ondelete take a form object as input.
Searching for answers in web2py-user topics such as:

*grid/smartgrid ondelete issue*
*Re: [web2py] Re: SQLFORM.smartgrid oncreate,ondelete not firing* .  
Here a format of: def myondelete(table, row_id):... is advised. But then 
why the book doesn't mention the ondelete other arguments, i.e. table and 
row_id?
*Examples for SQLFORM.grid oncreate, onupdate, ondelete* Here an 
example is given for a oncreate function, which still doesn't seem to fire 
in my case. Having some 'print' inside these callbacks, doesn't produce 
anything for some reason...

The code at sqlhtml.py (1928 line) is:

elif deletable and len(request.args) > 2 and request.args[-3] == 
'delete':
table = db[request.args[-2]]
if ondelete:
ondelete(table, request.args[-1])
ret = db(table[table._id.name] == request.args[-1]).delete()
which doesn't have any:

request.args[-3] == 'delete'

Still, if I don't define an ondelete function, the row is deleted properly 
by pressing the 'Delete' button. If I do declare a ondelete callback, the
row again is removed from the interface, but having a refresh, the 
'deleted' line is back on!

In my case the link that the Delete button is pointing to is:
http://127.0.0.1:8000/lims/default/my_analyses/analyses/samples.analysis/1?_signature=dfc73167259232e58a520cbf7a60d8d52e783fbb#null

Which I think is wrong, because it is the same for my listed samples. E.g. 
All the links of the Delete buttons point to the same direction!!
However the adjacent Edit button (e.g. for sample 4) is pointing to:
http://127.0.0.1:8000/lims/default/my_analyses/analyses/samples.analysis/1/edit/samples/8?_signature=55fe76676f0c1f9f97ee30d710af231e317d8b3e
Which is different for every Edit button of my rows.

 
It would be great, If someone could provide some clear explanation, and a 
working example, of the ondelete and the oncreate callbacks...

-- 





[web2py] SQLFORM.grid callbacks

2013-01-11 Thread Kostas M
I see there are many questions on the workings of ondelete and oncreate 
callbacks of the grid and smartgrid, but I can't find a valid answer.
The book says that all but ondelete take a form object as input.
Searching for answers in web2py-users topics such as:


   - *grid/smartgrid ondelete issue*
   - *Re: [web2py] Re: SQLFORM.smartgrid oncreate,ondelete not firing*.  
Here a format of: def myondelete(table, row_id):... is advised. But then 
   why the book doesn't mention the ondelete other arguments, i.e. table and 
   row_id?
   - *Examples for SQLFORM.grid oncreate, onupdate, ondelete* Here an 
   example is given for a oncreate function, which still doesn't seem to fire 
   in my case. Having some 'print' inside these callbacks, doesn't produce 
   anything for some reason...
   

The code at sqlhtml.py (1928 line) is:

elif deletable and len(request.args) > 2 and request.args[-3] == 
'delete':
table = db[request.args[-2]]
if ondelete:
ondelete(table, request.args[-1])
ret = db(table[table._id.name] == request.args[-1]).delete()


which doesn't have any:

request.args[-3] == 'delete'



Still, if I don't define an ondelete function, the row is deleted properly 
by pressing the 'Delete' button. If I do declare a ondelete callback, the
row again is removed from the interface, but having a refresh, the 
'deleted' line is back on!

In my case the link that the Delete button is pointing to is:
http://127.0.0.1:8000/lims/default/my_analyses/analyses/samples.analysis/1?_signature=dfc73167259232e58a520cbf7a60d8d52e783fbb#null

Which I think is wrong, because it is the same for my listed samples. E.g. 
All the links of the Delete buttons point to the same direction!!
However the adjacent Edit button (e.g. for sample 4) is pointing to:
http://127.0.0.1:8000/lims/default/my_analyses/analyses/samples.analysis/1/edit/samples/8?_signature=55fe76676f0c1f9f97ee30d710af231e317d8b3e
Which is different for every Edit button of my rows.

 
It would be great, If someone could provide some clear explanation, and a 
working example, of the ondelete and the oncreate callbacks...

-- 





[web2py] SQLFORM.grid ondelete and other callbacks

2013-01-11 Thread Kostas M
(This is the 3rd time I am trying to post this question. For some reason 
the message was deleted. Is using links in the message considered harmful?)

I see there are many questions on the workings of ondelete and oncreate 
callbacks of the grid and smartgrid, but I can't find a valid answer.
The book says that all but ondelete take a form object as input.
Searching for answers in web2py-users topics with titles:


   - *grid/smartgrid ondelete issue*
   -* Re: [web2py] Re: SQLFORM.smartgrid oncreate,ondelete not firing *.  
   Here a format of: def myondelete(table, row_id):... is advised. But then 
   why the book doesn't mention the ondelete other arguments, i.e. table and 
   row_id?
   - *Examples for SQLFORM.grid oncreate, onupdate, ondelete* Here an 
   example is given for a oncreate function, which still doesn't seem to fire 
   in my case. Having some 'print' inside these callbacks, doesn't produce 
   anything for some reason...
   

The code at sqlhtml.py (1928 line) is:

elif deletable and len(request.args) > 2 and request.args[-3] == 
'delete':
table = db[request.args[-2]]
if ondelete:
ondelete(table, request.args[-1])
ret = db(table[table._id.name] == request.args[-1]).delete()


which doesn't have any:

request.args[-3] == 'delete'



Still, if I don't define an ondelete function, the row is deleted properly 
by pressing the 'Delete' button. If I do declare a ondelete callback, the
row again is removed from the interface, but having a refresh, the 
'deleted' line is back on!

In my case the link that the Delete button is pointing to is:
http://127.0.0.1:8000/lims/default/my_analyses/analyses/samples.analysis/1?_signature=dfc73167259232e58a520cbf7a60d8d52e783fbb#null

Which I think is wrong, because it is the same for my listed samples. E.g. 
All the links of the Delete buttons point to the same direction!!
However the adjacent Edit button (e.g. for sample 4) is pointing to:
http://127.0.0.1:8000/lims/default/my_analyses/analyses/samples.analysis/1/edit/samples/8?_signature=55fe76676f0c1f9f97ee30d710af231e317d8b3e
Which is different for every Edit button of my rows.

 
It would be great, If someone could provide some clear explanation, and a 
working example, of the ondelete and the oncreate callbacks...

-- 





[web2py] SQLFORM.grid callbacks

2013-01-11 Thread Kostas M

I see there are many questions on the workings of ondelete and oncreate 
callbacks of the grid and smartgrid, but I can't find a valid answer.
The book says that all but ondelete take a form object as input.
Searching for answers in web2py-users topics:


   - *grid/smartgrid ondelete issue*
   - *Re: [web2py] Re: SQLFORM.smartgrid oncreate,ondelete not firing *.  
   Here a format of: def myondelete(table, row_id):... is advised. But then 
   why the book doesn't mention the ondelete other arguments, i.e. table and 
   row_id?
   - *Examples for SQLFORM.grid oncreate, onupdate, ondelete* Here an 
   example is given for a oncreate function, which still doesn't seem to fire 
   in my case. Having some 'print' inside these callbacks, doesn't produce 
   anything for some reason...
   

The code at sqlhtml.py (1928 line) is:

elif deletable and len(request.args) > 2 and request.args[-3] == 
'delete':
table = db[request.args[-2]]
if ondelete:
ondelete(table, request.args[-1])
ret = db(table[table._id.name] == request.args[-1]).delete()


which doesn't have any:

request.args[-3] == 'delete'



Still, if I don't define an ondelete function, the row is deleted properly 
by pressing the 'Delete' button. If I do declare a ondelete callback, the
row again is removed from the interface, but having a refresh, the 
'deleted' line is back on!

In my case the link that the Delete button is pointing to is:
http://127.0.0.1:8000/lims/default/my_analyses/analyses/samples.analysis/1?_signature=dfc73167259232e58a520cbf7a60d8d52e783fbb#null

Which I think is wrong, because it is the same for my listed samples. E.g. 
All the links of the Delete buttons point to the same direction!!
However the adjacent Edit button (e.g. for sample 4) is pointing to:
http://127.0.0.1:8000/lims/default/my_analyses/analyses/samples.analysis/1/edit/samples/8?_signature=55fe76676f0c1f9f97ee30d710af231e317d8b3e
Which is different for every Edit button of my rows.

 
It would be great, If someone could provide some clear explanation, and a 
working example, of the ondelete and the oncreate callbacks...

-- 





[web2py] Is there a problem posting questions?

2013-01-11 Thread Kostas M
I have tried 4 times to post a question here regarding SQLFORM.grid, and 
everytime I got a message 'The post was deleted'

What is going on?

-- 





[web2py] grid ondelete callback

2013-01-11 Thread Kostas M
I see there are many questions on the workings of *ondelete* and 
*oncreate*callbacks of the grid and smartgrid, but I can't find a valid answer.
The book says that all but *ondelete* take a form object as input. 
Searching for answers in:

   - grid/smartgrid ondelete 
issue
   - 
   
Re:
 
   [web2py] Re: SQLFORM.smartgrid oncreate,ondelete not firing .  
   
Here
 
   a format of: def myondelete(table, row_id):... is advised. But then why 
   the book doesn't mention the ondelete other arguments, i.e. table and 
   row_id?
   - Examples for SQLFORM.grid oncreate, onupdate, 
ondeleteHere
 an example is given for a oncreate function, which still doesn't seem 
   to fire in my case. Having some 'print' inside these callbacks, doesn't 
   produce anything for some reason...
   

The code at sqlhtml.py (1928 line) is:

elif deletable and len(request.args) > 2 and request.args[-3] == 
'delete':
table = db[request.args[-2]]
if ondelete:
ondelete(table, request.args[-1])
ret = db(table[table._id.name] == request.args[-1]).delete()

which doesn't have any:

> request.args[-3] == 'delete'

Still, if I don't define an ondelete function, the row is deleted properly 
by pressing the 'Delete' button. If I do declare a *ondelete* callback, the
row again is removed from the interface, but having a refresh, the 
'deleted' line is back on!

In my case the link that the Delete button is pointing to is:
http://127.0.0.1:8000/lims/default/my_analyses/analyses/samples.analysis/1?_signature=dfc73167259232e58a520cbf7a60d8d52e783fbb#null

Which I think is wrong, because it is the same for my listed samples. E.g. 
All the links of the Delete buttons point to the same direction!!
However the adjacent Edit button (e.g. for sample 4) is pointing to:
http://127.0.0.1:8000/lims/default/my_analyses/analyses/samples.analysis/1/edit/samples/8?_signature=55fe76676f0c1f9f97ee30d710af231e317d8b3e
Which is different for every Edit button of my rows.

 
It would be great, If someone could provide some clear explanation, and a 
working example, of the *ondelete* and the *oncreate* callbacks...

 

-- 





[web2py] SQLFORM.grid and smartgrid ondelete callbacks and etc.

2013-01-11 Thread Kostas M
I see there are many questions on the workings of *ondelete* and 
*oncreate*callbacks of the grid and smartgrid, but I can't find a valid answer.
The book says that all but *ondelete* take a form object as input.
Searching for answers in:

   - grid/smartgrid ondelete 
issue


   - Re: [web2py] Re: SQLFORM.smartgrid oncreate,ondelete not firing 
   
.
  
   Here a format of: def myondelete(table, row_id):... is advised. But then 
   why the book doesn't mention the ondelete other arguments, i.e. table and 
   row_id?


   - Examples for SQLFORM.grid oncreate, onupdate, 
ondeleteHere
 an example is given for a oncreate function, which still doesn't seem 
   to fire in my case. Having some 'print' inside these callbacks, doesn't 
   produce anything for some reason...


The code at sqlhtml.py (1928 line) is:

elif deletable and len(request.args) > 2 and request.args[-3] == 
'delete':
table = db[request.args[-2]]
if ondelete:
ondelete(table, request.args[-1])
ret = db(table[table._id.name] == request.args[-1]).delete()


which doesn't have any:

request.args[-3] == 'delete'



Still, if I don't define an *ondelete* function, the row is deleted 
properly by pressing the 'Delete' button. If I do declare a *ondelete*callback, 
the
row again is removed from the interface, but having a refresh, the 
'deleted' line is back on!

In my case the link that the Delete button is pointing to is:
http://127.0.0.1:8000/lims/default/my_analyses/analyses/samples.analysis/1?_signature=dfc73167259232e58a520cbf7a60d8d52e783fbb#null

Which I think is wrong, because it is the same for all my listed samples. 
E.g. All the links of the Delete buttons point to the same direction!!
However the adjacent Edit button (e.g. for sample 4) is pointing to:
http://127.0.0.1:8000/lims/default/my_analyses/analyses/samples.analysis/1/edit/samples/8?_signature=55fe76676f0c1f9f97ee30d710af231e317d8b3e
Which is different for every Edit button of my rows.

 
It would be great, If someone could provide some clear explanation, and a 
working example, of the *ondelete* and the *oncreate* callbacks...

-- 





[web2py] Re: Merry Christmas everybody!

2012-12-25 Thread Kostas M

+1

-- 





[web2py] Re: The book updates and status

2012-12-22 Thread Kostas M

IMHO, as I have said previously, it would be nice if the markmin to PDF 
converter produced comparable layouts/fonts to the online version of the 
book... The printed book, up to now, misses a lot of the pleasant and 
appealing layout of the online version.

-- 





Re: [web2py] Re: No module named plural_rules, end emtpy db in DAL connection

2012-12-20 Thread Kostas M
The same warning appears:

In [1]: from gluon.dal import DAL,Field
WARNING:root:Unable to import plural rules: No module named plural_rules


>>
>>
>>

-- 





Re: [web2py] Re: No module named plural_rules, end emtpy db in DAL connection

2012-12-19 Thread Kostas M
Thank you both, for the heads up!

As Niphlod have said at:
https://groups.google.com/forum/#!searchin/web2py/auto_import=True/web2py/bwCYiQcE59I/D1IkGFC55eEJ
   * Remember that DAL does NOT introspect databases.*

Any hints on the Warning?




-- 





[web2py] No module named plural_rules, end emtpy db in DAL connection

2012-12-19 Thread Kostas M
Trying to use DAL in my functional_tests.py (sitting in the application 
directory), I get the following warning:

In [1]: from gluon import DAL
WARNING:root:Unable to import plural rules: No module named plural_rules

Furthermore, the db seems to be empty, although it has proper tables, as 
seen by Sqliteman.
"test.sqlite" is a copy from the storage.sqlite 'normal' database.
For instance:

In [9]: db = DAL('sqlite://test.sqlite', folder='databases', 
migrate_enabled=False)

In [10]: db.tables
Out[10]: []

What am I doing wrong?

-- 





[web2py] Re: Passing an environment variable to wep2py

2012-12-18 Thread Kostas M

Thank you Massimo for the response.

os.environ["WEB2PY_USE_DB_TESTING"]= "1"   

is the correct way to set env. variables, and "modification of os.environ 
affect both the running program and subprocesses created by Python" (Python 
essential reference 4th ed.).

In my case after all, both ways are succeeding in transferring env 
variables to the models: either through passing a --config=MYCONFIG, or 
setting them in the setUP methods of unittest.TestCase subclasses. The 
problems were in the 'if' evaluation for the first case, and a restart of 
the shell in the second.. I chose finally the second method, as it does not 
create one more file (e.g. MYCONFIG.py) in the directories, and keeps the 
setting definition near where it belongs: at the unittest.TestCase 
construction.

-- 





[web2py] Passing an environment variable to wep2py

2012-12-17 Thread Kostas M
I am trying  to set up an environment variable (lets say 
"WEB2PY_USE_DB_TESTING"), so that in my db.py:

if not os.environ.get("WEB2PY_USE_DB_TESTING",None):
db = DAL('sqlite://storage.sqlite')
else:
db = DAL('sqlite://../fts/testdb.sqlite')

(as this resource points out:  
http://ncdegroot.blogspot.ca/2011/09/web2py-automate-unittesting-doctesting.html)

I want to set this variable by script, only when I run my functional tests.

So I have tried up to now:


   1. class FunctionalTest(unittest.TestCase):
   
   @classmethod
   def setUpClass(self):
   os.environ["WEB2PY_USE_DB_TESTING"]= "1"
   self.web2py = start_web2py_server()
   self.browser = webdriver.Firefox()
   self.browser.implicitly_wait(5)
   2. running web2py with --config=MYCONFIG, where MYCONFIG.py has:

import os
os.environ["WEB2PY_USE_DB_TESTING"]= "1"



Both methods fail to transfer the environment variable to the shell that 
web2py runs... Any suggestions?

-- 





[web2py] Re: IS_IN_DB Referencing Label

2012-12-13 Thread Kostas M

Thanks a lot Anthony! I think this should go to the book's documentation.

-- 





[web2py] IS_IN_DB Referencing Label

2012-12-13 Thread Kostas M
I have a table Lab_members:
db.define_table('lab_members', 
Field('member',db.auth_user,
  represent=lambda member,row: str(member.username)
),
)

and now I create a second table, having a Field:
Field('member',db.lab_members,label='Lab member',
  represent=lambda member,row: 
db.auth_user(member).username,
  
requires=IS_IN_DB(db((db.lab_members.lab==auth.user_id)),
field='lab_members.member', 
label='%(member)s',
)

My problem is, how to set the label in the IS_IN_DB validator, as to 
display in the dropdown list the usernames and not the user.id ?
After the selection, the usernames are displayed properly (through the 
represent function of the field).

Is there any solution?

-- 





[web2py] Re: Default value for reference type

2012-12-12 Thread Kostas M
Massimo thank you for your response.
Unfortunately, I have not the traceback now, since I chose to build a 
separate table, not referring to db.auth_group. This
is a kind of duplication in regards to auth_group, but it makes simple the 
handling of my lab_members table:

db.define_table('lab_members', 
Field('lab',label='Lab Name',
  default= auth.user_id and auth.user.username,
  writable=False,
  ),
Field('member',unique=True,requires=IS_NOT_EMPTY()),
)

The strange thing in this case again, is the :
default= auth.user_id and auth.user.username,
which I have taken from an older answer of yours:

https://groups.google.com/forum/?fromgroups=#!searchin/web2py/Re:$20Record$20Versioning/web2py/e55el7q_-kk/XkG1hN5w9VYJ

If i run my application on -S appname mode,  having just: "default= 
auth.user.username,", this error comes back:
Traceback (most recent call last):
  File "/home/kmouts/web2py/gluon/restricted.py", line 212, in restricted
exec ccode in environment
  File "applications/lims/models/db.py", line 140, in 
default= auth.user.username,
AttributeError: 'NoneType' object has no attribute 'username'

So it seems a check has to be made first if a current user exists (by 
auth.user_id )and then to try to get the attribute username from auth.user.

-- 





[web2py] Default value for reference type

2012-12-11 Thread Kostas M
I try to define a lab_members table:

from gluon import current
current.auth = auth

db.define_table('lab_members', 
Field('lab', db.auth_group, label='Lab Name',
  represent=lambda id,row: str(row.role)+' Lab',
  default=db.auth_group(current.auth.user_id)  ),
Field('member',db.auth_user'),
)

But the default value doesn't work. I have tried also the "default= 
auth.user_group(auth.user_id)" with no luck either.
What I would like to have, is the  lab field pre-completed with the current 
user group, and to be writable=False.

The error is: 
 unsupported operand type(s) for %: 'bool' and 
'Row'


If I put "default= db.auth_group(2),writable=False," there is no error, and 
a user group is selected in the drop-down selection, but it is still 
selectable by the user.


Any hints?

-- 





[web2py] Re: Very simple issue: redirect on login - auth.settings.login_next

2012-12-06 Thread Kostas M
Peter, I agree with you 100% regarding the ambiguous documentation, and the 
lost time back and forth, among google searches and source code reading...  
I am one of them!

Kostas

 

> 'These must point to the URL you want to redirect your users to after the 
> various possible auth actions (in case there is no referrer): '
>
> This is an example of documentation that can only be understood by the 
> person who wrote it, or other people who already know the answer.
>
> I expect everyone new to this expects setting auth.setting.register_next 
> to a URL will cause the redirection. They all then find out  the hard way 
> it does not work. Trawl through the forums and try various things until 
> coming up with a solution. I wonder how much time has been wasted on this 
> (and the login_next etc).
>
> Peter
>
>>
>>

-- 





[web2py] Re: The book updates and status

2012-11-29 Thread Kostas M
I have bought the (printed) web2py book (editions 3rd and 4th) from Lulu, 
and my note is that the black & white printouts are much less attractive 
from
the web css book layout. The coloring helps understanding the syntax as 
well. I wish the printed book could look as nice as the web version...
I once printed some chapters in a color printer to have this nice layout. 
Couldn't the Lulu book follow a better printing style?

Kostas

On Wednesday, November 28, 2012 7:08:48 PM UTC, Massimo Di Pierro wrote:
>
> Almost everything is documented except: 1) auth.wiki; 2) some of the new 
> grid parameters.
>
> Along with these changes I am planning some minor book refactoring before 
> publishing to 5th edition.
>
> Massimo
>
>>


-- 





[web2py] Re: SQLFORM.factory and Select functionalities

2011-11-07 Thread Kostas M
Omi,

there was a mistype "db.m_Maker.ALL" instead of "db.Maker.ALL", which
I corrected.

Anyway, my main issue with your solution is that the FORM object is
not used, and so no Form validation is possible. On the other hand,
Freeze's solution with cascading fields in web2pyslices, seems too
advance for me too =))

On Nov 3, 3:44 pm, Omi Chiba  wrote:
> Kostas,
>
> I'm glad you did it !
>
> I tried your code this morning but some how it does not function
> (second pull dropdown doesn't show when first one is changed :(
>
> Anyway,
> your code looks a little bit too advance for me so I will keep the
> current one.
>
> On Nov 3, 6:59 am, Kostas M  wrote:
>
> > Omi,
>
> > Thanks for the hint!
> > I managed to adjust your solution to my case.
>
> > Also, I made some small recommendations, posted in web2pyslices.
>
> > On Oct 18, 9:00 pm, Omi Chiba  wrote:
>
> > > Kostas,
>
> > > This could be your alternatives.
>
> > > slice:http://www.web2pyslices.com/slices/take_slice/144
>
>


[web2py] Re: SQLFORM.factory and Select functionalities

2011-11-07 Thread Kostas M
Omi,

there was a mistype "db.m_Maker.ALL" instead of "db.Maker.ALL", which
I corrected.

Anyway, my main issue with your solution is that the FORM object is
not used, and so no Form validation is possible. On the other hand,
Freeze's solution with cascading fields in web2pyslices, seems too
advance for me too =))

On Nov 3, 3:44 pm, Omi Chiba  wrote:
> Kostas,
>
> I'm glad you did it !
>
> I tried your code this morning but some how it does not function
> (second pull dropdown doesn't show when first one is changed :(
>
> Anyway,
> your code looks a little bit too advance for me so I will keep the
> current one.
>
> On Nov 3, 6:59 am, Kostas M  wrote:
>
> > Omi,
>
> > Thanks for the hint!
> > I managed to adjust your solution to my case.
>
> > Also, I made some small recommendations, posted in web2pyslices.
>
> > On Oct 18, 9:00 pm, Omi Chiba  wrote:
>
> > > Kostas,
>
> > > This could be your alternatives.
>
> > > slice:http://www.web2pyslices.com/slices/take_slice/144
>
>


[web2py] Re: SQLFORM.factory and Select functionalities

2011-11-03 Thread Kostas M
Omi,

Thanks for the hint!
I managed to adjust your solution to my case.

Also, I made some small recommendations, posted in web2pyslices.


On Oct 18, 9:00 pm, Omi Chiba  wrote:
> Kostas,
>
> This could be your alternatives.
>
> slice:http://www.web2pyslices.com/slices/take_slice/144


[web2py] Re: SQLFORM.factory and Select functionalities

2011-11-03 Thread Kostas M
Omi,

Thanks for the hint!
I managed to adjust your solution to my case.

Also, I made some small recommendations, posted in web2pyslices.


On Oct 18, 9:00 pm, Omi Chiba  wrote:
> Kostas,
>
> This could be your alternatives.
>
> slice:http://www.web2pyslices.com/slices/take_slice/144


[web2py] SQLFORM.factory and Select functionalities

2011-10-18 Thread Kostas M
I want a FORM that the select option from the 2nd field, depends on
the select option of the 1st field. This could be accomplished using a
jQuery function to change the available options.
However, the construction of the SQLFORM.factory SELECT Field, comes
with the "requires" command, which leaves no alternatives to play with
jQuery later.
For instance:

form=SQLFORM.factory(
Field('method',requires=IS_IN_SET(['A','B'],zero=T('choose one'),
   error_message=T('select one of the methods'))  ),
 Field('units',requires=IS_IN_SET(['1','2'],zero=T('choose one'),
   error_message=T('select one of the units')))
   )

This presents the options '1' or '2', whatever option the user chooses
in the first Field. I want, if the user at the first Field chooses
'B', the available option for the second Field to be '1.1' or '1.2'.
Even if  I changed these options with jQuery, the validation rule
"requires" would produce an error...

What are my alternatives?


[web2py] Re: Memory error with numpy large array

2011-05-17 Thread Kostas M
I tried the same application in a Linux (Ubuntu) machine, after the
installation of the latest numpy version (1.6.0).

No MemoryError ticket occured in web2py...



[web2py] Re: Memory error with numpy large array

2011-05-10 Thread Kostas M
Thanks for your answer. My trials are with the webserver coming with
web2py (no apache or other server), into a Windows machine. I will try
the same in a Linux machine, and I'll report the results in case it is
a Windows quirk...

On May 5, 11:52 pm, Massimo Di Pierro 
wrote:
> I do not think so although there may be less memory available. Apache,
> if you use, may set restrictions.
>
> On May 5, 3:00 pm, Kostas M  wrote:
>
> > I have an application which uses the function numpy.zeros to create a
> > very big array (~16500 x 16500) with the command:
> > data = numpy.zeros( (lgos,lgos), dtype=float)
> > This causes a MemoryError ticket in web2py. However when I run the
> > same function as a python module (outside web2py) it finishes without
> > any problem.
> > Any hints?
> > Are there any additional memory restrictions when modules run through
> > web2py that I should somehow consider?
>
>


[web2py] Memory error with numpy large array

2011-05-05 Thread Kostas M
I have an application which uses the function numpy.zeros to create a
very big array (~16500 x 16500) with the command:
data = numpy.zeros( (lgos,lgos), dtype=float)
This causes a MemoryError ticket in web2py. However when I run the
same function as a python module (outside web2py) it finishes without
any problem.
Any hints?
Are there any additional memory restrictions when modules run through
web2py that I should somehow consider?


[web2py] Re: Merry Christmas

2010-12-23 Thread Kostas M
def best_wishes(web2py):
for i in web2py.users:
print "Dear %s I wish you Merry Christmas \
 and a Happy New Year!!" % i


[web2py] Re: Table names: plural or singular?

2010-12-02 Thread Kostas M
Thanks!

Sometimes I still forget the flexibility offered by Python..

On 2 Δεκ, 16:12, mdipierro  wrote:
> You should be able to do
>
> db.unit.label=Τ('physics units')
>

>
> > I think  it would be nice and coherent if it was possible to set an
> > additonal attribute to atablewith its 'label'. Something like:
> > db.units.label
>
> > So I propose maybe something like:
> > db.define_table('unit',label=Τ('physics units'),
> >     Field(..),..  )
>
> > On Dec 2, 9:11 am, mdipierro  wrote:
>
> > > There is no "label" for thetablebecause the name of thetabledoes
> > > not show up in any generated forms except, as you say, in appadmin.
> > > But appadmin is not quite the same of Django admin. It is designed for
> > > the administrator, not for the users.
>
> > > Massimo
>
> > > On Dec 2, 12:48 am, Kostas M  wrote:
>
>


[web2py] Re: Table names: plural or singular?

2010-12-02 Thread Kostas M
Ok, I understand that, but I am trying to implement a generic
controller (e.g. 'mylist') which takes as argument a table name (e.g.
'units') and returns its records. This is fine done, but I would like
to have also a header of the returned table, which is kind of a
'label' of the table, and it is different (and due to i18n) from the
name of the table.

I think  it would be nice and coherent if it was possible to set an
additonal attribute to a table with its 'label'. Something like:
db.units.label

So I propose maybe something like:
db.define_table('unit',label=Τ('physics units'),
Field(..),..  )

On Dec 2, 9:11 am, mdipierro  wrote:
> There is no "label" for thetablebecause the name of thetabledoes
> not show up in any generated forms except, as you say, in appadmin.
> But appadmin is not quite the same of Django admin. It is designed for
> the administrator, not for the users.
>
> Massimo
>
> On Dec 2, 12:48 am, Kostas M  wrote:
>
>


[web2py] Re: Table names: plural or singular?

2010-12-01 Thread Kostas M
Speaking of table names, I have a question:

In Django models, when defining a table e.g. "Unit", there is the
ability to adjust the name of the table when it is shown in the admin
app, using the Meta class as 'verbose_name' for single, and
'verbose_name_plural' for plural:

class Unit(models.Model):
code=models.CharField(max_length=2, verbose_name=u'κωδικός')
title=models.CharField(max_length=100,verbose_name=u'τίτλος')
class Meta:
verbose_name = u"μονάδα"
verbose_name_plural = u"μονάδες"

In Web2py, I would do:

db.define_table('unit',
Field('code','string',length=2,required=True,label=u'κωδικός'),
Field('title','string',length=100, required=True,label=u'τίτλος'),
)

but what about the 'label' of the table?


On Dec 1, 2:54 am, mdipierro  wrote:
> when the dal was designed I has singular in mind.
>


[web2py] Re: Validate dynamically generated select SQLFORM.factory

2010-11-18 Thread Kostas M
It seems I don't understand what is the problem. Isn't the intended
action the form to have errors if nothing is selected?
This is checked with the: if form.accepts(request.vars, session): ...

> My app throws an error if you click the submit button without selecting an 
> item from the list in the form.
>
> I have tried adding 'zero=T('Choose one')', both with and without adding the 
> string 'Choose one' to the list 'options'. What would the best way to 
> validate this be?


[web2py] Re: Validate dynamically generated select SQLFORM.factory

2010-11-17 Thread Kostas M
At first thanks villas for the correction of the boolean 'multiple'
argument.

DenesL I agree that "multiple should mean 1 or more, not zero or
more."

Making though the following test:

>>> IS_IN_SET(['max', 'john'])('')
('', 'value not allowed')
>>> IS_IN_SET(['max', 'john'], multiple=True)('')
([], None)

seems that the zero option strangely is allowed for the multiple case.

According to: 
http://www.web2py.com/examples/static/epydoc/web2py.gluon.validators.IS_IN_SET-class.html#__call__
this is due to lines:
 327  if self.multiple and (value == None or value ==
''):
 328  return ([], None)

I think should return (value, self.error_message), as is the case for
multiple=False

>
> Because multiple is not False, but I am not sure about the logic.
> No selection should still fail because it is not in the set,
> i.e. multiple should mean 1 or more, not zero or more.
>


[web2py] Re: Validate dynamically generated select SQLFORM.factory

2010-11-16 Thread Kostas M
I tried this in a controller and worked fine:

def factory():
options = ['a','b','c']
form = SQLFORM.factory(Field('Optimizers',
requires=IS_IN_SET(options,multiple='multiple')))
if form.accepts(request.vars, session):
response.flash = 'form accepted'
elif form.errors:
response.flash = 'form has errors'
return dict(form = form, form_options = form.vars.Optimizers)

Note that according to the web2py book: "The elements of the set must
always be strings unless this validator is preceded by IS_INT_IN_RANGE
(which converts the value to int) or IS_FLOAT_IN_RANGE (which converts
the value to float)"

I have also 2 questions though if somebody can help:
   1. If nothing is selected why the form is accepted?
   2. If I try to use multiple validators in requires=[] of the
SQLFORM.factory, only the last validator of the 'requires' list is
enforced. Is this a bug? The tried code is:

form=SQLFORM.factory(Field('Optimizers',requires=[IS_IN_SET(options,multiple='multiple'),
IS_NOT_EMPTY()] ))


On 16 Νοέ, 18:39, Lorin Rivers  wrote:
> Actually, that block prevents the query from running when the page loads.
>


[web2py] ValueError: need more than 1 value to unpack

2010-11-12 Thread Kostas M
I am trying to reproduce the "What is going on with web2py?" video
(http://vimeo.com/13485916). At the 'friend' section, when I try to
enter a new friend eg. "Max" I am getting this error:

Traceback (most recent call last):
  File "C:\Temp\web2py\applications\myplayepedvm/models/
plugin_wiki.py", line 597, in render_widget
  File "C:\Temp\web2py\applications\myplayepedvm/models/
plugin_wiki.py", line 183, in create
  File "gluon/tools.py", line 2874, in create
  File "gluon/tools.py", line 2817, in update
  File "gluon/sqlhtml.py", line 987, in accepts
  File "gluon/html.py", line 1557, in accepts
  File "gluon/html.py", line 558, in _traverse
  File "gluon/html.py", line 558, in _traverse
  File "gluon/html.py", line 558, in _traverse
  File "gluon/html.py", line 558, in _traverse
  File "gluon/html.py", line 565, in _traverse
  File "gluon/html.py", line 1336, in _validate
  File "gluon/validators.py", line 490, in __call__
ValueError: need more than 1 value to unpack



meta-code is:
db.define_table('friend',Field('name',requires=IS_NOT_IN_DB(db,'friend_name')))

Home is:
# Test App
## Friends
``
name: create
table: friend
message: new friend
``:widget
Friends:
``
name: jqgrid
table: friend
col_width: 80
width: 700
height: 100
``:widget


[web2py] Re: 'DEMO_MODE' is not defined

2010-10-14 Thread Kostas M
I am still getting this error with Version 1.87.3

Version
web2py Version 1.87.3 (2010-10-13 19:44:46)

Error ticket for "images"
Ticket 127.0.0.1.2010-10-14.09-53-53.ad7929fb-6991-49e1-
a83c-8ac1a49712a4


Error traceback

1.
2.
3.
4.
5.



Traceback (most recent call last):
  File "gluon/restricted.py", line 188, in restricted
  File "C:/Temp/web2py/applications/images/controllers/appadmin.py",
line 14, in 
NameError: name 'DEMO_MODE' is not defined

Error snapshot
Detailed traceback description

* Exception: (name 'DEMO_MODE' is not
defined)
  Exception instance attributes
  o __setattr__: 
  o __reduce_ex__: 
  o __getslice__: 
  o __getitem__: 
  o __setstate__: 
  o __getattribute__: 
  o __str__: 
  o args: ("name 'DEMO_MODE' is not defined",)
  o __reduce__: 
  o __class__: 
  o __dict__: {}
  o __delattr__: 
  o __repr__: 
  o __hash__: 
  o __doc__: 'Name not found globally.'
  o __init__: 
  o __new__: 
* Python 2.5.4: C:\Temp\web2py\web2py.exe

File C:\Temp\web2py\gluon\restricted.py in restricted at line 188