Re: [web2py] Re: Resources for setting up for development

2012-01-16 Thread Philip Kilner

Hi,

On 16/01/2012 01:25, pbreit wrote:

My sense is that few Python programmers use IDEs (I don't know any that
do). If it's a brief talk, I'd suggest just using the file system and a
good text editor and moving quickly to some of the great features of
Web2py. If someone complains about code completion, you can say it's
possible (with Anthony's suggestion) and move on.


Yes - Anthony's suggestion is close to what I use (I seem to have a long 
explicit list, but the effect is the same).


I don't want to get hung up on this because it's trivial, really - it's 
just that the "magic import" thing is where people seem to focus, and 
since this is related I didn't want to pass on out of date info or 
contradict the consensus as to what is best practice.



--

Regards,

PhilK


'a bell is a cup...until it is struck'



[web2py] Re: form checkbox keepvalues

2012-01-16 Thread niktar
Thanx, Massimo!
It works!

But why not just set keepvalues=True?
I thought this should be sufficient.


[web2py] Auth with Google Oauth2 - Google Plus, Gmail and other scopes

2012-01-16 Thread Bruno Rocha
Hi,

I just implemented Google Connect Oauth2 in http://movu.ca/demo

If someone interested in the code it is in

https://github.com/rochacbruno/Movuca/blob/master/modules/oauth20_account_google.py(modified
module)
https://github.com/rochacbruno/Movuca/blob/master/modules/helpers/googleplus.py(modified
handler, can go in models or modules)
https://github.com/rochacbruno/Movuca/blob/master/modules/handlers/person.py#L378(action
handler)
https://github.com/rochacbruno/Movuca/blob/master/controllers/person.py#L95(controller)

It is based in the facebook version with some changes, but still needs
improvements.

To use it you have to create API keys in
https://code.google.com/apis/console/ and the other things will be just
like the facebook version. I guess the twitter version can be implemented
in the same way.

** im my code I am using Movuca config to get the option values, you just
need to replace them with your API keys.

I also found an issue in Auth
http://code.google.com/p/web2py/issues/detail?id=616


-- 

Bruno Rocha
[http://rochacbruno.com.br]


[web2py] Question about many to many forms

2012-01-16 Thread Thiago Magro
Hello everyone,

I have a question with forms for many to many relations and I just cant
find the answer.

Its possible to have forms inside forms?
For example:
I have a model Food that has inside a lot of components(nutrients). So Food
has many components.
Is there any chances that I could create a form for a food, and on the same
form create a lot of "subforms" to create each food component as well?
And going further, is it possible to edit a food and its components on the
same form?

What I looking for is something like acccept_nested_attributes from Rails.

Thanks for any help!

Thiago


Re: [web2py] Auth with Google Oauth2 - Google Plus, Gmail and other scopes

2012-01-16 Thread Michele Comitini
Hi Bruno,

Do you think we can integrate all in one oath20 module?

tnx

mic

2012/1/16 Bruno Rocha :
> Hi,
>
> I just implemented Google Connect Oauth2 in http://movu.ca/demo
>
> If someone interested in the code it is in
>
> https://github.com/rochacbruno/Movuca/blob/master/modules/oauth20_account_google.py
> (modified module)
> https://github.com/rochacbruno/Movuca/blob/master/modules/helpers/googleplus.py
> (modified handler, can go in models or modules)
> https://github.com/rochacbruno/Movuca/blob/master/modules/handlers/person.py#L378
> (action handler)
> https://github.com/rochacbruno/Movuca/blob/master/controllers/person.py#L95
> (controller)
>
> It is based in the facebook version with some changes, but still needs
> improvements.
>
> To use it you have to create API keys in
> https://code.google.com/apis/console/ and the other things will be just like
> the facebook version. I guess the twitter version can be implemented in the
> same way.
>
> ** im my code I am using Movuca config to get the option values, you just
> need to replace them with your API keys.
>
> I also found an issue in Auth
> http://code.google.com/p/web2py/issues/detail?id=616
>
>
> --
>
> Bruno Rocha
> [http://rochacbruno.com.br]
>


Re: [web2py] Re: Cherrypy can run on android ! without any patching needed , Can Rocket do that?

2012-01-16 Thread Phyo Arkar
There wont be much cons. I havn't tested tho.
I tested cherrypy and works well , going to test Web2py with Nik's patch on
my android tab.
With web2py it will open alot of possiblities to android. Thats cool!.




On Mon, Jan 16, 2012 at 3:24 AM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> Nice. perhaps we could by-pass shelve and provide out own
> implementation based on sqlite. Actually I have this coded already...
> pros, cons?
>
> On Jan 15, 4:28 am, Nik Klever  wrote:
> > web2py runs on Android - I've tested it with my Motorola Defy. The only
> > problems, I discovered until now concerns the cache:
> >
> > 1. gluon/cache.py uses the python standard library shelve. And shelve on
> > Android uses dumbdbm instead of anydbm as normally on unix systems, this
> > leads to problems in creating new database files for caching - in web2py
> > therefor in creating applications. I solved this with a short workaround
> > of cache.py (see attachment) and a default cache-archive (see
> > attachment). This is still a workaround, because this problem should be
> > solved by shelve in the standard library and not by web2py !
> >
> > The attachments can be found on my server:
> http://klever.hs-augsburg.de/Veranstaltungen/page/informationen#web2p...
> >
> > 2. additionally cache problems on Android is caused by the disk cache
> > functionality - I haven't looked into this problem in detail, because
> > web2py works also without disk caching and the normal use-case for
> > web2py on Android is for single-users - it does not makes any sense to
> > use it as a server for more than one user !
> >
> > Greetings,
> > Nik
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > > I did not try but I think yes because it does not use any additional
> > > libraries.
> >
> > > On Jan 14, 6:50 am, Phyo Arkar  wrote:
> > > > I cant wait to run Web2py on my android 8 inches and 10 inches
> tablets and
> > > > develop inside there.
> > > > But i see this tutorial : Cherrypy on Android!
> >
> > > > Can we hack rocket to run on android and then we should be able to
> run
> > > > web2py on there!
> http://www.defuze.org/archives/228-running-cherrypy-on-android-with-s...
> >
> > > > Anyone up for that?
> >
> > > > Thanks
> >
> > > > Phyo.
> >
> > --
> >
> > __
> > Prof. Dr. Nik Klever
> > - Studiendekan -
> > __
> > Hochschule Augsburg - Fakultät für Informatikhttp://
> www.hs-augsburg.de/informatik/
> > mailto:nik.kle...@hs-augsburg.de
> > __


[web2py] SOLVED Re: Inline image generation with matplotlib

2012-01-16 Thread andrej burja
this works
controller:
def image():
return dict(a=IMG(_src=URL('myimage'+'.png')))
view:
{{extend 'layout.html'}}
This is the graph/image.html template
{{=a}}

but this doesn't
controller:
def image():
return myimage()
view:
{{extend 'layout.html'}}
This is the graph/slika1.html template
{{=IMG(_src=URL('myimage'+'.png'))}}




Re: [web2py] Represent - redirect

2012-01-16 Thread Johann Spies
On 15 January 2012 22:49, Mathias Van Daele wrote:

> Hello,
>
> I have a select crud, with a URL in the column id.
>
> If I click 'edit', I should be redirected to a page, where I can
> update the concerned contact_part record.
> (as in a grid)
>
> What should I put between the URL brackets ?  _href=URL()
>
> How do I pass the selected record ?
>
>
I use something like this in the model:

db.akb_country.id.represent = \
lambda id, record: A('edit',
 _href = URL(r = request, c = 'default', # c refers
to controller
   f = 'edit_akb_country', # f : the
function in the controller
   args = str(id)))

Regards
Johann

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


[web2py] For trick

2012-01-16 Thread Web2Py Freak
Dear all ,

i am geting some images from the database and viewing them in the
page  i am using a for loop for the images and i want to have a 
after every 4 images  ,, how can i do somthing like this ??


Re: [web2py] For trick

2012-01-16 Thread Kenneth Lundström

Please show us some code how you are doing it at the moment


Kenneth


Dear all ,

i am geting some images from the database and viewing them in the
page  i am using a for loop for the images and i want to have a
after every 4 images  ,, how can i do somthing like this ??




[web2py] query with T in a grid

2012-01-16 Thread Martin Weissenboeck
Hi,

I have a grid=SQLFORM.grid(...searchable = True,...)
A query like 'auth_user.last_name starts with "c"' works fine.
Using the T-operator 'starts with' becomes (in German) 'beginnend mit' and
the whole query 'auth_user.last_name beginnend mit "c"'. This gives the
result "Invalid query".

I think, a solution would not be simple...

Regards, Martin


[web2py] Default/index fails to load

2012-01-16 Thread Andrew Evans
Just upgraded web2py to the latest version (1.99.4) and it fails to load my
default/index pages on a few of my sites. Other pages work fine

Any ideas what I am doing wrong? maybe something to do with routes?

was working fine before

*cheers


[web2py] Re: Default/index fails to load

2012-01-16 Thread Andrew Evans
Ok seems to be an issue using datetime or date

Sorry about double posting if I did I may have posted on the wrong email. I
appreciate any help though not sure what I need to post to get further help


ValueError: invalid literal for int() with base 10




On Sun, Jan 15, 2012 at 6:43 PM, Andrew Evans wrote:

> Just upgraded web2py to the latest version (1.99.4) and it fails to load
> my default/index pages on a few of my sites. Other pages work fine
>
> Any ideas what I am doing wrong? maybe something to do with routes?
>
> was working fine before
>
> *cheers


[web2py] web2py + cgi

2012-01-16 Thread Eduardo Bergavera
Hi There,

I would like to solicit your opinion on whether web2py supports CGI
and that it allows you to develop web apps using the framework. I plan
to develop a web-based systems management tool for Ubuntu similar to
webmin with features from Canonical's Landscape systems management
tool.

Thanks.

Eduardo D. Bergavera, Jr.


[web2py] Re: Default/index fails to load

2012-01-16 Thread Andrew Evans
After a bit of research this is what I found the table which caused an
error (it has been removed temporarily) but

db.define_table('trailer',
   Field('userinfo', db.auth_user, default=auth.user_id, readable=False,
writable=False),
   Field('title',requires=IS_NOT_EMPTY()),
   Field('description','text',requires=IS_NOT_EMPTY()),
   Field('keywords'),
   Field('trailer_link',requires=IS_NOT_EMPTY(),label='Trailer
Embed',comment='Enter Your Trailer embed code here'),
   Field('image','upload', label='Image', autodelete=True,
requires=[IS_IMAGE(extensions=('png', 'gif', 'jpg', 'jpeg')), RESIZE(600,
340)]),
   Field('image_thumb', 'upload', compute=lambda r: THUMB(r['image'], 120,
64)),   Field('views','integer',default=1,readable=False,writable=False),

Field('created_on','datetime',default=request.now,readable=False,writable=False),
   Field('air_date','date',requires=IS_NOT_EMPTY()))

the query

trailers = db(db.trailer.id>0).select(orderby=~db.trailer.air_date)

and the

html

{{for trailer in trailers:}}
   
  {{pass}}

seemed to cause on invalid literal for base 10 on the date data :-| if
anyone has suggestions on how to fix this cause I would still like to use
this feature

*cheers

Andrew


Re: [web2py] For trick

2012-01-16 Thread Manuele Pesenti

Il 16/01/2012 14:02, Web2Py Freak ha scritto:

Dear all ,

i am geting some images from the database and viewing them in the
page  i am using a for loop for the images and i want to have a
after every 4 images  ,, how can i do somthing like this ??

consider to use enumerate and test if the defined index is equal to 4

hope it helps

M.


[web2py] Re: For trick

2012-01-16 Thread LightDot
Another solution would be to use css. Use divs for individual photos and 
than assign a class with float, that should do it nicely.


[web2py] Re: For trick

2012-01-16 Thread Anthony
{{for (i + 1, image) in enumerate(images):}}
{{=i % 4 == 0 and '' or 
''}}
{{pass}}

Anthony

On Monday, January 16, 2012 8:02:52 AM UTC-5, Web2Py Freak wrote:
>
> Dear all , 
>
> i am geting some images from the database and viewing them in the 
> page  i am using a for loop for the images and i want to have a  
> after every 4 images  ,, how can i do somthing like this ??



[web2py] Re: query with T in a grid

2012-01-16 Thread Martin Weissenboeck
Maybe the search_widget parameter of grid is a solution.

2012/1/16 Martin Weissenboeck 

> Hi,
>
> I have a grid=SQLFORM.grid(...searchable = True,...)
> A query like 'auth_user.last_name starts with "c"' works fine.
> Using the T-operator 'starts with' becomes (in German) 'beginnend mit' and
> the whole query 'auth_user.last_name beginnend mit "c"'. This gives the
> result "Invalid query".
>
> I think, a solution would not be simple...
>
> Regards, Martin
>
>
>


[web2py] Re: For trick

2012-01-16 Thread Web2Py Freak
Thnx Anthony , thank you all guys  its working well now :)


[web2py] Re: web2py + cgi

2012-01-16 Thread Anthony
Yes -- see http://web2py.com/books/default/chapter/29/13 
and http://code.google.com/p/web2py/source/browse/cgihandler.py.

On Monday, January 16, 2012 6:18:10 AM UTC-5, Eduardo Bergavera wrote:
>
> Hi There,
>
> I would like to solicit your opinion on whether web2py supports CGI
> and that it allows you to develop web apps using the framework. I plan
> to develop a web-based systems management tool for Ubuntu similar to
> webmin with features from Canonical's Landscape systems management
> tool.
>
> Thanks.
>
> Eduardo D. Bergavera, Jr.
>
>

[web2py] Re: matplotlib plugin

2012-01-16 Thread andrej burja
i've installed the latest verson of matplotlib (from source, also libpng 
and freetype)
now matplotlib is working

but using MATLAB a lot, i have one question: is it possible to 
usematplotlib.pyplot instead of matplotlib api (matplotlib.figure) and not 
saving the file (sendign directly to view)? or si pyplot only for gui 
programming?

Andrej 


[web2py] using the calender in appadmin

2012-01-16 Thread Web2Py Freak
Dear All,

How can i use the calender from the appadmin in another page ?


[web2py] Re: using the calender in appadmin

2012-01-16 Thread Anthony
Are you talking about the date picker? It should work on any page with 
input fields that have class "date", "time", or "datetime". Your layout 
view should include web2py_ajax.html, which will automatically include the 
required web2py.js and calendar.js files.

Anthony

On Monday, January 16, 2012 10:36:52 AM UTC-5, Web2Py Freak wrote:
>
> Dear All, 
>
> How can i use the calender from the appadmin in another page ?



[web2py] Re: How is the best way to export/import auth_user database?

2012-01-16 Thread thstart
yes, how to have same ID's?

[web2py] Re: Set table name

2012-01-16 Thread Marcello
Would be great

This solution works great... but it's not accessible in the modules
files, because dog is not visible there...



On 14 jan, 15:21, Massimo Di Pierro 
wrote:
> eventually we shoud have a way to remap table and field names that was
> one of the main reason for rewriting the dal.
>
> On Jan 10, 10:51 am, MarcelloParra wrote:
>
>
>
>
>
>
>
> > Hello Massimo and all,
>
> > I'm trying to use web2py for several projects of mine.
> > I always find a problem that should be solved if I could set the table name.
>
> > Let me show an example...
>
> > Suppose that I have this:
>
> > db.define_table('person12345', Field('name'))
> > db.define_table('dog12345', Field('name'), Field('owner', db.person))
>
> > person12345 and dog12345 are names of the tables.
> > As they are already running projects, I can't change them...
>
> > If I don't want to call a dog, dog12345 all the time, I could do this:
>
> > person=db.define_table('person12345', Field('name'))
> > dog=db.define_table('dog12345', Field('name'), Field('owner', db.person))
>
> > This should work fine.
>
> > But I can't do this:
> > person[1].dog.select()
>
> > This should just work with:
> > person[1].dog12345.select()
>
> > Is there a way to do this ?
>
> > Thanks...


[web2py] Re: How is the best way to export/import auth_user database?

2012-01-16 Thread Anthony
Do you want to migrate the entire db? If so, then 
follow http://web2py.com/books/default/chapter/29/6#CSV-(all-tables-at-once). 
If you just want to migrate the Auth tables, I suppose you could 
temporarily change your model files so only the Auth tables are defined (or 
some subset of tables). Then when you run db.export_to_csv_file(), it will 
only export the tables defined in your models. Upon import, it won't 
preserve the original id's, but it will preserve all references among those 
tables as it constructs new id's.

If you're really only exporting and importing the auth_user table by 
itself, then why do you need to preserve id's? If you want to preserve 
references from other tables, you should probably export/import the entire 
set of inter-related tables together, as described above.

Anthony


On Monday, January 16, 2012 11:24:23 AM UTC-5, thstart wrote:
>
> yes, how to have same ID's?



[web2py] 3-table many-to-many with IS_IN_DB

2012-01-16 Thread sunny
Hi,

for days I try to find a solution for my problem which I'm sure
exists.
I want to create/update the many2many relationship
"auth_user -> auth_membership -> auth_group"
in an auth_user form with an "IS_IN_DB multiple=true"-widget.

How can I do that?

Thanks in advance,
Sven


[web2py] Re: How is the best way to export/import auth_user database?

2012-01-16 Thread thstart
It is a complex case. I am using GAE and already having users. Needed to 
change the database
structure, so I need to move to new GAE app. The simplest option is to 
re-invite the users but they are 100s. They will need to re-register again 
using email/password. Probably not big deal for them but I try to eliminate 
this step - if it is possible to migrate their accounts, then re-direct the 
domain to the new GAE app and when they access the new site, which will 
look the same they just have to login. But the ID's are used in the 
database for their membership. If their ID's are different it will not 
work. I am using the native GAE models for speed. web2py - only the auth 
functionality plus the generated ID's. 






Re: [web2py] Auth with Google Oauth2 - Google Plus, Gmail and other scopes

2012-01-16 Thread Bruno Rocha
yes we can! the difference is only some keys passed to auth and token url,
also the redirect page and the api caller.

I think we can create an api proxy to decide which class to use and have
the google/facebook/linkedin etc mappings in a single file.

I will try and if works I send a patch.

http://zerp.ly/rochacbruno
Em 16/01/2012 09:25, "Michele Comitini" 
escreveu:

> Hi Bruno,
>
> Do you think we can integrate all in one oath20 module?
>
> tnx
>
> mic
>
> 2012/1/16 Bruno Rocha :
> > Hi,
> >
> > I just implemented Google Connect Oauth2 in http://movu.ca/demo
> >
> > If someone interested in the code it is in
> >
> >
> https://github.com/rochacbruno/Movuca/blob/master/modules/oauth20_account_google.py
> > (modified module)
> >
> https://github.com/rochacbruno/Movuca/blob/master/modules/helpers/googleplus.py
> > (modified handler, can go in models or modules)
> >
> https://github.com/rochacbruno/Movuca/blob/master/modules/handlers/person.py#L378
> > (action handler)
> >
> https://github.com/rochacbruno/Movuca/blob/master/controllers/person.py#L95
> > (controller)
> >
> > It is based in the facebook version with some changes, but still needs
> > improvements.
> >
> > To use it you have to create API keys in
> > https://code.google.com/apis/console/ and the other things will be just
> like
> > the facebook version. I guess the twitter version can be implemented in
> the
> > same way.
> >
> > ** im my code I am using Movuca config to get the option values, you just
> > need to replace them with your API keys.
> >
> > I also found an issue in Auth
> > http://code.google.com/p/web2py/issues/detail?id=616
> >
> >
> > --
> >
> > Bruno Rocha
> > [http://rochacbruno.com.br]
> >
>


[web2py] Re: How is the best way to export/import auth_user database?

2012-01-16 Thread Anthony
If I understand correctly, GAE doesn't even use auto-increment integer 
fields for id's, so it may not be practical to keep the current id's 
anyway. Can't you export/import both the auth_user and the membership table 
together, so even though it will change the auth_user id's, it will also 
change those id's in the membership table reference field?

On Monday, January 16, 2012 12:37:55 PM UTC-5, thstart wrote:
>
> It is a complex case. I am using GAE and already having users. Needed to 
> change the database
> structure, so I need to move to new GAE app. The simplest option is to 
> re-invite the users but they are 100s. They will need to re-register again 
> using email/password. Probably not big deal for them but I try to eliminate 
> this step - if it is possible to migrate their accounts, then re-direct the 
> domain to the new GAE app and when they access the new site, which will 
> look the same they just have to login. But the ID's are used in the 
> database for their membership. If their ID's are different it will not 
> work. I am using the native GAE models for speed. web2py - only the auth 
> functionality plus the generated ID's. 
>
>
>
>
>

Re: [web2py] Re: priority of web2py CMS

2012-01-16 Thread Ross Peoples
I am also working on a CMS that will be a bit different than Movuca. The 
goal with my CMS is that I could stick an executive in front of it (someone 
who barely knows how to check their email), and allow them to theme their 
site, lay it out they way they want, and add content with a simple drag & 
drop interface.

That's goal. We will see if I can actually make it happen :)


[web2py] Re: How is the best way to export/import auth_user database?

2012-01-16 Thread thstart
you are correct - if I have a way to use GAE to populate auth table - this 
is the best way, but how to do that?

Re: [web2py] Re: matplotlib plugin

2012-01-16 Thread Mariano Reingart
You can send the image directly to the view, for an example see:

http://code.google.com/p/rad2py/source/browse/psp2py/modules/draws.py

http://code.google.com/p/rad2py/source/browse/psp2py/controllers/reports.py#243

Best regards,

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



On Mon, Jan 16, 2012 at 12:24 PM, andrej burja  wrote:
> i've installed the latest verson of matplotlib (from source, also libpng and
> freetype)
> now matplotlib is working
>
> but using MATLAB a lot, i have one question: is it possible to use
> matplotlib.pyplot instead of matplotlib api (matplotlib.figure) and not
> saving the file (sendign directly to view)? or si pyplot only for gui
> programming?
>
> Andrej


Re: [web2py] Re: Set table name

2012-01-16 Thread Marin Pranjić
On Sat, Jan 14, 2012 at 6:21 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> eventually we shoud have a way to remap table and field names that was
> one of the main reason for rewriting the dal.
>
>
This is good because without remapping apps cannot share the same database
(ie common-named tables, >1 instance of the same app, etc).
When can we expect this, is it low priority?
I was thinking about writing a patch few months ago but plans got lost in
my schedule.

On Mon, Jan 16, 2012 at 5:56 PM, Marcello  wrote:

> Would be great
>
> This solution works great... but it's not accessible in the modules
> files, because dog is not visible there...
>
> You can pass everything into modules using current object.
In controller:

current.db = db

in module

from gluon import current
def module_function():
db = current.db


don't do it as global, it should be inside some "module_function" bacause
it has to be executed for every request.



Marin


[web2py] Re: error class proposal

2012-01-16 Thread Massimo Di Pierro
Why do you want to add an "error" class to the input? The error class
is normally used for inputs. Perhaps I do not understand.

On Jan 15, 7:40 pm, David  wrote:
> I was thinking about the form validation.
>
> I thought that it may be useful to include an "error" class on the input
> widget when the form is submitted and has invalid data.
>
> ie.
>
> from
>
> 
>  assword">
> too short
> 
>
> to
>
> 
>  error"type="password"value=""name="password">
> too short
> 
>
> Notice the error is the class of the input.
>
> I think this would be very useful and don't think it would break any
> backwards compatibility.
>
> Thanks.


[web2py] Re: ValueError: invalid literal for int() with base 10

2012-01-16 Thread Massimo Di Pierro
I think your problem is that you somehow have corrupted data in
database, i.e. you stored a date in a field which you later changed to
int and web2py cannot take it out any more.

On Jan 15, 8:02 pm, Andrew Evans  wrote:
> Hello I just updated web2py and after restarting uwsgi I get an error on my
> site
>
> ValueError: invalid literal for int() with base 10: '05 04:36:30'
>
> 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 "/opt/web2py/gluon/restricted.py", line 204, in restricted
>     exec ccode in environment
>   File "/opt/web2py/applications/pstv/controllers/default.py"
> , line
> 105, in 
>   File "/opt/web2py/gluon/globals.py", line 172, in 
>     self._caller = lambda f: f()
>   File "/opt/web2py/applications/pstv/controllers/default.py"
> , line
> 23, in index
>     trailers = db(db.trailer.id>0).select(orderby=~db.trailer.air_date)
>   File "/opt/web2py/gluon/dal.py", line 6333, in select
>     return self.db._adapter.select(self.query,fields,attributes)
>   File "/opt/web2py/gluon/dal.py", line 1282, in select
>     rows = response(sql)
>   File "/opt/web2py/gluon/dal.py", line 1272, in response
>     self.execute(sql)
>   File "/opt/web2py/gluon/dal.py", line 1359, in execute
>     return self.log_execute(*a, **b)
>   File "/opt/web2py/gluon/dal.py", line 1353, in log_execute
>     ret = self.cursor.execute(*a, **b)
>   File "/usr/lib/python2.6/sqlite3/dbapi2.py", line 63, in convert_date
>     return datetime.date(*map(int, val.split("-")))
> ValueError: invalid literal for int() with base 10: '05 04:36:30'
>
> Any ideas?


[web2py] Re: Output from some controller

2012-01-16 Thread Massimo Di Pierro


On Jan 15, 11:43 pm, blackshirt  wrote:
> Thanks Massimo, you were great's people..
>
> 1. if we read from file resulted from redirected stdout, i think that
> we get complete output finally, not ongoing process output ??
> that was right, Massimo ?? correct me if i'm wrong ..

you read what has been flushed. If the process has completed you read
everything.

>
> 2. if we are using popen (popen2 or whatever), first arguments was
> cmd.. i think that cmd was external program or script, not function
> inside controller.. is true like that ?
> i don't want use external script/helper.. is it possible ?

you can probably do with the multiprocessing module. I am not sure how
it handles stdout.


> On Jan 15, 12:15 am, Massimo Di Pierro 
> wrote:
>
>
>
>
>
>
>
> > I think apt sends the output to stdout. There are two ways to capture
> > that:
>
> > 1) redirect stdout to a file, then read and display the file. This is
> > not thread safe which requires you lock when you do it
>
> > 2) use multiprocessing or popen and run the function in a separate
> > process which then captures the output.
>
> > I this case I would go with 1.
>
> > On Jan 12, 8:24 pm, blackshirt  wrote:
>
> > > i have some a littel coding with web2py framework..
> > > here is my controller and file :
>
> > > def update():
> > >    cache = apt.Cache()
> > >    progress = apt.progress.TextFetchProgress()
> > >    res = cache.update(progress)
> > >    return dict(res = res)
>
> > > in this related view..
>
> > > {{extend 'layout.html'}}
> > > {{=res}}
> > > {{pass}}
>
> > > the controller works normally, ie. update the APT database.. i see it
> > > progress on console output.
> > > but on view just return value
>
> > > True
>
> > > after process update finish...
>
> > > i hope, the output progress, like this normally :
>
> > > Hithttp://ftp.hk.debian.orgstableRelease.gpg
> > > Hithttp://security.debian.orgstable/updatesRelease.gpg
> > > Ignoredhttp://security.debian.org/stable/updates/contribTranslation-
> > > en
> > > Failedhttp://security.debian.org/stable/updates/contribTranslation-
> > > en
> > > Ignoredhttp://security.debian.org/stable/updates/mainTranslation-en
> > > Failedhttp://security.debian.org/stable/updates/mainTranslation-en
> > > Ignoredhttp://security.debian.org/stable/updates/non-free
> > > Translation-en
> > > Failedhttp://security.debian.org/stable/updates/non-freeTranslation-
> > > en
> > > Hithttp://security.debian.orgstable/updatesRelease
> > > Donehttp://security.debian.orgstable/updatesRelease
> > > Ignoredhttp://ftp.hk.debian.org/debian/stable/contribTranslation-en
> > > Failedhttp://ftp.hk.debian.org/debian/stable/contribTranslation-en
> > > Hithttp://security.debian.orgstable/updates/mainamd64Packages
> > > Ignoredhttp://ftp.hk.debian.org/debian/stable/mainTranslation-en
> > > Failedhttp://ftp.hk.debian.org/debian/stable/mainTranslation-en
> > > Hithttp://security.debian.orgstable/updates/contribamd64Packages
> > > Hithttp://security.debian.orgstable/updates/non-freeamd64Packages
> > > Ignoredhttp://ftp.hk.debian.org/debian/stable/non-freeTranslation-
> > > en
> > > Failedhttp://ftp.hk.debian.org/debian/stable/non-freeTranslation-en
> > > Hithttp://ftp.hk.debian.orgstableRelease
> > > Donehttp://ftp.hk.debian.orgstableRelease
> > > Hithttp://ftp.hk.debian.orgstable/mainSources
> > > Hithttp://ftp.hk.debian.orgstable/contribSources
> > > Hithttp://ftp.hk.debian.orgstable/non-freeSources
> > > Hithttp://ftp.hk.debian.orgstable/mainamd64Packages
> > > Hithttp://ftp.hk.debian.orgstable/contribamd64Packages
> > > Hithttp://ftp.hk.debian.orgstable/non-freeamd64Packages
> > > Done downloading
>
> > > showing on the view output..
> > > How we can do this on web2py ?
> > > i'm still pretty newbie on python and web2py
>
> > > thanks


Re: [web2py] Re: Set table name

2012-01-16 Thread Marcello Parra
I pass db to module...
Works fine...

But I was setting (in the model):

dog = 'dog12345'

So.. in the module I see db and not dog...
To make it work, I should pass dog also

As I have many associations in this project, this wold make it almost
impossible to implement



On Mon, Jan 16, 2012 at 5:15 PM, Marin Pranjić wrote:

>
> On Mon, Jan 16, 2012 at 5:56 PM, Marcello  wrote:
>
>> Would be great
>>
>> This solution works great... but it's not accessible in the modules
>> files, because dog is not visible there...
>>
>> You can pass everything into modules using current object.
> In controller:
>
> current.db = db
>
> in module
>
> from gluon import current
> def module_function():
> db = current.db
>
>
> don't do it as global, it should be inside some "module_function" bacause
> it has to be executed for every request.
>
>
>
> Marin
>


[web2py] Re: SOLVED Re: Inline image generation with matplotlib

2012-01-16 Thread Massimo Di Pierro
def image():
    return myimage()

myimage returns the binary data of the image. so calling image would
be the same as calling myimage. The former never calls the view.

Massimo

On Jan 16, 5:44 am, andrej burja  wrote:
> this works
> controller:
> def image():
>     return dict(a=IMG(_src=URL('myimage'+'.png')))
> view:
> {{extend 'layout.html'}}
> This is the graph/image.html template
> {{=a}}
>
> but this doesn't
> controller:
> def image():
>     return myimage()
> view:
> {{extend 'layout.html'}}
> This is the graph/slika1.html template
> {{=IMG(_src=URL('myimage'+'.png'))}}


Re: [web2py] Re: Inherit type from parent

2012-01-16 Thread Tsvi Mostovicz
Could be it works, but for populate it doesn't. I was hoping to generate a
rule that would force populate to behave correctly.
For the user I can obviously deal with it in AJAX. Is it possible that
populate disregards the compute field?

Tsvi Mostovicz
ttm...@gmail.com
www.linkedin.com/in/tsvim



On Mon, Jan 16, 2012 at 08:35, Anthony  wrote:

> db.define_table('accounts',
>> Field('name','string'),
>> Field('parent_account','**reference accounts'),
>> Field('account_type','string')**)
>>
>> What I'm trying to achieve is to create a tree-like structure. So we have
>> 5 "root" accounts, which can each hold some sub-accounts etc.
>> Now the account_type must be the same for all the children of a certain
>> account. So the root accounts pre-determine all of the children's account
>> type, rendering it unwritable for a child account.
>> For some reason the following didn't work for me:
>>
>> account_types = ['a','b','c']
>> db.accounts.account_type.**requires  = IS_IN_SET(account_types)
>> db.accounts.account_type.**required  = True
>> db.accounts.account_type.**compute = lambda x:
>> x['parent_account'].account_**type
>> db.accounts.account_type.**writeable = lambda x: (x['parent_account'] ==
>> 0)
>>
>
> For the "compute" attribute, maybe:
>
> db.accounts.account_type.compute = lambda r:
> db.accounts[r.parent_account].account_type if r.parent_account else None
>
> However, I don't think you can set the "writeable" attribute this way
> because you won't know if a parent account is going to be specified until
> after the new record is submitted, which happens after you have to decide
> whether to make the account_type field writeable. Instead you might need
> some client side JS and Ajax to dynamically set the account_type if the
> user selects a parent_account in the form.
>
> Anthony
>
>


Re: [web2py] Re: error class proposal

2012-01-16 Thread David

Sorry for not being clear;

I meant if the field has an error obviously.

After form validation, the ie. input would have an error class

This would be useful for styling the fields with say "red borders"

Alternatively if there is generic way to handle this I would appreciate it.

Thanks.



On 1/16/12 2:26 PM, Massimo Di Pierro wrote:

Why do you want to add an "error" class to the input? The error class
is normally used for inputs. Perhaps I do not understand.

On Jan 15, 7:40 pm, David  wrote:

I was thinking about the form validation.

I thought that it may be useful to include an "error" class on the input
widget when the form is submitted and has invalid data.

ie.

from



too short


to



too short


Notice the error is the class of the input.

I think this would be very useful and don't think it would break any
backwards compatibility.

Thanks.




Re: [web2py] Re: error class proposal

2012-01-16 Thread Bruno Rocha
*include this in the page where you have the form*


jQuery(function(){
jQuery(".error").prev().css({"border":"1px solid red"});
});


*There is a css way for doing this (but not all browsers support css
siblings ~*


.error~input, .error~select, .error~textarea {
border: 1px solid red;
}



On Mon, Jan 16, 2012 at 6:25 PM, David  wrote:

> Sorry for not being clear;
>
> I meant if the field has an error obviously.
>
> After form validation, the ie. input would have an error class
>
> This would be useful for styling the fields with say "red borders"
>
> Alternatively if there is generic way to handle this I would appreciate it.
>
> Thanks.
>
>
>
>
> On 1/16/12 2:26 PM, Massimo Di Pierro wrote:
>
>> Why do you want to add an "error" class to the input? The error class
>> is normally used for inputs. Perhaps I do not understand.
>>
>> On Jan 15, 7:40 pm, David  wrote:
>>
>>> I was thinking about the form validation.
>>>
>>> I thought that it may be useful to include an "error" class on the input
>>> widget when the form is submitted and has invalid data.
>>>
>>> ie.
>>>
>>> from
>>>
>>> 
>>> >> assword">
>>> too
>>> short
>>> 
>>>
>>> to
>>>
>>> 
>>> >> error"type="password"value=""**name="password">
>>> too
>>> short
>>> 
>>>
>>> Notice the error is the class of the input.
>>>
>>> I think this would be very useful and don't think it would break any
>>> backwards compatibility.
>>>
>>> Thanks.
>>>
>>
>


-- 

Bruno Rocha
[http://rochacbruno.com.br]


[web2py] Re: priority of web2py CMS

2012-01-16 Thread Gour
On Mon, 16 Jan 2012 10:49:41 -0800 (PST)
Ross Peoples 
wrote:

> The goal with my CMS is that I could stick an executive in front of
> it (someone who barely knows how to check their email), and allow
> them to theme their site, lay it out they way they want, and add
> content with a simple drag & drop interface.

Hmm, inline-editing...that sounds good and it reminds me to C5.


Sincerely,
Gour

> That's goal. We will see if I can actually make it happen :)

Nothing is public yet?


Sincerely,
Gour

-- 
As a strong wind sweeps away a boat on the water, 
even one of the roaming senses on which the mind 
focuses can carry away a man's intelligence.

http://atmarama.net | Hlapicina (Croatia) | GPG: 52B5C810


signature.asc
Description: PGP signature


Re: [web2py] Re: error class proposal

2012-01-16 Thread Anthony
But still, would be easier if the input itself had an error class.

On Monday, January 16, 2012 3:33:30 PM UTC-5, rochacbruno wrote:
>
> *include this in the page where you have the form*
>
> 
> jQuery(function(){
> jQuery(".error").prev().css({"border":"1px solid red"});
> });
> 
>
> *There is a css way for doing this (but not all browsers support css 
> siblings ~*
>
> 
> .error~input, .error~select, .error~textarea {
> border: 1px solid red;
> }
>
> 
>
> On Mon, Jan 16, 2012 at 6:25 PM, David  wrote:
>
>> Sorry for not being clear;
>>
>> I meant if the field has an error obviously.
>>
>> After form validation, the ie. input would have an error class
>>
>> This would be useful for styling the fields with say "red borders"
>>
>> Alternatively if there is generic way to handle this I would appreciate 
>> it.
>>
>> Thanks.
>>
>>
>>
>>
>> On 1/16/12 2:26 PM, Massimo Di Pierro wrote:
>>
>>> Why do you want to add an "error" class to the input? The error class
>>> is normally used for inputs. Perhaps I do not understand.
>>>
>>> On Jan 15, 7:40 pm, David  wrote:
>>>
 I was thinking about the form validation.

 I thought that it may be useful to include an "error" class on the input
 widget when the form is submitted and has invalid data.

 ie.

 from

 
 >>>  
 assword">
 too 
 short
 

 to

 
 >>> error"type="password"value=""**name="password">
 too 
 short
 

 Notice the error is the class of the input.

 I think this would be very useful and don't think it would break any
 backwards compatibility.

 Thanks.

>>>
>>
>
>
> -- 
>
> Bruno Rocha
> [http://rochacbruno.com.br]
>
>

[web2py] Re: priority of web2py CMS

2012-01-16 Thread Ross Peoples
Not yet. Just a bunch of proof of concept ideas. I have to combine them 
into a workable solution, which will take some time. The good news is I've 
already figured out how to do it, I just have to put the work in.

Re: [web2py] Re: Inherit type from parent

2012-01-16 Thread Anthony
No, I don't think populate looks at the compute attribute -- it just looks 
at the field type and generates an appropriate value.

On Monday, January 16, 2012 3:21:16 PM UTC-5, tsvim wrote:
>
> Could be it works, but for populate it doesn't. I was hoping to generate a 
> rule that would force populate to behave correctly.
> For the user I can obviously deal with it in AJAX. Is it possible that 
> populate disregards the compute field?
>
> Tsvi Mostovicz
> ttm...@gmail.com
> www.linkedin.com/in/tsvim
>
>
>
> On Mon, Jan 16, 2012 at 08:35, Anthony  wrote:
>
>> db.define_table('accounts',
>>> Field('name','string'),
>>> Field('parent_account','**reference accounts'),
>>> Field('account_type','string')**)
>>>
>>> What I'm trying to achieve is to create a tree-like structure. So we 
>>> have 5 "root" accounts, which can each hold some sub-accounts etc.
>>> Now the account_type must be the same for all the children of a certain 
>>> account. So the root accounts pre-determine all of the children's account 
>>> type, rendering it unwritable for a child account.
>>> For some reason the following didn't work for me:
>>>
>>> account_types = ['a','b','c']
>>> db.accounts.account_type.**requires  = IS_IN_SET(account_types)
>>> db.accounts.account_type.**required  = True
>>> db.accounts.account_type.**compute = lambda x: 
>>> x['parent_account'].account_**type
>>> db.accounts.account_type.**writeable = lambda x: (x['parent_account'] 
>>> == 0)
>>>
>>
>> For the "compute" attribute, maybe:
>>
>> db.accounts.account_type.compute = lambda r: 
>> db.accounts[r.parent_account].account_type if r.parent_account else None
>>
>> However, I don't think you can set the "writeable" attribute this way 
>> because you won't know if a parent account is going to be specified until 
>> after the new record is submitted, which happens after you have to decide 
>> whether to make the account_type field writeable. Instead you might need 
>> some client side JS and Ajax to dynamically set the account_type if the 
>> user selects a parent_account in the form.
>>
>> Anthony
>>
>>
>

[web2py] Re: priority of web2py CMS

2012-01-16 Thread Gour
On Mon, 16 Jan 2012 12:41:32 -0800 (PST)
Ross Peoples 
wrote:

> Not yet. Just a bunch of proof of concept ideas. I have to combine
> them into a workable solution, which will take some time. The good
> news is I've already figured out how to do it, I just have to put the
> work in.

Good luck. ;)


Sincerely,
Gour

-- 
But those who, out of envy, disregard these teachings and do not 
follow them are to be considered bereft of all knowledge, befooled, 
and ruined in their endeavors for perfection.

http://atmarama.net | Hlapicina (Croatia) | GPG: 52B5C810


signature.asc
Description: PGP signature


Re: [web2py] Represent - redirect

2012-01-16 Thread Mathias Van Daele
Thanks for answer Johann.

But how can I catch the value of args in the concerned function ?

Thanks


Op 16 januari 2012 13:15 schreef Johann Spies  het
volgende:

> On 15 January 2012 22:49, Mathias Van Daele wrote:
>
>> Hello,
>>
>> I have a select crud, with a URL in the column id.
>>
>> If I click 'edit', I should be redirected to a page, where I can
>> update the concerned contact_part record.
>> (as in a grid)
>>
>> What should I put between the URL brackets ?  _href=URL()
>>
>> How do I pass the selected record ?
>>
>>
> I use something like this in the model:
>
> db.akb_country.id.represent = \
> lambda id, record: A('edit',
>  _href = URL(r = request, c = 'default', # c
> refers to controller
>f = 'edit_akb_country', # f : the
> function in the controller
>args = str(id)))
>
> Regards
> Johann
>
> --
> Because experiencing your loyal love is better than life itself,
> my lips will praise you.  (Psalm 63:3)
>
>


[web2py] Re: error class proposal

2012-01-16 Thread Massimo Di Pierro
I understand. Let me think about this the problem is some some
widgets do not have a single input fiels (think if lists and
checkboxes). Please open a ticket in google code so we do not forget.

On Jan 16, 2:25 pm, David  wrote:
> Sorry for not being clear;
>
> I meant if the field has an error obviously.
>
> After form validation, the ie. input would have an error class
>
> This would be useful for styling the fields with say "red borders"
>
> Alternatively if there is generic way to handle this I would appreciate it.
>
> Thanks.
>
> On 1/16/12 2:26 PM, Massimo Di Pierro wrote:
>
>
>
>
>
>
>
> > Why do you want to add an "error" class to the input? The error class
> > is normally used for inputs. Perhaps I do not understand.
>
> > On Jan 15, 7:40 pm, David  wrote:
> >> I was thinking about the form validation.
>
> >> I thought that it may be useful to include an "error" class on the input
> >> widget when the form is submitted and has invalid data.
>
> >> ie.
>
> >> from
>
> >> 
> >>  >>  assword">
> >> too 
> >> short
> >> 
>
> >> to
>
> >> 
> >>  >> error"type="password"value=""name="password">
> >> too 
> >> short
> >> 
>
> >> Notice the error is the class of the input.
>
> >> I think this would be very useful and don't think it would break any
> >> backwards compatibility.
>
> >> Thanks.


[web2py] Re: priority of web2py CMS

2012-01-16 Thread Massimo Di Pierro
One piece that every CMS needs and we could all benefit from is the
following:

a plugin to manage groups:
- create groups
- apply for membership
- add memberships to owned(created) groups
- approve members of owned(created) groups
- revoke membership
etc.

I could use it right away.

On Jan 16, 3:24 pm, Gour  wrote:
> On Mon, 16 Jan 2012 12:41:32 -0800 (PST)
> Ross Peoples 
> wrote:
>
> > Not yet. Just a bunch of proof of concept ideas. I have to combine
> > them into a workable solution, which will take some time. The good
> > news is I've already figured out how to do it, I just have to put the
> > work in.
>
> Good luck. ;)
>
> Sincerely,
> Gour
>
> --
> But those who, out of envy, disregard these teachings and do not
> follow them are to be considered bereft of all knowledge, befooled,
> and ruined in their endeavors for perfection.
>
> http://atmarama.net| Hlapicina (Croatia) | GPG: 52B5C810
>
>  signature.asc
> < 1KViewDownload


[web2py] Many-to-many relations with CRUD Insert

2012-01-16 Thread Christian Winterhager
One of the standard examples  of many-to-many Relations is a library. For 
simplicity i choose only 3 Tables:

db.define_table ('author',
Field ('name', 'string', length=100))

db.define_table ('verb',
   Field ('bnr', db.book ),  
   Field ('anr', db.author ), 
)

db.define_table ('book',
Field('title', 'string', length=250))

It is very easy to insert a new book, one or more author and the 
corresponding record
in the table "verb". But i found no way to insert a book with the 
CRUD-Method. The 
complexity
is that i first must insert a row into  table "book", then one into table 
"author" and last i have to connect
the inserted rows with the corresponding numbers 'bnr' and 'anr' in table 
"verb". Does anyone know if there
is a way to do that with CRUD?


 



[web2py] how to implement a custom checkboxes widget?

2012-01-16 Thread ofr
Hi there,

I would like to implement a custom checkboxes widget where I can control 
the rendering in the template similar to the other custom form widgets. In 
the controller I would like to define the checkboxes widget as usual with 
an array of choices like:

choices = [(1, 'first'), (2, 'second'), (3, 'third')]
form = SQLFORM.factory(
Field('selection',requires=IS_IN_SET(choices), 
widget=SQLFORM.widgets.checkboxes.widget)

so I can use the built-in validations. However in the view I would like to 
have fine-grained control over the placement of the individual items like:

please choose:
{{=form.custom.widget.selection.1}}
someotherhtmlhere
{{=form.custom.widget.selection.2}}
morehtmlgoeshere
{{=form.custom.widget.selection.3}}

or some other syntax for achieving the same goal. How can I implement this 
and where do I start?

Thanks for your help
ofr








[web2py] SQLFORM.grid links

2012-01-16 Thread Miguel
Hello,

I have defined two tables related between each other, I have defined
a  SQLFORM.grid with this two tables and works ok, but when I try to
add a new button with the id parameter it fails, but when I use other
field like name works correctly.

db.define_table('course',
Field('name','string',label=T('Course'), requires=IS_NOT_EMPTY(),
required=True, unique=True),
Field('comments','text',label=T('Comments')))

db.define_table('subject',
Field('course',db.course,label=T('Course')),
Field('name','string', label=T('Subject'),
requires=IS_NOT_EMPTY(), required=True, unique=True),
Field('groupsubject','string', label=T('Group')),
Field('comments','text', label=T('Comments')))
db.subject.course.requires = IS_IN_DB(db,db.course.id,'%(name)s')


It is possible to use the id of one of these tables?

ok: links = [lambda row:
A(T('Details'),_href=URL("default","detailsubject",args=[row.subject.name]))]
not ok: links = [lambda row:
A(T('Details'),_href=URL("default","detailsubject",args=[row.subject.id]))]

-
query = db.subject.course == db.course.id
fields =[db.course.name,
db.subject.name,db.subject.groupsubject,db.subject.comments]
links = [lambda row:
A(T('Details'),_href=URL("default","detailsubject",args=[row.subject.name]))]

form = SQLFORM.grid( query=query,  create=False, links = links,
searchable=True, user_signature=False, fields=fields,
deletable=False, editable=False, csv=True, maxtextlength=64,
paginate=20, details=False )

Thanks
Miguel


[web2py] Welcome app and i18n

2012-01-16 Thread Otto Domínguez
I have understood that the Welcome app is a template for new apps. I 
changed the About of the Welcome app and when making a new app I get this 
modified About page. But not so with language files. On the Welcome app I 
created a new spanish file for my country (Guatemala) named es-gt.py. It 
does work in that app, but when making a new Simple Application (based on 
Welcome) this file does not get copied to the new app. Am I missing 
something?


[web2py] SQLFORM.grid order

2012-01-16 Thread Miguel
Hello,

I have a question about SQLFORM.grid order of the fields in the table
represented?

Is there any way to modify the order of these fields in a
SQLFORM.grid?

Thanks
Miguel


[web2py] I am looking for an html widget for lists

2012-01-16 Thread Bruno Rocha
Hi,

Some people are little confused with the list widget that we have in
web2py, some enters values separated by comma when it needs to press 

I would like to have an html widget which shows + and - buttons next to
each item, and can watch for ',' so when user press ',' it wraps and
automatically creates a new text box.

Take a look in to this image http://www.diigo.com/item/image/121xl/8cvh

That's the idea, may be somebody already developed something like that?

-- 

Bruno Rocha
[http://rochacbruno.com.br]


Re: [web2py] Welcome app and i18n

2012-01-16 Thread Bruno Rocha
You have to pack your customized welcome and place the welcome.w2p in
web2py/welcome.w2p

On Mon, Jan 16, 2012 at 7:03 PM, Otto Domínguez wrote:

> I have understood that the Welcome app is a template for new apps. I
> changed the About of the Welcome app and when making a new app I get this
> modified About page. But not so with language files. On the Welcome app I
> created a new spanish file for my country (Guatemala) named es-gt.py. It
> does work in that app, but when making a new Simple Application (based on
> Welcome) this file does not get copied to the new app. Am I missing
> something?
>



-- 

Bruno Rocha
[http://rochacbruno.com.br]


Re: [web2py] Represent - redirect

2012-01-16 Thread Anthony
On Monday, January 16, 2012 4:47:01 PM UTC-5, Mathias Van Daele wrote:
>
> Thanks for answer Johann.
>
> But how can I catch the value of args in the concerned function ?
>

args from the URL are always in request.args, so in the edit_akb_country() 
function, the id would be in request.args(0).

See http://web2py.com/books/default/chapter/29/4#Dispatching.

Anthony 


[web2py] Re: I am looking for an html widget for lists

2012-01-16 Thread Bruno Rocha
Something like that http://www.diigo.com/item/image/121xl/oahk would be
great for list widget


-- 

Bruno Rocha
[http://rochacbruno.com.br]


[web2py] Re: I am looking for an html widget for lists

2012-01-16 Thread Bruno Rocha
I found the resource http://webspirited.com/tagit/?page=tagit just need to
know if it already exists for web2py, so I will not start to develop, else
I will start tomorrow.
-- 

Bruno Rocha
[http://rochacbruno.com.br]


[web2py] Re: Welcome app and i18n

2012-01-16 Thread Anthony
New apps are created from the welcome.w2p file in the /web2py folder, not 
by directly copying the /web2py/applications/welcome folder. If you want 
new apps to be based on your modified welcome app, pack the modified app 
and replace the existing /web2py/welcome.w2p file with it.

Anthony

On Monday, January 16, 2012 4:03:59 PM UTC-5, Otto Domínguez wrote:
>
> I have understood that the Welcome app is a template for new apps. I 
> changed the About of the Welcome app and when making a new app I get this 
> modified About page. But not so with language files. On the Welcome app I 
> created a new spanish file for my country (Guatemala) named es-gt.py. It 
> does work in that app, but when making a new Simple Application (based on 
> Welcome) this file does not get copied to the new app. Am I missing 
> something?
>


[web2py] Re: Welcome app and i18n

2012-01-16 Thread Otto Domínguez
Thank you Bruno and Anthony. It does work and you have made the world
a happier place (at least for me).

On Jan 16, 5:55 pm, Anthony  wrote:
> New apps are created from the welcome.w2p file in the /web2py folder, not
> by directly copying the /web2py/applications/welcome folder. If you want
> new apps to be based on your modified welcome app, pack the modified app
> and replace the existing /web2py/welcome.w2p file with it.
>
> Anthony
>
>
>
>
>
>
>
> On Monday, January 16, 2012 4:03:59 PM UTC-5, Otto Domínguez wrote:
>
> > I have understood that the Welcome app is a template for new apps. I
> > changed the About of the Welcome app and when making a new app I get this
> > modified About page. But not so with language files. On the Welcome app I
> > created a new spanish file for my country (Guatemala) named es-gt.py. It
> > does work in that app, but when making a new Simple Application (based on
> > Welcome) this file does not get copied to the new app. Am I missing
> > something?


Re: [web2py] Re: I am looking for an html widget for lists

2012-01-16 Thread Javier Quarite
On Mon, Jan 16, 2012 at 6:51 PM, Bruno Rocha  wrote:

> I found the resource http://webspirited.com/tagit/?page=tagit just need
> to know if it already exists for web2py, so I will not start to develop,
> else I will start tomorrow.
>
> --
>
> Bruno Rocha
> [http://rochacbruno.com.br]
>
>
Thanks for sharing, it looks like the tagging system of stackoverflow

Thanks again :)

Javier


[web2py] Re: Output from some controller

2012-01-16 Thread blackshirt
Yes, like you say... i have modified the controller code become like
this :

def run_command(self, *args):
p = subprocess.Popen(args, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
return p.communicate()

def update():
output, error = run_command('/bin/sh','apt-get','update', '-V')
return dict(output=output, error=error)

and for notes, update controller use external executable from sistem.
i mean external, not come from web2py, own defined class, or some
function. apt-get was debian-based application.

and related view :
{{extend 'layout.html'}}
{{=output}}
{{=error}}
{{pass}}

and you can look output here 
http://imageshare.web.id/images/48jjun7nv5kbdk95aw71.png
like scrambled... how to parse output line by line ??

Thanks again

On Jan 17, 2:29 am, Massimo Di Pierro 
wrote:
> On Jan 15, 11:43 pm, blackshirt  wrote:
>
> > Thanks Massimo, you were great's people..
>
> > 1. if we read from file resulted from redirected stdout, i think that
> > we get complete output finally, not ongoing process output ??
> > that was right, Massimo ?? correct me if i'm wrong ..
>
> you read what has been flushed. If the process has completed you read
> everything.
>
>
>
> > 2. if we are using popen (popen2 or whatever), first arguments was
> > cmd.. i think that cmd was external program or script, not function
> > inside controller.. is true like that ?
> > i don't want use external script/helper.. is it possible ?
>
> you can probably do with the multiprocessing module. I am not sure how
> it handles stdout.
>
>
>
> > On Jan 15, 12:15 am, Massimo Di Pierro 
> > wrote:
>
> > > I think apt sends the output to stdout. There are two ways to capture
> > > that:
>
> > > 1) redirect stdout to a file, then read and display the file. This is
> > > not thread safe which requires you lock when you do it
>
> > > 2) use multiprocessing or popen and run the function in a separate
> > > process which then captures the output.
>
> > > I this case I would go with 1.
>
> > > On Jan 12, 8:24 pm, blackshirt  wrote:
>
> > > > i have some a littel coding with web2py framework..
> > > > here is my controller and file :
>
> > > > def update():
> > > >    cache = apt.Cache()
> > > >    progress = apt.progress.TextFetchProgress()
> > > >    res = cache.update(progress)
> > > >    return dict(res = res)
>
> > > > in this related view..
>
> > > > {{extend 'layout.html'}}
> > > > {{=res}}
> > > > {{pass}}
>
> > > > the controller works normally, ie. update the APT database.. i see it
> > > > progress on console output.
> > > > but on view just return value
>
> > > > True
>
> > > > after process update finish...
>
> > > > i hope, the output progress, like this normally :
>
> > > > Hithttp://ftp.hk.debian.orgstableRelease.gpg
> > > > Hithttp://security.debian.orgstable/updatesRelease.gpg
> > > > Ignoredhttp://security.debian.org/stable/updates/contribTranslation-
> > > > en
> > > > Failedhttp://security.debian.org/stable/updates/contribTranslation-
> > > > en
> > > > Ignoredhttp://security.debian.org/stable/updates/mainTranslation-en
> > > > Failedhttp://security.debian.org/stable/updates/mainTranslation-en
> > > > Ignoredhttp://security.debian.org/stable/updates/non-free
> > > > Translation-en
> > > > Failedhttp://security.debian.org/stable/updates/non-freeTranslation-
> > > > en
> > > > Hithttp://security.debian.orgstable/updatesRelease
> > > > Donehttp://security.debian.orgstable/updatesRelease
> > > > Ignoredhttp://ftp.hk.debian.org/debian/stable/contribTranslation-en
> > > > Failedhttp://ftp.hk.debian.org/debian/stable/contribTranslation-en
> > > > Hithttp://security.debian.orgstable/updates/mainamd64Packages
> > > > Ignoredhttp://ftp.hk.debian.org/debian/stable/mainTranslation-en
> > > > Failedhttp://ftp.hk.debian.org/debian/stable/mainTranslation-en
> > > > Hithttp://security.debian.orgstable/updates/contribamd64Packages
> > > > Hithttp://security.debian.orgstable/updates/non-freeamd64Packages
> > > > Ignoredhttp://ftp.hk.debian.org/debian/stable/non-freeTranslation-
> > > > en
> > > > Failedhttp://ftp.hk.debian.org/debian/stable/non-freeTranslation-en
> > > > Hithttp://ftp.hk.debian.orgstableRelease
> > > > Donehttp://ftp.hk.debian.orgstableRelease
> > > > Hithttp://ftp.hk.debian.orgstable/mainSources
> > > > Hithttp://ftp.hk.debian.orgstable/contribSources
> > > > Hithttp://ftp.hk.debian.orgstable/non-freeSources
> > > > Hithttp://ftp.hk.debian.orgstable/mainamd64Packages
> > > > Hithttp://ftp.hk.debian.orgstable/contribamd64Packages
> > > > Hithttp://ftp.hk.debian.orgstable/non-freeamd64Packages
> > > > Done downloading
>
> > > > showing on the view output..
> > > > How we can do this on web2py ?
> > > > i'm still pretty newbie on python and web2py
>
> > > > thanks


[web2py] Re: ValueError: invalid literal for int() with base 10

2012-01-16 Thread howesc
or perhaps changed a datetime to a date?


[web2py] Re: How is the best way to export/import auth_user database?

2012-01-16 Thread howesc
there are 2 options:
 - use GAE datastore admin to copy data from application A to application 
B.  select only the auth tables, press a button, take a nap, and when you 
awaken it will be done.
 - use the GAE bulkloader to do the work.  you then have to write the 
transforms and preserving IDs is a PITA.  if you choose to torture yourself 
with this route let me know and i'll share some tricks with you.

cfh


[web2py] Re: 3-table many-to-many with IS_IN_DB

2012-01-16 Thread howesc
i do this for admins of one of my sites:  (note that i have customizations 
to my auth_user table so this is not a drop-in method for your site).

@auth.requires_membership('admin')
def auth_user():
users_form=None
retval = dict(aahome=A("Forms Home", _href=URL(r=request, f='index')))
role_values = []
#remove bio requirements from auth pane
db.auth_user.bio.requires=None

table = db.auth_user

if request.args and request.args[0]:
selected_membership = db(db.auth_membership.user_id == 
request.args[0]).select(db.auth_membership.group_id)
#build the current roles list, before the update
query = None
for r in selected_membership:
if query == None:
query = db(db.auth_group.id == 
r.group_id).select(orderby=db.auth_group.role)
else:
query = query | db(db.auth_group.id == 
r.group_id).select(orderby=db.auth_group.role)

#@TODO: remove user specific roles from query
roles = query

retval['all roles for %s' % request.args[0]] = 
SQLTABLE(roles,linkto,orderby=True,_class='sortable')
for role in roles:
role_values.append(role.id)

#check the form submit
users_form = SQLFORM(table, request.args[0])
if users_form.accepts(request.vars, session, formname='userupdate'):
for role in request.vars.roles:
# currently trusts that only valid role id's will be 
submitted
if not auth.has_membership(role, users_form.vars.id):
auth.add_membership(role, users_form.vars.id)
for role in roles:
#delete roles that have been removed
if str(role.id) not in request.vars.roles:
auth.del_membership(role.id,
users_form.vars.id)

redirect(URL(r=request,f='auth_user', args=request.args))


#add roles multi-select to the form
rows = db(db.auth_group.id > 0).select(db.auth_group.id, 
db.auth_group.role, orderby=db.auth_group.role)

import logging
logging.info(rows)
logging.info(role_values)
opts = [OPTION(r['role'], _value=r['id']) for r in rows]

users_form.components[0].insert(-1,
  TR(TD('Roles:'),
 TD(SELECT(opts, _name="roles",
   #@TODO: add better requires if 
we can
   # make it work with lists
   requires=IS_NOT_EMPTY(),
   _multiple=True,
   value=role_values

else:
users_form = SQLFORM(table)
if users_form.accepts(request.vars, session, formname='userupdate'):
#create role
auth.add_membership(auth.add_group('user_%d' % 
users_form.vars.id,'user_%d' % users_form.vars.id), users_form.vars.id) ## 
a group for this user


#get list of users to display
orderby=request.vars.orderby
if orderby == None:
orderby=db.auth_user.id
rows = db( db.auth_user.id > 0
  ).select(db.auth_user.id,
   db.auth_user.first_name,
   db.auth_user.last_name,
   db.auth_user.email,
   db.auth_user.registration_key)

headers = {'auth_user.id':T("ID"),
   'auth_user.first_name':T("First Name"),
   'auth_user.last_name':T("Last Name"),
   'auth_user.email':T("Email"),
   'auth_user.registration_key':T("Registration Key")}
tbl = SQLTABLE(rows,linkto,orderby=True,_class='sortable', truncate=128,
   headers=headers)

retval['aform'] = users_form
retval['users'] = tbl

return retval



[web2py] Re: Question about many to many forms

2012-01-16 Thread howesc
it's code therefore it is possible.

i think you'll have to create a set of custom forms and custom form 
handlers to deal with all the interdependency, but given enough time to 
work on it you can make it work.  my first question though is: what will 
the user interface be such that it is intuitive and understandable?  i 
often find when putting lots of forms into 1 page that i confuse my user 
quite quickly!

cfh


[web2py] using PAM to authenticate and verify user

2012-01-16 Thread blackshirt
i have a simply question about using PAM on linux to authenticate
user.

let's me explain my code.
we have a simple controller like this

def update():
   cache = apt.Cache()
   progress = apt.progress.TextFetchProgress()
   res = cache.update(progress)
   redirect(URL(r=request, c='statistic', f='index'))
   return dict(res = res)

cache.update(progress) was python-apt based function, that need "root"
or  sudoer" user to perform operation, likes apt-get update on debian-
based linux.
I have succesfully run this if i using su/sudo to start web2py, aka
like this $sudo python web2py.py
cache.update() can update apt database with this technique.
but if web2py run as a normal user with $python web2py, we know that
was run with specified password on prompt, but still can't run
cache.update because need of root privileges to access and lock apt
lock's file.

i think it is possible to use PAM method to accomply this.. like we
read on gluon/contrib/login_methods/pam_auth.py  said :
"""
to use pam_login:
from gluon.contrib.login_methods.pam_auth import pam_auth
auth.settings.login_methods.append(pam_auth())

or

auth.settings.actions_disabled=[
   'register','change_password','request_reset_password']
auth.settings.login_methods=[pam_auth()]

The latter method will not store the user password in auth_user.
"""

i have try this suggestion, but still no luck..

any clue or some enlightenment for me ? thanks before


[web2py] get user id on mobile app after login to web2py

2012-01-16 Thread Yuval
I need the web2py user id on an android mobile application.

The user will use a web page (WebView) to perform the login (or to
register).

Once logged in, what is the best suggested way to pass back the user
id to the container application (browser)?

Thanks,
Yuval



[web2py] There is no web2py homebrew for OS X

2012-01-16 Thread Jemes Hsu
Homebrew (Homebrew — MacPorts driving you to drink? Try 
Homebrew!)
 
is the most popular way to install third party apps on Mac OS X. It has 
"similar" aim as web2py, which is to make it easier. Since web2py is 
available in an OS X app binary, wondering if you could consider create a 
homebrew formula so that installing web2py on OS X is just "brew install 
web2py". Almost all popular open source software has brew formulae for 
example MacVim, postgresql, zeromq, node.js, python etc.

Re: [web2py] Re: I am looking for an html widget for lists

2012-01-16 Thread Bruno Rocha
The web2py widget for it is almost done! I just need to solve one issue:

form.errors:



request.vars:



I dont know why, but form is not receiving the same args as request, or
form is not validating its type for a list:string field.

-- 

Bruno Rocha
[http://rochacbruno.com.br]


Re: [web2py] get user id on mobile app after login to web2py

2012-01-16 Thread Bruno Rocha
the user id is in session.auth.user.id once usre logged in.

On Mon, Jan 16, 2012 at 10:50 PM, Yuval  wrote:

> I need the web2py user id on an android mobile application.
>
> The user will use a web page (WebView) to perform the login (or to
> register).
>
> Once logged in, what is the best suggested way to pass back the user
> id to the container application (browser)?
>
> Thanks,
> Yuval
>
>


-- 

Bruno Rocha
[http://rochacbruno.com.br]


[web2py] Re: get user id on mobile app after login to web2py

2012-01-16 Thread Yuval
This is on the server side, I looked for the better way to get it over
from the server to the mobile application/ client side.
I will just set the user id in a cookie and I will pick up from the
cookie on the mobile application side.

Thanks
Yuval

On Jan 16, 4:50 pm, Yuval  wrote:
> I need the web2py user id on an android mobile application.
>
> The user will use a web page (WebView) to perform the login (or to
> register).
>
> Once logged in, what is the best suggested way to pass back the user
> id to the container application (browser)?
>
> Thanks,
> Yuval


Re: [web2py] Re: get user id on mobile app after login to web2py

2012-01-16 Thread Bruno Rocha
You can redirect the user after login to a new url and post user ID as args
or vars, so in client side I think you can take it from location. Or you
can set a  with the value and read it with jquery, or the
cookie.

On Tue, Jan 17, 2012 at 2:07 AM, Yuval  wrote:

> This is on the server side, I looked for the better way to get it over
> from the server to the mobile application/ client side.
> I will just set the user id in a cookie and I will pick up from the
> cookie on the mobile application side.
>
> Thanks
> Yuval
>
> On Jan 16, 4:50 pm, Yuval  wrote:
> > I need the web2py user id on an android mobile application.
> >
> > The user will use a web page (WebView) to perform the login (or to
> > register).
> >
> > Once logged in, what is the best suggested way to pass back the user
> > id to the container application (browser)?
> >
> > Thanks,
> > Yuval
>



-- 

Bruno Rocha
[http://rochacbruno.com.br]


Re: [web2py] Re: I am looking for an html widget for lists

2012-01-16 Thread Bruno Rocha
Thats working!

http://www.diigo.com/item/image/121xl/vnwt

-- 

Bruno Rocha
[http://rochacbruno.com.br]


[web2py] read pdf file and display

2012-01-16 Thread kasun perera
 hi everyone, 

I want to read a uploaded pdf file and display its content in the webpage 
with the other fields that data need to be inserted. Can anyone point me 
how to do this.

db.define_table('Phrase',
   Field('DocumentId', db.Document,label=T("Document Id")),
   Field('PhraseContent', 'text',label=T("Phrase Content")),
   Field('DocumentContent', 'text',default=db.Document.File 
,label=T("Document Content")),  /// this is where I need to read the PDF 
file
   Field('UserId',db.auth_user, default=auth.user_id,label=T("User Id")),
   Field('Date','datetime', default=request.now, label=T("Date")),
   format = '%(PhraseContent)s')

I have pasted my files here.
models/db.py - http://paste.org/43879 controllers/default.py- 
http://paste.org/43880 

Thanks
Kasun


[web2py] Proposal for SQLFORM.grid

2012-01-16 Thread Martin Weissenboeck
Hi!

grid generats SQLFORMs for 'new', 'view' and 'edit'. But only the first
propagates the parameter formstyle from the constructor:
Line 1550 ('new'):

   create_form = SQLFORM(
table, ignore_rw = ignore_rw, formstyle = formstyle,


There is no formstile in line 1566 ('view')

   form = SQLFORM(table,record,upload=upload,ignore_rw=ignore_rw,
   readonly=True,_class='web2py_form')


and line 1578 ('edit')

   edit_form =
SQLFORM(table,record,upload=upload,ignore_rw=ignore_rw,
deletable=deletable,

Proposal: change to

   form =
SQLFORM(table,record,upload=upload,ignore_rw=ignore_rw, *formstyle
= formstyle, *
   readonly=True,_class='web2py_form')

and

   edit_form =
SQLFORM(table,record,upload=upload,ignore_rw=ignore_rw, *formstyle =
formstyle,*
deletable=deletable,

Regards, Martin


Re: [web2py] SQLFORM.grid order

2012-01-16 Thread Johann Spies
On 16 January 2012 23:03, Miguel  wrote:

> Hello,
>
> I have a question about SQLFORM.grid order of the fields in the table
> represented?
>
> Is there any way to modify the order of these fields in a
> SQLFORM.grid?
>
>
The initial order can be determined in orderby = .  The
displayed grid's order can be altered by clicking on the column heading of
the field you want to order.

See http://www.web2py.com/books/default/chapter/29/7

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


Re: [web2py] Many-to-many relations with CRUD Insert

2012-01-16 Thread Johann Spies
On 16 January 2012 22:35, Christian Winterhager <
christian.winterha...@onlinehome.de> wrote:

> One of the standard examples  of many-to-many Relations is a library. For
> simplicity i choose only 3 Tables:
>
> db.define_table ('author',
> Field ('name', 'string', length=100))
>
> db.define_table ('verb',
>Field ('bnr', db.book ),
>Field ('anr', db.author ),
> )
>
> db.define_table ('book',
> Field('title', 'string', length=250))
>
> It is very easy to insert a new book, one or more author and the
> corresponding record
> in the table "verb". But i found no way to insert a book with the
> CRUD-Method. The 
> complexity
> is that i first must insert a row into  table "book", then one into table
> "author" and last i have to connect
> the inserted rows with the corresponding numbers 'bnr' and 'anr' in table
> "verb". Does anyone know if there
> is a way to do that with CRUD?
>

I don't think you can do this in one step.

I would do the following:

1. Find the author in the author table and if it is not there, insert.  For
each author, collect the id of the record.
2. Then insert the book and get the id
3. Then for each author create a record in 'verb'. I would do this in the
background without any form involved.

Regards
Johann



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


[web2py] Re: There is no web2py homebrew for OS X

2012-01-16 Thread pbreit
Might not be a bad idea but it's way better to install Web2py from source. 
Then you have excellent version control.

Re: [web2py] Re: I am looking for an html widget for lists

2012-01-16 Thread Bruno Rocha
After hours hacking Jquery plugin I have a good and working web2py
tag-widget.

http://www.diigo.com/item/image/121xl/3snt

The code is in github

-- 

Bruno Rocha
[http://rochacbruno.com.br]