Re: [web2py] Plugin Wiki, jqgrid, crud.create error

2012-04-12 Thread Johann Spies
On 12 April 2012 05:38, Simon Ashley  wrote:

> Just playing with the plugin wiki and jqgrid with a simple example below, but 
> it return an error:
>
> Not sure why, any ideas?
>
>
>
Did you create the table 'plant' ?

I also played with this yesterday and it seems that this 'create' widget
only creates a form based on  the table (plant in this case).


Regards
Johann

-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)


Re: [web2py] question about processing db entries in chunks

2012-04-12 Thread Johann Spies
On 12 April 2012 08:51, weheh  wrote:

> I need to limit my processing of db entries to chunks of, let's say, 100.
> So I want to first get the data:
>
> data = db(db.mytable.flag == False).select(limitby=(0,100))
>
> for d in data:
> # do something
>
> Then I want to set mytable.flag to True after the above loop is done, but
> only for the same 100 entries I've just retrieved.
>
> BUT, while this is going on, someone else may be adding new entries with
> mytable.flag=False to the table.
>
> So without iterating one-by-one on "data", is there a one-liner to update
> mytable.flag to True for the 100 entries I already retrieved?
>

What about something like

ids = [x.id for x in data]
db(db.mytable.id.belongs(ids)).update(db.mytable.flag = True)

?

Or just store ids and in the next 'select' exclude those ids from your
query.


Regards
Johann


-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)


Re: [web2py] Adding a copy option to a SQLFORM.grid

2012-04-12 Thread Mike Veltman

On 04/12/2012 01:08 PM, Mike Veltman wrote:
Well I would like to have besides edit delete etc in my SQLFORM.grid 
also a copy option that copies the record and then gives me the edit 
so I can modify it.


Anyone a idea how to do that ?

Mike


Aha I have to use links (RTFM)
Does anybody have a example of the link and the called function for me ?




[web2py] translation issue with right-to-left languages

2012-04-12 Thread Kalpa Welivitigoda
Hi,

I am using Sahana-eden [1] which runs on web2py and I have a issue with 
right-to-left language (Arabic, Urdu) translations (Sahana-eden uses web2py 
translation feature).

I change the language to Urdu in 
http://demo.eden.sahanafoundation.org/eden/(second from the bottom in the 
language menu - top right corner). Then 
point the mouse to the language button again and notice "Portugues 
((Brasil". The closing parenthesis is not properly placed. This is the same 
with Arabic also.

I checked the languages file in applications/eden/languages/ur.py. There 
the translation is properly (parenthesis are in order) there as "Portugues 
(Brasil)". Further I changed the translated string into "Portugues (Brasil) 
sample" and now it is displayed properly (parenthesis are i order).

This is the same with Arabic also. And hopefully with any right-to-left 
language.

I am not sure whether this is a bug in web2py since I don't have any other 
site to check with.

Any help is highly appreciated.

Thanks in advance

[1] http://www.eden.sahanafoundation.org/

[web2py] References, uuid, postgresql and foreign keys

2012-04-12 Thread Johann Spies
When 'normal' web2py practice  defines a field as a reference like this:

 Field('created_by', db.auth_user, default = auth.user_id,
   readable = False, writable = False)


, postgresql does something like this:


ALTER TABLE akb_articles
  ADD CONSTRAINT akb_articles_created_by_fkey FOREIGN KEY (created_by)
  REFERENCES auth_user (id) MATCH SIMPLE
  ON UPDATE NO ACTION ON DELETE CASCADE;

I use uuids, not ids for reference in a complex database.  How do I change 
my field definition which currently looks like this:

db.akb_journal.publisher.requires = IS_EMPTY_OR(IS_IN_DB(db,   
   'akb_publisher.uuid',
'%(publisher)s'))



to produce a foreign key in Postgresql similar than the previous one?

Regards
Johann







Re: [web2py] Adding a copy option to a SQLFORM.grid

2012-04-12 Thread Mike Veltman

ok I used this in the end :)

   links = [lambda row: 
A('Copy',_href=URL("formdb","copy_profile",args=[row.id]))]



@auth.requires_login()
def copy_profile():

record = db.lparprofile(request.args[0])

vals = {}
for k,v in record.items():
if k in db.lparprofile.fields:
if k == 'lparname':
v = v + "_copy"
recname = str(v) # Needed to redirect the page to the 
right record

if k != 'id':
vals[k] = v

db.lparprofile.insert(**vals)
rec = db(db.lparprofile.lparname == recname).select().first()
rec_id = rec.id
redirect(URL(r=request, f='manage_profile',args=str(rec_id)))

return



Problem solved :-)

On 04/12/2012 03:19 PM, Mike Veltman wrote:

On 04/12/2012 01:08 PM, Mike Veltman wrote:
Well I would like to have besides edit delete etc in my SQLFORM.grid 
also a copy option that copies the record and then gives me the edit 
so I can modify it.


Anyone a idea how to do that ?

Mike


Aha I have to use links (RTFM)
Does anybody have a example of the link and the called function for me ?






Re: [web2py] Re: default value for upload Fields

2012-04-12 Thread hasan alnator
Massimo , still its now working , i did what you told me and it got me the
name of the image in the upload folder  but it didnt work


[web2py] bidirectional languages

2012-04-12 Thread Kalpa Welivitigoda
Hi,

Does the translation feature of web2py support bidirectional languages?


Re: [web2py] Re: Add conditional sub-menu

2012-04-12 Thread Javier Pepe
I was working on a set menu from the database. It's simple and it can be
useful.
The model is simple, and has a condition to evaluate options when
generating the menu items.
The evaluation was done using the function 'eval'.
Attach model.
To manage SQLFORM.grid use or what you like

db.define_table('menu',
Field('posicion',type='integer'),
Field('titulo',type='string'),
Field('controlador',type='string'),
Field('funcion',type='string'),
Field('padre'),
Field('condicion'),
   )
db.menu.padre.requires = IS_IN_DB(db, db.menu.id,'%(titulo)s')
db.menu.padre.represent = lambda id,row: db.menu(id).titulo
db.menu.condicion.default = 'True'

response.title = settings.title
response.subtitle = settings.subtitle
response.meta.author = '%(author)s <%(author_email)s>' % settings
response.meta.keywords = settings.keywords
response.meta.description = settings.description
response.menu = [ ]


def add_item(nivel):
item = []
for itemmenu in db((db.menu.padre == nivel) & (db.menu.id >
1)).select(orderby=db.menu.posicion):
if eval(itemmenu.condicion):

item.append([itemmenu.titulo,None,URL(itemmenu.controlador,itemmenu.funcion),add_item(
itemmenu.id) ])
return item

if auth.is_logged_in():
response.menu = add_item(1)


On Thu, Apr 12, 2012 at 1:00 AM, Cliff  wrote:

> I have something like this working:
>
> sub_menu = []
> if (auth.user_id != None) and ((auth.has_membership(role = 'admin'))):
> sub_menu = [('Admin',  False,  URL('admin')), ]
> response.menu = [('Home', False, URL('home','default','index'), []),
> (SPAN('Price List',_style='color:yellow'), True,
> URL('pricelist','default','index'),
> [('Guideline',  False,  URL('pricelist','default','guideline')),
>  ('Multiplier Tables',  False,
>  URL('pricelist','default','multitable')),
>  ('Cut Charge Tables',  False,  URL('pricelist','default','cuttable')),
>  (sub_menu),
> ])]
>
> On Wednesday, April 11, 2012 12:24:29 PM UTC-4, Omi Chiba wrote:
>>
>> The following menu works. It's add "Admin" menu next to "Price List" if
>> the user has role "admin". Now, I want to add the "Admin" menu as sub-menu
>> of "Price List" where it's right after the "Cut Charge Tables". How can I
>> do this ?
>>
>> response.menu = [('Home', False, URL('home','default','index'), []),
>> (SPAN('Price List',_style='color:yellow'), True,
>> URL('pricelist','default','**index'),
>> [('Guideline',  False,  URL('pricelist','default','**guideline')),
>>  ('Multiplier Tables',  False,  URL('pricelist','default','**
>> multitable')),
>>  ('Cut Charge Tables',  False,  URL('pricelist','default','**
>> cuttable')),
>> ])]
>>
>> if (auth.user_id != None) and ((auth.has_membership(role = 'admin'))):
>> response.menu += [('Admin',  False,  URL('admin')), ]
>>
>


[web2py] unable to deploy web2py application on GAE

2012-04-12 Thread Monika Vashistha

I have successfully managed to run my web2py application on dev_appserver. 
However when I tried to deploy it on GAE using command on terminal : 

python2.5 appcfg.py update ../web2py , it is giving error :
Error 404: --- begin server output ---
This application does not exist (app_id=u'friends').
--- end server output ---

I have edited the app.yaml and set the application id as required.
Kindly help.



[web2py] plugin_fbconnect_button() of sample

2012-04-12 Thread shinriyo
Hi there

Nice to meet you

I downloaded "FacebookConnectExample" from http://www.web2py.com/appliances 
And deployed it on my web2py.

The top page has a "{{=button}}" button.

I touch the button, new page open and input my facebook information.
And later, *new page* go to logged in page.

I hope* the original* *page *go to logged in page. it is almost application 
way.

The button created by "models/ plugin_fbconnect.py".

Could you tell me how to change?



[web2py] Re: OpenID, facebook, twitter, linkedin, etc etc

2012-04-12 Thread Roma Asnani

i am trying janrain and had created a model that contains this code. Refer 
from vimeo.com/21364178 building a minimalist facebook clone and deploying 
on google app engine using janrain.

import os
from gluon.contrib.login_methods.rpx_account import RPXAccount
# we disable actions that will be provided by Janrain, not auth
auth.settings.actions_disabled = ['register','change_password',
'request_reset_password']
# we read the key frm a file because we want to keep it private
api_key 
=open(os.path.join(request.folder,'private','janrain_api_key.txt'),'r').read().strip()
# we connect auth to janrain
auth.settings.login_form = RPXAccount(request, 
api_key=api_key,domain='web2py',
url = "http://localhost:8000/%s/default/user/login"; % 
request.application)

and i had created a file with name janrain_api_key.txt in app/private/ 
folder now in this i added the api key provided by janrain.
After all this i find my application works but it only stucks at login. It 
get sign in redirects to rpxnow page communicates the login information in 
another page graps the permission and come back to my application but still 
at same situation from where it starts. As the user doesn't get logged in. 
Can anyone specify what actually the problem is and why it lets me go back 
to the same login prompt.
ack t

On Friday, July 16, 2010 5:01:46 AM UTC+5:30, mdipierro wrote:
>
> I have integrated Mr Freeze RPX API into web2py (trunk only). 
>
> Take your existing app and at the bottom of db.py (or after you define 
> auth) add 
>
> from gluon.contrib.login_methods.rpx_account import RPXAccount 
>   
> auth.settings.actions_disabled=['register','change_password','request_reset_password']
>  
>
> auth.settings.login_form = RPXAccount( 
>   request, 
>   api_key="...", 
>   domain="...", 
>   url = "http://localhost:8000/%s/default/user/login"; % 
> request.application) 
>
> WHERE you can get and api_key and domain by registering (for free) at 
> https://rpxnow.com 
> you choose the domain (has to be unique) and they give you the 
> api_key. 
> The url is the URL of the login page itself as visible to your 
> visitors. 
>
> If you do not define your own db.auth_user table this is all you need. 
> If you define your own table, add a new field to it: 
>
> Field('registration_id', length=512,writable=False, 
> readable=False, default='') 
>
> Then visit the login page and viola' you can login with OpenID, 
> Google, etc etc. You can add UP to 6 methods for free using the 
> rpxnow.com interface. For more methods, you need to pay (I am not 
> affiliated with them and I get no profit but I like their system) 
>
> PLEASE TRY IT AND REPORT ANY PROBLEM. 
>
> I would like to release 1.81.1 with this tomorrow so I can show it at 
> EuroPython Saturday. 
>
> Massimo



[web2py] Re: Browser back button: Reloading database results

2012-04-12 Thread villas
My conclusion is that it is better to submit search forms with GET.  
Not only does it seem to avoid this problem,  it allows users to bookmark 
searches.
I create the search form with SQLFORM.factory and usually use 
keepvalues=True so that the user can keep his previous choice.
I hope this is relevant for you.
Best Regards,
David

On Wednesday, 11 April 2012 22:07:50 UTC+1, DJ wrote:
>
> Hello W2People,
>
> This may be a simple setting that I am unaware of - how does one retain 
> the database search results when you click the Back Button on the browser 
> without having to refresh the page and confirming?
>
> Thank you,
> Sebastian
>


[web2py] Re: Query or Expression for excluding certain values from DAL selection on GAE

2012-04-12 Thread Massimo Di Pierro
What database, what web2py version?

On Thursday, 12 April 2012 01:48:51 UTC-5, Sathvik Ponangi wrote:
>
> From http://stackoverflow.com/q/10117143/937891
>
> I'm trying to exclude posts which have a tag named meta from my selection, 
> by:
>
> meta_id = db(db.tags.name == "meta").select().first().id
> not_meta = ~db.posts.tags.contains(meta_id)
> posts=db(db.posts).select(not_meta)
>
> But those posts still show up in my selection.
>
> What is the right way to write that expression?
>
> My tables look like:
>
> db.define_table('tags',
> db.Field('name', 'string'),
> db.Field('desc', 'text', default="")
> )
>
> db.define_table('posts', 
> db.Field('title', 'string'),
> db.Field('message', 'text'),
> db.Field('tags', 'list:reference tags'),
> db.Field('time', 'datetime', default=datetime.utcnow())
> )
>
> *UPDATE:*
>
> I just tried posts=db(not_meta).select() as suggested by @Anthony, but it 
> gives me a Ticket with the following Traceback:
>
> Traceback (most recent call last):
>   File "E:\Programming\Python\web2py\gluon\restricted.py", line 205, in 
> restricted
> exec ccode in environment
>   File 
> "E:/Programming/Python/web2py/applications/vote_up/controllers/default.py", 
> line 391, in 
>   File "E:\Programming\Python\web2py\gluon\globals.py", line 173, in 
> self._caller = lambda f: f()
>   File 
> "E:/Programming/Python/web2py/applications/vote_up/controllers/default.py", 
> line 8, in index
> posts=db(not_meta).select()#orderby=settings.sel.posts, limitby=(0, 
> settings.delta)
>   File "E:\Programming\Python\web2py\gluon\dal.py", line 7578, in select
> return adapter.select(self.query,fields,attributes)
>   File "E:\Programming\Python\web2py\gluon\dal.py", line 3752, in select
> (items, tablename, fields) = self.select_raw(query,fields,attributes)
>   File "E:\Programming\Python\web2py\gluon\dal.py", line 3709, in select_raw
> filters = self.expand(query)
>   File "E:\Programming\Python\web2py\gluon\dal.py", line 3589, in expand
> return expression.op(expression.first)
>   File "E:\Programming\Python\web2py\gluon\dal.py", line 3678, in NOT
> raise SyntaxError, "Not suported %s" % first.op.__name__
> SyntaxError: Not suported CONTAINS
>
>

[web2py] Re: bidirectional languages

2012-04-12 Thread Massimo Di Pierro
Yes. You have to translate the CSS that determines the alignment as well.

On Thursday, 12 April 2012 05:15:29 UTC-5, Kalpa Welivitigoda wrote:
>
> Hi,
>
> Does the translation feature of web2py support bidirectional languages?
>


Re: [web2py] Re: Scaling web2py

2012-04-12 Thread villas

>
>
> Thanks that will be helpful, I liked the idea of paths also. However if 
> you have 200,000 + nodes in a tree the paths might be coming hard to work 
> with.
>
>
Yes, my tree was somewhat smaller!  It seems to me that "with recursive" is 
the easiest method to manage this,  although of course the DAL does not 
have any support for this.

I have been thinking more about the path method and for most cases can see 
that this would be a very high performance and easy method.  Having read 
through several papers on tree structures which seem absurdly complex,  I 
am amazed that the path method is not everyone's first choice for most 
simple tree structures.  Even more so than the widely used nested sets. 
 The paths are so intuitive and,  not least,  solve everyone's breadcrumb 
problems at a stroke!  I wonder to myself why on earth everyone only seems 
to mention the path method as an after-thought.

Best wishes
David



Re: [web2py] Re: bidirectional languages

2012-04-12 Thread Kalpa Welivitigoda
On Thu, Apr 12, 2012 at 5:56 PM, Massimo Di Pierro
 wrote:
> Yes. You have to translate the CSS that determines the alignment as well.
>

My translation file is applications/eden/languages/ur.py (eden is my
application name).

There I have an untranslated string as "Today (Monday)" and in Urdu
language which is a RTL it is displayed as "Today ((Monday".
I want to have the "(" and ")" in LTR and the rest in RTL.

How can I accomplish this?

>
> On Thursday, 12 April 2012 05:15:29 UTC-5, Kalpa Welivitigoda wrote:
>>
>> Hi,
>>
>> Does the translation feature of web2py support bidirectional languages?



-- 
Best Regards,

Kalpa Pathum Welivitigoda
http://about.me/callkalpa


Re: [web2py] Re: Query or Expression for excluding certain values from DAL selection on GAE

2012-04-12 Thread Sathvik Ponangi
GAE DataStore - Web2Py 1.99.7 Stable

On Thu, Apr 12, 2012 at 5:53 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> What database, what web2py version?
>
>
> On Thursday, 12 April 2012 01:48:51 UTC-5, Sathvik Ponangi wrote:
>>
>> From 
>> http://stackoverflow.com/**q/10117143/937891
>>
>> I'm trying to exclude posts which have a tag named meta from my
>> selection, by:
>>
>> meta_id = db(db.tags.name == "meta").select().first().id
>> not_meta = ~db.posts.tags.contains(meta_**id)
>> posts=db(db.posts).select(not_**meta)
>>
>> But those posts still show up in my selection.
>>
>> What is the right way to write that expression?
>>
>> My tables look like:
>>
>> db.define_table('tags',
>> db.Field('name', 'string'),
>> db.Field('desc', 'text', default="")
>> )
>>
>> db.define_table('posts',
>> db.Field('title', 'string'),
>> db.Field('message', 'text'),
>> db.Field('tags', 'list:reference tags'),
>> db.Field('time', 'datetime', default=datetime.utcnow())
>> )
>>
>> *UPDATE:*
>>
>> I just tried posts=db(not_meta).**select() as suggested by @Anthony, but
>> it gives me a Ticket with the following Traceback:
>>
>> Traceback (most recent call last):
>>   File "E:\Programming\Python\web2py\**gluon\restricted.py", line 205, in 
>> restricted
>> exec ccode in environment
>>   File 
>> "E:/Programming/Python/web2py/**applications/vote_up/**controllers/default.py",
>>  line 391, in 
>>   File "E:\Programming\Python\web2py\**gluon\globals.py", line 173, in 
>> 
>> self._caller = lambda f: f()
>>   File 
>> "E:/Programming/Python/web2py/**applications/vote_up/**controllers/default.py",
>>  line 8, in index
>> posts=db(not_meta).select()#**orderby=settings.sel.posts, limitby=(0, 
>> settings.delta)
>>   File "E:\Programming\Python\web2py\**gluon\dal.py", line 7578, in select
>> return adapter.select(self.query,**fields,attributes)
>>   File "E:\Programming\Python\web2py\**gluon\dal.py", line 3752, in select
>> (items, tablename, fields) = self.select_raw(query,fields,**attributes)
>>   File "E:\Programming\Python\web2py\**gluon\dal.py", line 3709, in 
>> select_raw
>> filters = self.expand(query)
>>   File "E:\Programming\Python\web2py\**gluon\dal.py", line 3589, in expand
>> return expression.op(expression.**first)
>>   File "E:\Programming\Python\web2py\**gluon\dal.py", line 3678, in NOT
>> raise SyntaxError, "Not suported %s" % first.op.__name__
>> SyntaxError: Not suported CONTAINS
>>
>>


-- 
Sathvik Ponangi


[web2py] Re: Query or Expression for excluding certain values from DAL selection on GAE

2012-04-12 Thread Anthony
Actually, I think the problem is not with contains() but with the NOT 
operator (~) -- it doesn't work on GAE (technically, you can use it with a 
few operators, such as <, >, ==, because they can be negated by using the 
opposite operators).

Massimo, note that the syntax error used there is misspelled -- it says 
"suported" instead of "supported".

Anthony

On Thursday, April 12, 2012 2:48:51 AM UTC-4, Sathvik Ponangi wrote:
>
> From http://stackoverflow.com/q/10117143/937891
>
> I'm trying to exclude posts which have a tag named meta from my selection, 
> by:
>
> meta_id = db(db.tags.name == "meta").select().first().id
> not_meta = ~db.posts.tags.contains(meta_id)
> posts=db(db.posts).select(not_meta)
>
> But those posts still show up in my selection.
>
> What is the right way to write that expression?
>
> My tables look like:
>
> db.define_table('tags',
> db.Field('name', 'string'),
> db.Field('desc', 'text', default="")
> )
>
> db.define_table('posts', 
> db.Field('title', 'string'),
> db.Field('message', 'text'),
> db.Field('tags', 'list:reference tags'),
> db.Field('time', 'datetime', default=datetime.utcnow())
> )
>
> *UPDATE:*
>
> I just tried posts=db(not_meta).select() as suggested by @Anthony, but it 
> gives me a Ticket with the following Traceback:
>
> Traceback (most recent call last):
>   File "E:\Programming\Python\web2py\gluon\restricted.py", line 205, in 
> restricted
> exec ccode in environment
>   File 
> "E:/Programming/Python/web2py/applications/vote_up/controllers/default.py", 
> line 391, in 
>   File "E:\Programming\Python\web2py\gluon\globals.py", line 173, in 
> self._caller = lambda f: f()
>   File 
> "E:/Programming/Python/web2py/applications/vote_up/controllers/default.py", 
> line 8, in index
> posts=db(not_meta).select()#orderby=settings.sel.posts, limitby=(0, 
> settings.delta)
>   File "E:\Programming\Python\web2py\gluon\dal.py", line 7578, in select
> return adapter.select(self.query,fields,attributes)
>   File "E:\Programming\Python\web2py\gluon\dal.py", line 3752, in select
> (items, tablename, fields) = self.select_raw(query,fields,attributes)
>   File "E:\Programming\Python\web2py\gluon\dal.py", line 3709, in select_raw
> filters = self.expand(query)
>   File "E:\Programming\Python\web2py\gluon\dal.py", line 3589, in expand
> return expression.op(expression.first)
>   File "E:\Programming\Python\web2py\gluon\dal.py", line 3678, in NOT
> raise SyntaxError, "Not suported %s" % first.op.__name__
> SyntaxError: Not suported CONTAINS
>
>

[web2py] Re: Add conditional sub-menu

2012-04-12 Thread Omi Chiba
Cliff, 

Thank you for sharing code but now I got a different error. Maybe it cannot 
understand sub_menu contains three parameters..

Traceback (most recent call last):
  File "C:\web2py\gluon\restricted.py", line 205, in restricted
exec ccode in environment
  File "C:\web2py\applications\home\views\default/index.html", line 64, in 

  File "C:\web2py\gluon\globals.py", line 182, in write
self.body.write(xmlescape(data))
  File "C:\web2py\gluon\html.py", line 114, in xmlescape
return data.xml()
  File "C:\web2py\gluon\html.py", line 2146, in xml
return self.serialize(self.data, 0).xml()
  File "C:\web2py\gluon\html.py", line 2121, in serialize
li.append(self.serialize(item[3], level+1))
  File "C:\web2py\gluon\html.py", line 2109, in serialize
(name, active, link) = item[:3]
ValueError: need more than 0 values to unpack

On Wednesday, April 11, 2012 11:00:30 PM UTC-5, Cliff wrote:
>
> I have something like this working:
>
> sub_menu = []
> if (auth.user_id != None) and ((auth.has_membership(role = 'admin'))):
> sub_menu = [('Admin',  False,  URL('admin')), ]
> response.menu = [('Home', False, URL('home','default','index'), []),
> (SPAN('Price List',_style='color:yellow'), True, 
> URL('pricelist','default','index'), 
> [('Guideline',  False,  URL('pricelist','default','guideline')),
>  ('Multiplier Tables',  False, 
>  URL('pricelist','default','multitable')),
>  ('Cut Charge Tables',  False,  URL('pricelist','default','cuttable')),
>  (sub_menu),
> ])]
>
> On Wednesday, April 11, 2012 12:24:29 PM UTC-4, Omi Chiba wrote:
>>
>> The following menu works. It's add "Admin" menu next to "Price List" if 
>> the user has role "admin". Now, I want to add the "Admin" menu as sub-menu 
>> of "Price List" where it's right after the "Cut Charge Tables". How can I 
>> do this ?
>>
>> response.menu = [('Home', False, URL('home','default','index'), []),
>> (SPAN('Price List',_style='color:yellow'), True, 
>> URL('pricelist','default','index'), 
>> [('Guideline',  False,  URL('pricelist','default','guideline')),
>>  ('Multiplier Tables',  False, 
>>  URL('pricelist','default','multitable')),
>>  ('Cut Charge Tables',  False, 
>>  URL('pricelist','default','cuttable')),
>> ])]
>>
>> if (auth.user_id != None) and ((auth.has_membership(role = 'admin'))):
>> response.menu += [('Admin',  False,  URL('admin')), ]
>>
>

Re: [web2py] Re: Add conditional sub-menu

2012-04-12 Thread Omi Chiba
Nice approach. I will try for my another project !

On Thursday, April 12, 2012 5:18:58 AM UTC-5, Javier wrote:
>
> I was working on a set menu from the database. It's simple and it can be 
> useful.
> The model is simple, and has a condition to evaluate options when 
> generating the menu items.
> The evaluation was done using the function 'eval'.
> Attach model.
> To manage SQLFORM.grid use or what you like
>
> db.define_table('menu',
> Field('posicion',type='integer'),
> Field('titulo',type='string'),
> Field('controlador',type='string'),
> Field('funcion',type='string'),
> Field('padre'),
> Field('condicion'),
>)   
> db.menu.padre.requires = IS_IN_DB(db, db.menu.id,'%(titulo)s')
> db.menu.padre.represent = lambda id,row: db.menu(id).titulo
> db.menu.condicion.default = 'True'
>
> response.title = settings.title
> response.subtitle = settings.subtitle
> response.meta.author = '%(author)s <%(author_email)s>' % settings
> response.meta.keywords = settings.keywords
> response.meta.description = settings.description
> response.menu = [ ] 
>
>
> def add_item(nivel):
> item = []
> for itemmenu in db((db.menu.padre == nivel) & (db.menu.id > 
> 1)).select(orderby=db.menu.posicion):
> if eval(itemmenu.condicion):
> 
> item.append([itemmenu.titulo,None,URL(itemmenu.controlador,itemmenu.funcion),add_item(
> itemmenu.id) ])
> return item
>
> if auth.is_logged_in():
> response.menu = add_item(1)
>
>
> On Thu, Apr 12, 2012 at 1:00 AM, Cliff  wrote:
>
>> I have something like this working:
>>
>> sub_menu = []
>> if (auth.user_id != None) and ((auth.has_membership(role = 'admin'))):
>> sub_menu = [('Admin',  False,  URL('admin')), ]
>> response.menu = [('Home', False, URL('home','default','index'), []),
>> (SPAN('Price List',_style='color:yellow'), True, 
>> URL('pricelist','default','index'), 
>> [('Guideline',  False,  URL('pricelist','default','guideline')),
>>  ('Multiplier Tables',  False, 
>>  URL('pricelist','default','multitable')),
>>  ('Cut Charge Tables',  False, 
>>  URL('pricelist','default','cuttable')),
>>  (sub_menu),
>> ])]
>>
>> On Wednesday, April 11, 2012 12:24:29 PM UTC-4, Omi Chiba wrote:
>>>
>>> The following menu works. It's add "Admin" menu next to "Price List" if 
>>> the user has role "admin". Now, I want to add the "Admin" menu as sub-menu 
>>> of "Price List" where it's right after the "Cut Charge Tables". How can I 
>>> do this ?
>>>
>>> response.menu = [('Home', False, URL('home','default','index'), []),
>>> (SPAN('Price List',_style='color:yellow'), True, 
>>> URL('pricelist','default','**index'), 
>>> [('Guideline',  False,  URL('pricelist','default','**guideline')),
>>>  ('Multiplier Tables',  False,  URL('pricelist','default','**
>>> multitable')),
>>>  ('Cut Charge Tables',  False,  URL('pricelist','default','**
>>> cuttable')),
>>> ])]
>>>
>>> if (auth.user_id != None) and ((auth.has_membership(role = 'admin'))):
>>> response.menu += [('Admin',  False,  URL('admin')), ]
>>>
>>
>

[web2py] Re: Questions on the scheduler

2012-04-12 Thread blackthorne
Sorry to rehash this topic, this is critical to me and eventually to you.

Scheduler in web2py works great. 
What I need is to access the workers asynchronously and invoke methods on 
it so that I can pause/resume/abort them and check on its level of progress.

Any ideas on this?

Thank you

On Saturday, 11 February 2012 18:59:43 UTC, blackthorne wrote:
>
> Massimo: 
> For instance, I created a method that returns the progress of the task 
> that I am running 
> I guess my questions could collapse into this example: 
>
> Consider, 
> in a db file 
>
> def plugin_run(plugin, **kw): 
> plugin_obj = load_plugin(plugin, **kw) 
> plugin_obj.start() 
> return plugin_obj.report() #this shall be a dictionary for 
> appearing in results properly 
>
> myscheduler = Scheduler(db_tasks, dict(plugin_run=plugin_run)) 
>
> Eventually that plugin_obj will be picked up by a worker... 
> now, that it is running it is taking a lot of time and I wanted to do 
> something like.. 
> from db_scheduler_worker where it is running task with 
> task_name="demo" 
> call "plugin_obj.progress()" defined inside 
>
>
>
>
>
> On Feb 10, 5:39 pm, Massimo Di Pierro  
> wrote: 
> > Not sure I understand. You do not call scheduled_workers functions. 
> > You schedule tasks. Workers pick them up from queue an execute them 
> > using the available power. 
> > 
> > On Feb 10, 4:54 am, blackthorne  wrote: 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > > - Is it possible to call scheduled_workers functions asynchronously? 
> > > How? 
> > > - How should I adapt the behavior of a scheduled_worker as changing 
> > > its model and adding new functionality? 
> > 
> > > Thank you



Re: [web2py] Re: Query or Expression for excluding certain values from DAL selection on GAE

2012-04-12 Thread Sathvik Ponangi
Anthony is right, it works fine without the ~.

 As a temporary workaround I'm using:

meta = db.posts.tags.contains(settings.meta_id)
all=db(db.posts).select()#, limitby=(0, settings.delta)
meta=db(meta).select()
posts = []
i = 0
for post in all:
if i==settings.delta: break
if post in meta: continue
else:
posts.append(post)
i += 1
#settings.delta is an long integer to be used with limitby


Kindly let me know if there is a better way to do the same.

On Thu, Apr 12, 2012 at 7:05 PM, Anthony  wrote:

> Actually, I think the problem is not with contains() but with the NOT
> operator (~) -- it doesn't work on GAE (technically, you can use it with a
> few operators, such as <, >, ==, because they can be negated by using the
> opposite operators).
>
> Massimo, note that the syntax error used there is misspelled -- it says
> "suported" instead of "supported".
>
> Anthony
>
>
> On Thursday, April 12, 2012 2:48:51 AM UTC-4, Sathvik Ponangi wrote:
>>
>> From 
>> http://stackoverflow.com/**q/10117143/937891
>>
>> I'm trying to exclude posts which have a tag named meta from my
>> selection, by:
>>
>> meta_id = db(db.tags.name == "meta").select().first().id
>> not_meta = ~db.posts.tags.contains(meta_**id)
>> posts=db(db.posts).select(not_**meta)
>>
>> But those posts still show up in my selection.
>>
>> What is the right way to write that expression?
>>
>> My tables look like:
>>
>> db.define_table('tags',
>> db.Field('name', 'string'),
>> db.Field('desc', 'text', default="")
>> )
>>
>> db.define_table('posts',
>> db.Field('title', 'string'),
>> db.Field('message', 'text'),
>> db.Field('tags', 'list:reference tags'),
>> db.Field('time', 'datetime', default=datetime.utcnow())
>> )
>>
>> *UPDATE:*
>>
>> I just tried posts=db(not_meta).**select() as suggested by @Anthony, but
>> it gives me a Ticket with the following Traceback:
>>
>> Traceback (most recent call last):
>>   File "E:\Programming\Python\web2py\**gluon\restricted.py", line 205, in 
>> restricted
>> exec ccode in environment
>>   File 
>> "E:/Programming/Python/web2py/**applications/vote_up/**controllers/default.py",
>>  line 391, in 
>>   File "E:\Programming\Python\web2py\**gluon\globals.py", line 173, in 
>> 
>> self._caller = lambda f: f()
>>   File 
>> "E:/Programming/Python/web2py/**applications/vote_up/**controllers/default.py",
>>  line 8, in index
>> posts=db(not_meta).select()#**orderby=settings.sel.posts, limitby=(0, 
>> settings.delta)
>>   File "E:\Programming\Python\web2py\**gluon\dal.py", line 7578, in select
>> return adapter.select(self.query,**fields,attributes)
>>   File "E:\Programming\Python\web2py\**gluon\dal.py", line 3752, in select
>> (items, tablename, fields) = self.select_raw(query,fields,**attributes)
>>   File "E:\Programming\Python\web2py\**gluon\dal.py", line 3709, in 
>> select_raw
>> filters = self.expand(query)
>>   File "E:\Programming\Python\web2py\**gluon\dal.py", line 3589, in expand
>> return expression.op(expression.**first)
>>   File "E:\Programming\Python\web2py\**gluon\dal.py", line 3678, in NOT
>> raise SyntaxError, "Not suported %s" % first.op.__name__
>> SyntaxError: Not suported CONTAINS
>>
>>


-- 
Sathvik Ponangi


[web2py] Re: unordered list and pagination

2012-04-12 Thread Annet
Massimo,

Thanks for helping me solve the problem. This:

fields=(db.Organization.name , ) # <<< 
> the commma
>

... doesn't work. It had to be:

fields=[db.Organization.name ]
>

 
Kind regards,

Annet.


[web2py] Re: Can't rebuild database files

2012-04-12 Thread Yarin
The current documentation is here: 
http://web2py.com/books/default/chapter/29/6#Fixing-broken-migrations in 
case anyone else wants to know.

@Massimo- you should consider having a "warnings" or "rules of thumb" 
section in the book where things like this can be documented collectively. 

Example:

   - Altering more than one database table definition at a time will 
   corrupt mysql mappings.

When I think of others I'll let you know ;)


On Wednesday, April 11, 2012 9:04:12 PM UTC-4, Massimo Di Pierro wrote:
>
> I suspect the online docs is incorrect and fake_migrate does not work 
> without migrate. I need to double check.
>
> Massimo
>
> On Wednesday, 11 April 2012 19:40:17 UTC-5, Yarin wrote:
>>
>> Massimo, this worked and I was able to get everything restored- thanks. 
>> However I could use an explanation. Setting both migrate *and*fake_migrate 
>> to True is not something prescribed in the documentation nor 
>> is it intuitive- how/why does this work?
>>
>> On Wednesday, April 11, 2012 7:25:21 PM UTC-4, Massimo Di Pierro wrote:
>>>
>>> Can you true setting both migrate=True, fake_migrate_all=True? then 
>>> call appadmin. What happens?
>>>
>>> On Wednesday, 11 April 2012 17:05:14 UTC-5, Yarin wrote:

 I corrupted my web2py -myql mapping and am trying to rebuild the web2py 
 database files from scratch. 

 Starting point: 

- The mysql database tables already exist. Some tables were working 
correctly under the old mapping, and some were never mapped.
- I've already deleted everything from the databases folder.
- I've already cleared everything from the db.py file except the 
original code (auth tables, etc.)

 Plan:


- Set migrate=False, fake_migrate_all=True at the DAL connection 
level: 
db = DAL('mysql://root:root@localhost/mydb', 
 migrate=False,fake_migrate_all
=True)
- Re-add each table into the db.py file one by one, starting with a 
fake_migrate and then going to real migrate into all the tables were 
working.

 Problem:


- I can't get any table files generated for anything, even the auth 
files. Setting fake_migrate_all=True doesn't generate any files, and 
setting migrate=True gives me an error that the tables already exist. 


 How do I get the table files to generate?











[web2py] Python Argentina Conference 2012 - Massimo confirmed - Call for Sponsors

2012-04-12 Thread Mariano Reingart
FYI

Massimo Di Pierro (creator of web2py) is our first confirmed invited speaker:

http://ar.pycon.org/2012?lang=en

http://ar.pycon.org/2012/activity/speakers/#34


We're looking for sponsors:

http://ar.pycon.org/2012/sponsors/prospectus?lang=en

http://ar.pycon.org/2012/static/docs/carta_sponsors_pyconar2012.pdf


Call for Proposals comming soon


Regards

Mariano Reingart
http://www.sistemasagiles.com.ar
http://reingart.blogspot.com

PS: I'm the Conference Chair, so fell free to contact me about the event


[web2py] Re: Questions on the scheduler

2012-04-12 Thread Wikus van de Merwe
If all what you need is to report th task progress, you could periodically 
write the amount of work done to db from within the task. Then query db 
asynchronously with ajax to show it to the user. This could be done by 
extending the "scheduler_run" table.

I'm not sure if there is a way to stop a running task. I guess you would 
have to kill the worker process to do that. Pause/resume would be even more 
difficult as the state of a task have to be stored. Probably it would be 
easier to do using a task queue framework such as Celery [1] or 
implementing your own queue using e.g. RabbitMQ [2].

[1] http://celeryproject.org/
[2] http://www.rabbitmq.com/tutorials/tutorial-two-python.html




Re: [web2py] Re: bidirectional languages

2012-04-12 Thread Massimo Di Pierro
You have to use something like in CSS

.rlt
{
direction:rtl;
}
.ltr
{
direction:ltr;
}

and use something like 

{{=T('text')}}

and translate the direction as you translate the text.



On Thursday, 12 April 2012 08:22:09 UTC-5, Kalpa Welivitigoda wrote:
>
> On Thu, Apr 12, 2012 at 5:56 PM, Massimo Di Pierro
>  wrote:
> > Yes. You have to translate the CSS that determines the alignment as well.
> >
>
> My translation file is applications/eden/languages/ur.py (eden is my
> application name).
>
> There I have an untranslated string as "Today (Monday)" and in Urdu
> language which is a RTL it is displayed as "Today ((Monday".
> I want to have the "(" and ")" in LTR and the rest in RTL.
>
> How can I accomplish this?
>
> >
> > On Thursday, 12 April 2012 05:15:29 UTC-5, Kalpa Welivitigoda wrote:
> >>
> >> Hi,
> >>
> >> Does the translation feature of web2py support bidirectional languages?
>
> -- 
> Best Regards,
>
> Kalpa Pathum Welivitigoda
> http://about.me/callkalpa
>
>

[web2py] Re: Python Argentina Conference 2012 - Massimo confirmed - Call for Sponsors

2012-04-12 Thread Massimo Di Pierro
Thank you Mariano. I am honored.

On Thursday, 12 April 2012 10:42:28 UTC-5, Mariano Reingart wrote:
>
> FYI
>
> Massimo Di Pierro (creator of web2py) is our first confirmed invited 
> speaker:
>
> http://ar.pycon.org/2012?lang=en
>
> http://ar.pycon.org/2012/activity/speakers/#34
>
>
> We're looking for sponsors:
>
> http://ar.pycon.org/2012/sponsors/prospectus?lang=en
>
> http://ar.pycon.org/2012/static/docs/carta_sponsors_pyconar2012.pdf
>
>
> Call for Proposals comming soon
>
>
> Regards
>
> Mariano Reingart
> http://www.sistemasagiles.com.ar
> http://reingart.blogspot.com
>
> PS: I'm the Conference Chair, so fell free to contact me about the event
>
>

[web2py] Re: Questions on the scheduler

2012-04-12 Thread Francisco G. T. Ribeiro
Thank you for your answer. 

I am not very interested in importing more dependencies even though I know 
those projects you mention are great (I really like Erlang..).
Anyway you gave me an idea that could solve it. Implement a "messaging 
system" in web2py by keeping a table with those contents as "flags" that 
would be cyclically verified by the workers... that could work...

Thanks 

On Thursday, 12 April 2012 18:06:46 UTC+1, Wikus van de Merwe wrote:
>
> If all what you need is to report th task progress, you could periodically 
> write the amount of work done to db from within the task. Then query db 
> asynchronously with ajax to show it to the user. This could be done by 
> extending the "scheduler_run" table.
>
> I'm not sure if there is a way to stop a running task. I guess you would 
> have to kill the worker process to do that. Pause/resume would be even more 
> difficult as the state of a task have to be stored. Probably it would be 
> easier to do using a task queue framework such as Celery [1] or 
> implementing your own queue using e.g. RabbitMQ [2].
>
> [1] http://celeryproject.org/
> [2] http://www.rabbitmq.com/tutorials/tutorial-two-python.html
>
>
>

RE: [web2py] Re: Mimicking HTML5 pattern attribute for inputs

2012-04-12 Thread Sean Samborski
The h5Validate does the trick for me. I can't get Webshims to work so that 
wasn't a viable option. It is all-enclusive so it is a more ideal solution than 
h5 but for some reason I have trouble making some js work with things like 
web2py. I've had trouble in the past with Drupal and AbleCommerce having the 
same problems. That is, they work on static pages, but lose something in the 
transfer. The only thing I can think of is that with the header, content, 
footer, et al sections being broken up I'm doing something wrong.

 

Anyway, the web2py method you gave me works like a charm. I got it working no 
problems and for modern browsers, the HTML5 fires first and then on the older 
browsers web2py handles the validation. So that's perfect.

 

One last thing, if you will. Where can you find the programming for the 
response.flash? I would like to keep the behavior of flashing a message if 
there is an error, but I want to define a specific location and have no 
animation whatsoever. The way it works for me out of the box is to shift 
everything down and sort of "roll up" out of nowhere. I can't stand having the 
screen change so I would like to set it to have no animation and just appear. I 
can keep the areas where it is going to appear defined in widths and heights so 
they always exist even if there is no content but the rolling effect stills 
shifts everything.

 

hopefully I explained that last part right. Thanks for your help, Anthony!

 

From: web2py@googlegroups.com [mailto:web2py@googlegroups.com] On Behalf Of 
Anthony
Sent: Wednesday, April 11, 2012 5:17 PM
To: web2py@googlegroups.com
Subject: [web2py] Re: Mimicking HTML5 pattern attribute for inputs

 

If you want to stick with client side validation, you might also consider a 
Javascript polyfill library like Webshims Lib 
(http://afarkas.github.com/webshim/demos/), which lets you use HTML5 features 
in older browsers. Also note that although client-side validation improves the 
user experience, it does not protect against malicious attacks, so you may 
still want some server-side validation in addition.

 

Anthony

On Wednesday, April 11, 2012 4:21:35 PM UTC-4, RKS wrote:

I'm looking to validate all of my forms with HTML5 and the pattern attribute, 
but as always, nothing is perfect on the internet and I still need a backup to 
catch those users who do not use HTML5 friendly browsers.

I'm having trouble finding exact representations of the regular expressions in 
the handbook so if you know, I'd appreciate some help. I have written the code 
in two ways, the HTML way and the HTML helper way (see below) and the HTML5 
works and validates in modern browsers except IE as expected but I can't 
translate them to python.

An example, you will see below, is the expression 
pattern="[A-F0-9]{11}|[A-F0-9]{14}"
This effectively forces an input to only contain uppercase letters of A-F and 
numbers 0-9. It also ensures the length is exactly 11 characters or 14. So how 
would I use this in web2py? IS_LENGTH seems to accept only a range from my 
tests and so far I've only found IS_ALPHANUMERIC to control what characters are 
accepted.

Please seem the form below:

HTML:


MSIE/ESN *


Zip Code *






   * denotes a required field.




HTML Helpers:

form=FORM(LABEL('MEID/ESN 
',(SPAN('*'))),INPUT(_name='meid',_pattern="[A-F0-9]{11}|[A-F0-9]{14}",_placeholder='MEID/ESN',_required='required',_title="The
 MEID/ESN number only contains 11 or 13 characters, the letters A-F, and the 
numbers 0-9.",requires=[IS_LENGTH(11|14),IS_NOT_EMPTY()], 
_onblur="this.checkValidity();"),BR(),LABEL('ZIP CODE 
',(SPAN('*'))),INPUT(_name='zip',_type='number',_pattern="[0-9]{5}",_placeholder='Zip
 Code',_required='required',_title="We only required the five character zip 
code.",requires=IS_NOT_EMPTY()),BR(),BR(),BR(),BR(),INPUT(_type='button',_name='cancel',_value='Cancel',_onclick="history.go(-1);return
 
true;"),INPUT(_type='submit',_name='submit',_value='Activate'),_method='post',_id='activate_form')
if form.accepts(request,session):
response.flash = 'Form accepted'
 #   redirect(URL('next'))
elif form.errors:
response.flash = 'Form has errors'
return dict(form=form)



Thanks.



[web2py] how to change a field type from string to decimal?

2012-04-12 Thread Carlos
Hi,

Is it possible (and how) to change a field type from string to decimal 
without recreating the table?.

There are no records in the table yet, but I would like to know if there's 
a way to accomplish this from web2py (without recreating the database).

The error I get:

 column "xfield__tmp" is of type numeric 
but expression is of type character varying LINE 1: UPDATE xtable SET 
xfield__tmp=xfield; ^ HINT: You will need to rewrite or cast the 
expression. 

I'm using latest web2py trunk with postgresql.

Thanks,

   Carlos



Re: [web2py] how to change a field type from string to decimal?

2012-04-12 Thread Carlos Costa
The database wont be recreated.
And you could change the field name temporally.

2012/4/12 Carlos :
> Hi,
>
> Is it possible (and how) to change a field type from string to decimal
> without recreating the table?.
>
> There are no records in the table yet, but I would like to know if there's a
> way to accomplish this from web2py (without recreating the database).
>
> The error I get:
>
>  column "xfield__tmp" is of type numeric
> but expression is of type character varying LINE 1: UPDATE xtable SET
> xfield__tmp=xfield; ^ HINT: You will need to rewrite or cast the
> expression.
>
> I'm using latest web2py trunk with postgresql.
>
> Thanks,
>
>    Carlos
>



-- 
Carlos J. Costa
Cientista da Computação
Esp. Gestão em Telecom

EL MELECH NEEMAN!
אָמֵן


[web2py] Re: How to add an input field in SQLFORM.grid??

2012-04-12 Thread greenpoise
Massimo,

where do I change the INPUT size (length, width)?



links = [lambda row: INPUT(_name='quantity', _class='integer', _value=1)]




On Wednesday, 11 April 2012 18:34:16 UTC-7, Massimo Di Pierro wrote:
>
> yes and not and what I said needs clarification.
>
> grid = SQLFORM.grid(create=False,update=False) is not a form. If 
> create=True or update=True then it contains a form when you are creating or 
> updating a record. you must avoind a form within a form and you can do so 
> in the view:
>
> {{if grid.create_form or grid.update_form:}}
> {{=grid}} it is a form
> {{else:}}
> {{=grid}} it is not a form but you can embed it in one  type='submit'/>
> {{pass}}
>
>
> On Wednesday, 11 April 2012 20:23:08 UTC-5, greenpoise wrote:
>>
>> A bit confused..I thought SQLFORM.grid was itself a form? Also, can I add 
>> more than one link per grid? Reading from the book, it creates a column so 
>> technically sounds as if I could???
>>
>> On Wednesday, 11 April 2012 16:27:17 UTC-7, Massimo Di Pierro wrote:
>>>
>>> You can put the grid in a form and you add 
>>>
>>> SQLFORM.grid(..., link=[lambda row: INTPUT(...)])
>>>
>>> On Wednesday, 11 April 2012 17:07:58 UTC-5, greenpoise wrote:

 Is this possible?? I have a products table that shows all the products. 
 I also created an add to cart button in it problem is if I want to add 100 
 items I would have to press the button 100 times.  Is there a way to add a 
 quantity text field???


 Thanks

 Dan

>>>
>> On Wednesday, 11 April 2012 16:27:17 UTC-7, Massimo Di Pierro wrote:
>>>
>>> You can put the grid in a form and you add 
>>>
>>> SQLFORM.grid(..., link=[lambda row: INTPUT(...)])
>>>
>>> On Wednesday, 11 April 2012 17:07:58 UTC-5, greenpoise wrote:

 Is this possible?? I have a products table that shows all the products. 
 I also created an add to cart button in it problem is if I want to add 100 
 items I would have to press the button 100 times.  Is there a way to add a 
 quantity text field???


 Thanks

 Dan

>>>

[web2py] Re: Downloaded file size differs from the original file size.

2012-04-12 Thread nick name
On Wednesday, April 11, 2012 5:56:22 AM UTC-4, Changju wrote:
>
> I put a file on the static folder, let say 'testApp/static'. 
> And I download the file on static folder, the downloaded file differs from 
> the original file in size.
> Original file size is 15,227,904 and 15,096,832 for downloaded file.
>

This is a known rocket bug, which was reported to the rocket maintainer a 
long time ago but was not fixed.

Use a different webserver, e.g. tornado or scgi (see "anyserver", for 
example). Note: do not just use apache/nginx to redirect to rocket - you 
must not use rocket at all to solve this problem.

See: https://github.com/explorigin/Rocket/issues/1 for the upstream bug 
report, https://groups.google.com/d/topic/web2py/1_b63bhBeQs/discussion for 
a previous discussion in this mailing list.



Re: [web2py] Re: How to add an input field in SQLFORM.grid??

2012-04-12 Thread Richard Vézina
Hello Danel,

May I see screenshot of what Massimo propose?

I mean I would be really interrested in a bulk entry capability too.

If it is already available I would know I was about to make a custom
mechanism to allow user to add many result at the same time that would rely
on Excel and validate_and_insert web2py method...

The problem I had was to read directly Excel file, I would need to write a
lot of code with xlrd. If I can avoid that I will be happy :)

Thanks.

Richard

On Thu, Apr 12, 2012 at 5:14 PM, greenpoise  wrote:

> Massimo,
>
> where do I change the INPUT size (length, width)?
>
>
>
> links = [lambda row: INPUT(_name='quantity', _class='integer', _value=1)]
>
>
>
>
>
> On Wednesday, 11 April 2012 18:34:16 UTC-7, Massimo Di Pierro wrote:
>>
>> yes and not and what I said needs clarification.
>>
>> grid = SQLFORM.grid(create=False,**update=False) is not a form. If
>> create=True or update=True then it contains a form when you are creating or
>> updating a record. you must avoind a form within a form and you can do so
>> in the view:
>>
>> {{if grid.create_form or grid.update_form:}}
>> {{=grid}} it is a form
>> {{else:}}
>> {{=grid}} it is not a form but you can embed it in one > type='submit'/>
>> {{pass}}
>>
>>
>> On Wednesday, 11 April 2012 20:23:08 UTC-5, greenpoise wrote:
>>>
>>> A bit confused..I thought SQLFORM.grid was itself a form? Also, can I
>>> add more than one link per grid? Reading from the book, it creates a column
>>> so technically sounds as if I could???
>>>
>>> On Wednesday, 11 April 2012 16:27:17 UTC-7, Massimo Di Pierro wrote:

 You can put the grid in a form and you add

 SQLFORM.grid(..., link=[lambda row: INTPUT(...)])

 On Wednesday, 11 April 2012 17:07:58 UTC-5, greenpoise wrote:
>
> Is this possible?? I have a products table that shows all the
> products. I also created an add to cart button in it problem is if I want
> to add 100 items I would have to press the button 100 times.  Is there a
> way to add a quantity text field???
>
>
> Thanks
>
> Dan
>

>>> On Wednesday, 11 April 2012 16:27:17 UTC-7, Massimo Di Pierro wrote:

 You can put the grid in a form and you add

 SQLFORM.grid(..., link=[lambda row: INTPUT(...)])

 On Wednesday, 11 April 2012 17:07:58 UTC-5, greenpoise wrote:
>
> Is this possible?? I have a products table that shows all the
> products. I also created an add to cart button in it problem is if I want
> to add 100 items I would have to press the button 100 times.  Is there a
> way to add a quantity text field???
>
>
> Thanks
>
> Dan
>



Re: [web2py] Re: Mimicking HTML5 pattern attribute for inputs

2012-04-12 Thread Anthony

>
> The h5Validate does the trick for me. I can't get Webshims to work so that 
> wasn't a viable option. It is all-enclusive so it is a more ideal solution 
> than h5 but for some reason I have trouble making some js work with things 
> like web2py.
>
It should work. Perhaps you're loading it before jQuery. Note, if using the 
default layout.html with {{include 'web2py_ajax.html'}}, jQuery will be 
loaded automatically by web2py_ajax.html -- so anything that depends on 
jQuery should be loaded after that. If you're adding it to response.files, 
you must do so before {{include 'web2py_ajax.html'}} because response.files 
is actually processed within web2py_ajax.html (jQuery is automatically 
inserted before all other files in response.files, so no need to worry 
about jQuery dependencies).
 

> One last thing, if you will. Where can you find the programming for the 
> response.flash?
>
The default layout.html view includes the following:

{{=response.flash or ''}}

So, the styling is controlled by the CSS for the "flash" class in 
web2py.css. Animation is controlled by code in web2py.js:

jQuery(function() {
   var flash = jQuery('.flash');
   flash.hide();
   if(flash.html()) flash.slideDown();
   web2py_ajax_init(document);
   web2py_event_handlers();
});

You can either edit that JS code, or just use your own custom class for the 
flash message so the web2py code won't have any affect on it.

Anthony


[web2py] menu issues when no subitems

2012-04-12 Thread anonymouse
Hi,

[FYI, my problem is SOLVED -- But I still wonder about this...]

I have been using a menu with web2py since v1.8x (currently 1.98.2). I now 
have 3 different versions running on three different servers. 

PRODUCTION -- 1.98.2 -- menu is OK
TEST - 1.99.3 -- menu is screwy
DEV - 1.99.4 -- menu is screwy

Now the problem is that when I created a menu, it didn't load properly 
unless I had subitems in it -- I have dividing images that load between the 
top level menu items, and if the top level item doesn't contain children, 
then the dividing images wouldn't load.

Ok, so I managed to get past that by adding an "empty" menu row:

empty = (T(''), False, URL(), [])

Now, on web2py<=1.98.2 this is fine -- the menu class decides not to create 
a dropdown and all is well.

However, on 1.99.{3,4} the menu is "screwy": it creates an empty dropdown 
with a computed height of 4px, which contains an li and anchor, but no text 
nodes. Now, removing the "empty" and just using an empty list gives me the 
image issue (so maybe that's my fault and I should relook at that and 
choose different css selectors). 

So I guess I'm wondering if anyone else had a problem with Top-Level Menu 
items with NO children not getting the proper class they need to style 
their menus appropriately? Anyone have an inkling as to what I'm doing 
wrong from what I've described? I'm wondering if it has anything to do with 
the new "mobile" code for menus?


If not, then I guess this whole post is moot, and I'm doing something 
stupid somewhere, but if so, lemme know!

Thanks!



PS:
here's my solution that allows you to use "None" or an empty tuple "()" 
inside of the list arg:

In web2py/gluon/html.py, COPY (don't modify in place!!) the entire MENU 
class into your models file (or modules and import in models, but it really 
doesn't matter), and add these lines inside of the "serialize" function:

if not item or len(item)<3:
  continue

right after the "for item in data" loop, so serialize would look like so:

 def serialize(self, data, level=0):
if level == 0:
ul = UL(**self.attributes)
else:
ul = UL(_class=self['ul_class'])
for item in data:
if not item or len(item) < 3:
  continue
(name, active, link) = item[:3]
if isinstance(link,DIV):
li = LI(link)
elif 'no_link_url' in self.attributes and self['no_link_url']==
link:
li = LI(DIV(name))
elif link:
li = LI(A(name, _href=link, _title=name))
else:
li = LI(A(name, _title=name, _href='#',
  _onclick='javascript:void(0):return false'))
if len(item) > 3 and item[3]:
li['_class'] = self['li_class']
li.append(self.serialize(item[3], level+1))
if active or ('active_url' in self.attributes and self[
'active_url']==link):
if li['_class']:
li['_class'] = li['_class']+' '+self['li_active']
else:
li['_class'] = self['li_active']
ul.append(li)
return ul


Then in your Menu do:


empty = None # or empty = () 
response.menu = [
  (T('Whatever'), False, URL(...wherever...), [empty]),
  ...
]






Re: [web2py] Re: web2py: encrypt uploaded files

2012-04-12 Thread Naveed Ahmed
I wasn’t asking as how to encrypt the file itself, but how to incorporate it in 
to web2py’s existing excellent form upload and download system. Assuming that 
we have functions encrypt(file, password) and decrypt(file, password) which 
return the encrypted and decrypted file respectively.


From: Massimo Di Pierro 
Sent: Wednesday, April 11, 2012 13.31
To: web2py@googlegroups.com 
Subject: Re: [web2py] Re: web2py: encrypt uploaded files

Perhaps this can be useful: 
http://stackoverflow.com/questions/6309958/encrypting-a-file-with-rsa-in-python
(look at code in first answer)

On Wednesday, 11 April 2012 12:35:05 UTC-5, naveed wrote: 
  Thanks Massimo for getting back. I can’t use an encrypted file system as when 
the file system is mounted, it’s totally open. Every file can be encrypted with 
the same master password. I’m thinking of storing this master password which is 
itself encrypted using the user’s password (or it’s hash) in the auth_user 
table.

  On a related note, I am planning to encrypt some columns of other tables 
using the same master password. Your thoughts on this approach?


  From: Massimo Di Pierro 
  Sent: Wednesday, April 11, 2012 12.13
  To: web2py@googlegroups.com 
  Subject: [web2py] Re: web2py: encrypt uploaded files

  What are the specs? Can you store them in an encrypted file system? can you 
encrypt them with the same password? Should every file be encrypted with a 
different password? Where should the passwords be stored?

  On Wednesday, 11 April 2012 11:54:24 UTC-5, naveed wrote: 
I need to encrypt uploaded files in web2py (for a HIPAA compliant 
application) preferably with AES. How can I accomplish this?


RE: [web2py] Re: web2py: encrypt uploaded files

2012-04-12 Thread Alvaro Lizama
You should make a custom validator for encrypt files.  

--  
Alvaro Lizama  
http://alvarolizama.net


El jueves 12 de abril de 2012 a las 16:35, Naveed Ahmed escribió:

> I wasn’t asking as how to encrypt the file itself, but how to incorporate it 
> in to web2py’s existing excellent form upload and download system. Assuming 
> that we have functions encrypt(file, password) and decrypt(file, password) 
> which return the encrypted and decrypted file respectively.
>  
>  
> From: Massimo Di Pierro (mailto:massimo.dipie...@gmail.com)  
> Sent: Wednesday, April 11, 2012 13.31
> To: web2py@googlegroups.com (mailto:web2py@googlegroups.com)  
> Subject: Re: [web2py] Re: web2py: encrypt uploaded files
>  
>  
>  
> Perhaps this can be useful:  
> http://stackoverflow.com/questions/6309958/encrypting-a-file-with-rsa-in-python
> (look at code in first answer)
>  
> On Wednesday, 11 April 2012 12:35:05 UTC-5, naveed wrote:  
> > Thanks Massimo for getting back. I can’t use an encrypted file system as 
> > when the file system is mounted, it’s totally open. Every file can be 
> > encrypted with the same master password. I’m thinking of storing this 
> > master password which is itself encrypted using the user’s password (or 
> > it’s hash) in the auth_user table.
> >  
> > On a related note, I am planning to encrypt some columns of other tables 
> > using the same master password. Your thoughts on this approach?
> >  
> >  
> > From: Massimo Di Pierro (mailto:massimo.dipie...@gmail.com)  
> > Sent: Wednesday, April 11, 2012 12.13
> > To: web2py@googlegroups.com (mailto:web2py@googlegroups.com)  
> > Subject: [web2py] Re: web2py: encrypt uploaded files
> >  
> >  
> >  
> > What are the specs? Can you store them in an encrypted file system? can you 
> > encrypt them with the same password? Should every file be encrypted with a 
> > different password? Where should the passwords be stored?
> >  
> > On Wednesday, 11 April 2012 11:54:24 UTC-5, naveed wrote:  
> > > I need to encrypt uploaded files in web2py (for a HIPAA compliant 
> > > application) preferably with AES. How can I accomplish this?
> >  
>  





[web2py] Default table schema for the Auth tables

2012-04-12 Thread cyan

Hi group,

Is there anywhere I can find the default schema for the tables involved in 
Auth provided by Web2py, namely,

'auth_user'
'auth_group'
'auth_membership'
'auth_permission'
'auth_event'

They're described in the the manual but I would like to see the exact field 
definitions for each of them, if possible. In addition, can we remove 
fields from these tables? I know we can add extra fields or re-define the 
whole table from scratch to replace them. Thanks!


Re: [web2py] Re: web2py: encrypt uploaded files

2012-04-12 Thread Derek
You put it on the 'accept' or else you make it a job in cron.

On Thursday, April 12, 2012 2:35:36 PM UTC-7, naveed wrote:
>
>   I wasn’t asking as how to encrypt the file itself, but how to 
> incorporate it in to web2py’s existing excellent form upload and download 
> system. Assuming that we have functions encrypt(file, password) and 
> decrypt(file, password) which return the encrypted and decrypted file 
> respectively.
>  
>   
>  *From:* Massimo Di Pierro  
> *Sent:* Wednesday, April 11, 2012 13.31
> *To:* web2py@googlegroups.com 
> *Subject:* Re: [web2py] Re: web2py: encrypt uploaded files
>  
> Perhaps this can be useful: 
>
> http://stackoverflow.com/questions/6309958/encrypting-a-file-with-rsa-in-python
> (look at code in first answer)
>
> On Wednesday, 11 April 2012 12:35:05 UTC-5, naveed wrote: 
>>
>>   Thanks Massimo for getting back. I can’t use an encrypted file system 
>> as when the file system is mounted, it’s totally open. Every file can be 
>> encrypted with the same master password. I’m thinking of storing this 
>> master password which is itself encrypted using the user’s password (or 
>> it’s hash) in the auth_user table.
>>  
>> On a related note, I am planning to encrypt some columns of other tables 
>> using the same master password. Your thoughts on this approach?
>>  
>>   
>>  *From:* Massimo Di Pierro  
>> *Sent:* Wednesday, April 11, 2012 12.13
>> *To:* web2py@googlegroups.com 
>> *Subject:* [web2py] Re: web2py: encrypt uploaded files
>>  
>> What are the specs? Can you store them in an encrypted file system? can 
>> you encrypt them with the same password? Should every file be encrypted 
>> with a different password? Where should the passwords be stored?
>>
>> On Wednesday, 11 April 2012 11:54:24 UTC-5, naveed wrote: 
>>>
>>> I need to encrypt uploaded files in web2py (for a HIPAA compliant 
>>> application) preferably with AES. How can I accomplish this?
>>>
>>

[web2py] Re: Default table schema for the Auth tables

2012-04-12 Thread villas
One way is to look directly at the code in gluon/tools.py
Under Class Auth try searching for define_table etc.
I doubt that you would be able to safely remove fields though.


On Thursday, 12 April 2012 23:23:21 UTC+1, cyan wrote:
>
>
> Hi group,
>
> Is there anywhere I can find the default schema for the tables involved in 
> Auth provided by Web2py, namely,
>
> 'auth_user'
> 'auth_group'
> 'auth_membership'
> 'auth_permission'
> 'auth_event'
>
> They're described in the the manual but I would like to see the exact 
> field definitions for each of them, if possible. In addition, can we remove 
> fields from these tables? I know we can add extra fields or re-define the 
> whole table from scratch to replace them. Thanks!
>


[web2py] Re: Default table schema for the Auth tables

2012-04-12 Thread Anthony
Look at the define_tables method of the Auth class in /gluon/tools.py: 
http://code.google.com/p/web2py/source/browse/gluon/tools.py#1299. I'm not 
sure there's a good way to remove individual fields, but if you don't want 
them, you can always set their readable and writable attributes to False, 
so they won't appear in any forms (including registration and profile).

Anthony 

On Thursday, April 12, 2012 6:23:21 PM UTC-4, cyan wrote:
>
>
> Hi group,
>
> Is there anywhere I can find the default schema for the tables involved in 
> Auth provided by Web2py, namely,
>
> 'auth_user'
> 'auth_group'
> 'auth_membership'
> 'auth_permission'
> 'auth_event'
>
> They're described in the the manual but I would like to see the exact 
> field definitions for each of them, if possible. In addition, can we remove 
> fields from these tables? I know we can add extra fields or re-define the 
> whole table from scratch to replace them. Thanks!
>


[web2py] Re: how to change a field type from string to decimal?

2012-04-12 Thread pbreit
This might not work because I'm not sure changing from a string to decimal 
is straightforward (if the column was not empty). Per the docs, it may need 
a "using" clause: 
http://www.postgresql.org/docs/current/static/sql-altertable.html

Alternatively, you could delete the Field from your model and then re-add 
it.

To be safe, you might want to use a tool like pgAdmin or Navicat.


[web2py] Re: Downloaded file size differs from the original file size.

2012-04-12 Thread Changju
Yes, I just installed Apache + web2py and It worked perfectly.
Thanks~:)


On Friday, April 13, 2012 6:16:05 AM UTC+9, nick name wrote:
>
> On Wednesday, April 11, 2012 5:56:22 AM UTC-4, Changju wrote:
>>
>> I put a file on the static folder, let say 'testApp/static'. 
>> And I download the file on static folder, the downloaded file differs 
>> from the original file in size.
>> Original file size is 15,227,904 and 15,096,832 for downloaded file.
>>
>
> This is a known rocket bug, which was reported to the rocket maintainer a 
> long time ago but was not fixed.
>
> Use a different webserver, e.g. tornado or scgi (see "anyserver", for 
> example). Note: do not just use apache/nginx to redirect to rocket - you 
> must not use rocket at all to solve this problem.
>
> See: https://github.com/explorigin/Rocket/issues/1 for the upstream bug 
> report, https://groups.google.com/d/topic/web2py/1_b63bhBeQs/discussionfor a 
> previous discussion in this mailing list.
>
>