[web2py] Re: Passing arg from view to controller.

2012-02-21 Thread Annet
Hi Anthony,

Thanks for your reply.

> $(function() {
>   $("#no_table_locality_args").autocomplete({
> source: "{{=URL('hubaddressbook', 'locality_args_autocomplete')}}" +
> "/" + $(select#no_table_word).val(),

I tried the above, which made the view's JavaScript invalid, I had to
add '' to make it valid JavaScript:

$('select#no_table_word').val()

Testing this, results in the following url:

.../init/hubaddressbook/locality_args_autocomplete/?term=Am


Adding option:selected: $('select#no_table_word
option:selected').val() as in http://api.jquery.com/val/ doesn't make
any difference.


When I hard code the .val() part with "Coach":

$(function() {
  $("#no_table_locality_args").autocomplete({
source: "{{=URL('hubaddressbook', 'locality_args_autocomplete')}}"
+ "/" + "Coach",
minLength: 2
  });

It all works. The url:

.../init/hubaddressbook/locality_args_autocomplete/Coach?term=Am


Removing the the jQuery UI MultiSelect from the select doesn't make
any difference.



Kind regards,

Annet


[web2py] Re: Validate the Checkbox

2012-02-21 Thread whowhywhat
also

TR("Type:",TD(INPUT(_type="checkbox",_name="options",_value="a",_size="0",requires
= IS_NOT_EMPTY(error_message="Please select
at least one check-box"))," A" ...

to have your required error message

Please check out the excellent web2py documentation for forms and
validators http://web2py.com/books/default/chapter/29/7#Validators


On Feb 21, 12:51 pm, whowhywhat  wrote:
> You can also just write a jquery validator for the same..
>
> On Feb 21, 12:49 pm, whowhywhat  wrote:
>
>
>
>
>
>
>
> > This should work. Although it is ugly (it gives a error message under
> > all the checkboxes :P ).. but does validate as you require. Please
> > check and let me know.
>
> > def multi_check_box():
> >     form = FORM(TABLE(
>
> > TR("Type:",TD(INPUT(_type="checkbox",_name="options",_value="a",_size="0",requires
> > = IS_NOT_EMPTY())," A",
>
> > INPUT(_type="checkbox",_name="options",_value="b",_size="0")," B",
>
> > INPUT(_type="checkbox",_name="options",_value="c",_size="0")," C")),
> >             TR("",INPUT(_type="submit",_value="SUBMIT" 
> >     if form.accepts(request.vars,session):
>
> >     return dict(form=form)
>
> > On Feb 21, 11:09 am, Sanjeet Kumar  wrote:
>
> > > TR("Type:",(TD(INPUT(_type="checkbox",_name="a",_value="a",_size="0"),"A"))),
>
> > > (TD(INPUT(_type="checkbox",_name="b",_value="b",_size="0"),"B")),
>
> > > (TD(INPUT(_type="checkbox",_name="c",_value="c",_size="0"),"C"))),
> > > TR("",INPUT(_type="submit",_value="SUBMIT" ))
>
> > > On Tue, Feb 21, 2012 at 11:28 AM, whowhywhat  wrote:
> > > > please could post your controller code..
>
> > > > On Feb 21, 10:32 am, Sanjeet Kumar  wrote:
> > > > > I have the multiple check-box in one row in Controller I want to 
> > > > > validate
> > > > > it form controller when the user submit his request without selecting 
> > > > > any
> > > > > of the check-box than it should be shown the error message "Please 
> > > > > select
> > > > > at least one check-box"


[web2py] Re: BELONGS is not supported on GAE?

2012-02-21 Thread Peter G.
Hmm, if that's the case, can someone recommend a viable alternative to
perform what I'm trying to do with an operation that works under GAE?

On Feb 20, 11:09 pm, guruyaya  wrote:
> I think inner select belongs are not supported by GAE, but using an
> array, is. Can anyone confirm what I just said (read the code, didn't
> test it).
>
> On 21 פברואר, 08:06, "Peter G."  wrote:
>
>
>
>
>
>
>
> > I'm trying to obtain a set of rows whose ID values belongs in rows'
> > fields of another table.
>
> > Here's the code:
>
> > # Construct a query to fetch all the mootid's from the group
> > mootGroup =
> > db(db.moot_groups.gid==groupid)._select(db.moot_groups.mootid)
> > # Gets moots only if the moot ID exists in the Group query
> > moots =
> > db((db.moots.url==request.get_vars.url)&(db.moots.id.belongs(mootGroup))).s 
> > elect(db.moots.ALL)
>
> > The error in the admin says this:
> > File "/base/data/home/apps/356965595645653415/gluon/dal.py", line
> > 3367, in BELONGS
> >     raise SyntaxError, "Not supported"
> > SyntaxError: Not supported
>
> > Thanks!


[web2py] How to optimize the output typography of blocks in web2py views?

2012-02-21 Thread chinakr
The block instructions in web2py will cause extra blank lines in final
HTML, which are useless and ugly in HTML source code.

e.g. with
{{block head}}
{{end}}
we will get two extra blank lines in final HTML.
Demo:
http://www.haijia.org/
In the source code of the page, Line 13 and line 15 are the useless
blank lines.

I would like to get a more pretty HTML, what should I do then?


[web2py] $.ajax : how to parse data sent to the controller

2012-02-21 Thread Vineet
Earlier i was using ajax() function.
But since it is not possible to send js array or json object, I am
trying $.ajax function.

--- View ---
var jsonObjects = [{id:1, name:"amit"}, {id:2, name:"ankit"},{id:3,
name:"atin"},{id:1, name:"puneet"}];

$.ajax({
 url: "{{=URL('myControllerName')}}",
 type: "POST",
 context: document.body,
 data: {students: JSON.stringify(jsonObjects) },
 dataType: "json",
 success: function(){
 alert('ok');
  }
});

--- end View ---

In controller, how do I access the data?

Somebody has give the code for grails as :---

//this code is written in grails
import grails.converters.JSON;
List students = JSON.parse(params.students) //students in
request params is parsed to json objects and stored in the List
println "Student id: " + students[0].studentId//first element of
the students list is accessed as a map holding a key studentId

In web2py, how to port this code?

Thanks,

Vineet


[web2py] Re: BELONGS is not supported on GAE?

2012-02-21 Thread BrendanC
I've just started looking Web2py and the Google App Engine - here is some 
research you might find useful. 

While this does not relate directly to Web2py it's worth reading/reviewing 
as it illustrates some gae fundamentals.
http://www.arbingersys.com/20080430/google-app-engine-a-better-many-to-many-join.html

Also look at this:
http://web2py.com/books/default/chapter/29/6#Many-to-many,-list:,-and-contains

'Belongs' is basically an SQL construct with no GAE counterpart. With GAE 
you need to rethink your data models and assume you will have some level of 
data redundancy. 
Note also that the DAL interface to the GAE has some limitations and does 
not utilitize all the features of the GAE - but that's a separate 
discussion. Some issues to be aware of are:

- debugging with GAE can be tricky
- not clear if running a local Web2py shell is supported - have not got it 
to work yet
- expect some surprises along the way to GAE enlightenment

For some decent sample Web2py/GAE code take a look here:
http://code.google.com/p/publicradioroadtrip/source/browse/

Hope this helps,
BrendanC



Re: [web2py] Re: Validate the Checkbox

2012-02-21 Thread Sanjeet Kumar
I got it but you are putted here the same name of the check box through
which we can validate the multiple checkbox eaisly but here i want the
value of the different check box in different variables for checking the
multiple conditions.
such as
qury=db((db.employee.name==a ) | (db.employee.name==b ) | (db.employee.name==b
)).select()

On Tue, Feb 21, 2012 at 1:36 PM, whowhywhat  wrote:

> also
>
>
> TR("Type:",TD(INPUT(_type="checkbox",_name="options",_value="a",_size="0",requires
> = IS_NOT_EMPTY(error_message="Please select
> at least one check-box"))," A" ...
>
> to have your required error message
>
> Please check out the excellent web2py documentation for forms and
> validators http://web2py.com/books/default/chapter/29/7#Validators
>
>
> On Feb 21, 12:51 pm, whowhywhat  wrote:
> > You can also just write a jquery validator for the same..
> >
> > On Feb 21, 12:49 pm, whowhywhat  wrote:
> >
> >
> >
> >
> >
> >
> >
> > > This should work. Although it is ugly (it gives a error message under
> > > all the checkboxes :P ).. but does validate as you require. Please
> > > check and let me know.
> >
> > > def multi_check_box():
> > > form = FORM(TABLE(
> >
> > >
> TR("Type:",TD(INPUT(_type="checkbox",_name="options",_value="a",_size="0",requires
> > > = IS_NOT_EMPTY())," A",
> >
> > > INPUT(_type="checkbox",_name="options",_value="b",_size="0")," B",
> >
> > > INPUT(_type="checkbox",_name="options",_value="c",_size="0")," C")),
> > > TR("",INPUT(_type="submit",_value="SUBMIT" 
> > > if form.accepts(request.vars,session):
> >
> > > return dict(form=form)
> >
> > > On Feb 21, 11:09 am, Sanjeet Kumar  wrote:
> >
> > > >
> TR("Type:",(TD(INPUT(_type="checkbox",_name="a",_value="a",_size="0"),"A"))),
> >
> > > > (TD(INPUT(_type="checkbox",_name="b",_value="b",_size="0"),"B")),
> >
> > > > (TD(INPUT(_type="checkbox",_name="c",_value="c",_size="0"),"C"))),
> > > > TR("",INPUT(_type="submit",_value="SUBMIT" ))
> >
> > > > On Tue, Feb 21, 2012 at 11:28 AM, whowhywhat 
> wrote:
> > > > > please could post your controller code..
> >
> > > > > On Feb 21, 10:32 am, Sanjeet Kumar  wrote:
> > > > > > I have the multiple check-box in one row in Controller I want to
> validate
> > > > > > it form controller when the user submit his request without
> selecting any
> > > > > > of the check-box than it should be shown the error message
> "Please select
> > > > > > at least one check-box"
>


[web2py] Hide the Links based on Permission

2012-02-21 Thread Sanjeet Kumar
I am using the same layout for the Admin and Client but i want to hide some 
links for the clients in my page based on the permissions 


[web2py] Re: crontab sytax

2012-02-21 Thread Wikus van de Merwe
I say the book works just fine: 
http://web2py.com/book/default/chapter/04#Cron

The syntax you want to use is: @reboot * * * * root 
*applications/test/controllers/private.py
Set that in your app/cron/crontab and make sure your controller does 
db.commit() at the end.

Also you need SOFTCRON = True in the wsgihandler (if you run it as WSGI 
script).




[web2py] Re: Validate the Checkbox

2012-02-21 Thread Wikus van de Merwe
The easiest way to do that is rely on web2py model -> form transformation 
and use a validator (instead of the custom form).

model
--
MY_OPTIONS = ["a","b","c"]
db.define_table("my_table",
db.Field("my_options", "list:string", default=MY_OPTIONS))

db.my_table.my_options.widget = SQLFORM.widgets.checkboxes.widget
db.my_table.my_options.requires = [IS_IN_SET(MY_OPTIONS, multiple=True), 
IS_NOT_EMPTY()]

controller
--
def my_function():
if len(request.args):
form=SQLFORM(db.my_table, request.args[0])
else:
form=SQLFORM(db.my_table)

if form.accepts(request.vars):
redirect(URL(r=request, f='my_next_function', args=[form.vars.id]))

return {"form":form}



[web2py] Re: How to optimize the output typography of blocks in web2py views?

2012-02-21 Thread Wikus van de Merwe
You can do tricks like that, but it does not have the best readability:
{{ for i in range(10):
}}  text {{=i}} text  {{
pass }}



Re: [web2py] Re: Web2py Code University and Officaial Certify Training

2012-02-21 Thread Kanthi Narisetti
I appreciate your thoughts. I would suggest an online course(on Google+), 
tutorials involving some real time projects. Also we can take advantage of 
google hangouts etc to make it more interactive. I have been working on 
building a web development team for my friends startup and I face the same 
issue with the freshers. I can hardly find people with Python  knowledge. I 
am a systems administrator based in hyderabad(India) and interested to 
learn web2py after reading about it. Hope some of the web2py experts also 
become part of this.

 



[web2py] I save content of textarea into db.doc following,

2012-02-21 Thread web2py_lover
I save content of textarea into db.docas  following,

 db.define_table('doc',
   Field('title'),
   Field('content', 'text'))

 But how can I save this 'text' content into xxx.doc (as ms office
format) for downloading?

Can pyRTF do this thing, how to ? Thank you all.


[web2py] Re: $.ajax : how to parse data sent to the controller

2012-02-21 Thread Wikus van de Merwe
if "students" in request.vars:
  students = json.loads(request.vars.students)
  print students[0]["student_id"]

For python 2.5 you might need to import the simplejson from contrib (I'm 
not sure if this is done automatically):
import gluon.contrib.simplejson as json



[web2py] Re: Validate the Checkbox

2012-02-21 Thread whowhywhat
Good tip Wikus..
you can also do the something similar with SQLFORM.factory and not
define in the model (that way no DB table is created)

in controller

MY_OPTIONS = ["a","b","c"]
form = SQLFORM.factory(
Field("my_options", "list:string",
default=MY_OPTIONS,widget=SQLFORM.widgets.checkboxes.widget,
requires=[IS_IN_SET(MY_OPTIONS,
multiple=True),IS_NOT_EMPTY()]))
if form.accepts(request.vars):
#code to process form
return dict(form=form)


On Feb 21, 4:03 pm, Wikus van de Merwe 
wrote:
> The easiest way to do that is rely on web2py model -> form transformation
> and use a validator (instead of the custom form).
>
> model
> --
> MY_OPTIONS = ["a","b","c"]
> db.define_table("my_table",
>     db.Field("my_options", "list:string", default=MY_OPTIONS))
>
> db.my_table.my_options.widget = SQLFORM.widgets.checkboxes.widget
> db.my_table.my_options.requires = [IS_IN_SET(MY_OPTIONS, multiple=True),
> IS_NOT_EMPTY()]
>
> controller
> --
> def my_function():
>     if len(request.args):
>         form=SQLFORM(db.my_table, request.args[0])
>     else:
>         form=SQLFORM(db.my_table)
>
>     if form.accepts(request.vars):
>         redirect(URL(r=request, f='my_next_function', args=[form.vars.id]))
>
>     return {"form":form}


[web2py] Re: Validate the Checkbox

2012-02-21 Thread Sanjeet Kumar
Thanks My problems are solved


[web2py] Re: $.ajax : how to parse data sent to the controller

2012-02-21 Thread Vineet
Oh I see.
It worked as per your tip.
Thank you !
:)

-- Vineet


On Feb 21, 4:17 pm, Wikus van de Merwe 
wrote:
> if "students" in request.vars:
>   students = json.loads(request.vars.students)
>   print students[0]["student_id"]
>
> For python 2.5 you might need to import the simplejson from contrib (I'm
> not sure if this is done automatically):
> import gluon.contrib.simplejson as json


[web2py] Re: Passing arg from view to controller.

2012-02-21 Thread Alan Etkin
> I tried the above, which made the view's JavaScript invalid, I had to
> add '' to make it valid JavaScript:

> $('select#no_table_word').val()

> Testing this, results in the following url:

> .../init/hubaddressbook/locality_args_autocomplete/?term=Am

So jQuery doesn't find data in 'select#no_table_word' (it seems to be
returning an empty string). I assume that "Coach" can be any term to
be sent for the automplete feature. Check if the selector is named
correctly. You could add extra javascript to debug (for example send
the .val() output to a popup alert() window). Does that javascript
section start when a user types data in? (check wether the function is
called after the event)


[web2py] math Division in web2py

2012-02-21 Thread Hassan Alnatour
Dear All ,

i have two variables am using  :

1 - myfull >>> returns 3
2 - myfull 2  >>> returns 5

so what am trying to do is  myfull1 = (myfull / myfull2)* 100 , so i
can get a percent  >>> {{=myfull1%}} but i keep geting 0 it should be
60%




[web2py] Re: Hide the Links based on Permission

2012-02-21 Thread Alan Etkin
There is a lot of options by using the auth object features and
templates. I think the online manual has many examples on this.
http://web2py.com/books/default/chapter/29/9

Maybe this can help:
groups.google.com/group/web2py/browse_thread/thread/cda7a114fb627b86/
cb1adee3cf4c8940

On Feb 21, 7:17 am, Sanjeet Kumar  wrote:
> I am using the same layout for the Admin and Client but i want to hide some
> links for the clients in my page based on the permissions


[web2py] cached values from background tasks

2012-02-21 Thread Brian Will
In parts of my app, some needed values take a long time to generate,
so I'm farming the generation of these values out to Scheduled tasks
and designing with the expectation that some values just won't be
ready to include in a page. When ready, the generated values are then
incorporated into the page on subsequent requests or by ajax calls
from the page.

Almost always, I want to cache these generated values.  I thought this
seemed a common enough need that a mechanism should be incorporated
with the task Scheduler. Here's a start at what this might look like:

def bgCache(key, db, task, args=None, time_expire=60 * 60 * 24,
cache=cache.ram):
'''
cache argument expects either cache.ram or cache.disk

If the value was sitting in the cache, return it from the cache.
If the value is not in the cache, check if task was previously run
and has completed, in which case get the output value from the task
db.
Otherwise, schedule the task and return None to indicate that the
value is not ready. TODO use a special sentinel value to indicate no
value? Maybe just throw an exception?
'''
val = cache(key, lambda: None, time_expire=time_expire)
if val == None:
# see if task has been completed and get value
val = getTaskOutput(task):
if val == None:
scheduleTask(task, args)  # TODO don't schedule redundant
tasks
else:
cache(key, None)
cache(key, lambda: val, time_expire=time_expire)
return val

So calling bgCache('key'...) returns the value for 'key' if it's
already in cache or if the task to generate it has completed;
otherwise, the task is scheduled and None returned. (So None couldn't
be a valid generated value. Arguably, some other special sentinel
value should be used to indicate that the generated value is not ready
so that None could be used as a valid generated value.)

To make this work generically, the input and output to the task would
be passed through the db as JSON. If I'm not wrong, this would serve
most Scheduler use cases while obviating any custom task db tables.

Of course, the precise details and API need some thought. Perhaps
bgCache could instead be a Scheduler method called 'cache'. Any
thoughts?


[web2py] Re: Dedicated IDE beginner

2012-02-21 Thread Alan Etkin
Have you followed the installation instructions?

I think I have managed to run welcome inside ide2py (with mercurial)

The alternative installation (without mercurial) shouldn't be much
different, downloading the packages and extracting de data into the
specified folders.

http://code.google.com/p/rad2py/wiki/InstallationGuide#ide2py_Quick_Install

On Feb 19, 7:26 am, Ashraf Mansour  wrote:
> Hi all,
>
> I installed red2py and web2py. No mercurial , No psp.
>
> ide2py.ini pointing to web2py server.
>
> ((python main.py)) will showide2py(no files open) and start the
> application welcome in a browser.
>
> How can i run and debug welcome application insideide2py(as in the
> screenshots , no mercurial) ?
>
> Regards,
>
> Ashraf


[web2py] Re: Hide the Links based on Permission

2012-02-21 Thread Hassan Alnatour
{{if auth.has_permission == "SeeLinks"}}

  Your link here

{{pass}}

 make a group called myadmin and add the ones who you want to see the
links and then give myadmin group permission "SeeLinks" ...

Best Regards,
Hassan Alnatour



[web2py] Re: math Division in web2py

2012-02-21 Thread Brian Will
This is actually just a Python quirk:

In Python 2.x, the / operator always returns an integer when both
operands are integers, e.g. (5 / 2) returns 2, not  2.5. The solution
is to simply make one or both operands a float:

percent = float(x) / y * 100   # x/y as a percentage

If you want your percent value to be an integer:

percent = int(float(x) / y * 100)   # x/y as a percentage

On Feb 21, 3:45 am, Hassan Alnatour 
wrote:
> Dear All ,
>
> i have two variables am using  :
>
> 1 - myfull >>> returns 3
> 2 - myfull 2  >>> returns 5
>
> so what am trying to do is  myfull1 = (myfull / myfull2)* 100 , so i
> can get a percent  >>> {{=myfull1%}} but i keep geting 0 it should be
> 60%


[web2py] New official release, any time soon?

2012-02-21 Thread guruyaya
It's been quite some time since the last official release. There are
several features in trunk, that I'd love to use, but I cannot use
unstable releases (like trunk). when are we seeing another version?
Thanks

Yair


[web2py] force mobilize

2012-02-21 Thread OpenMercury
I was wondering if there is a way to set a global variable that would
force a site to present in mobile mode.  Thanks for the help.


[web2py] Re: How to optimize the output typography of blocks in web2py views?

2012-02-21 Thread chinakr
Sorry, but I am puzzled with your suggestion @_@

On 2月21日, 下午7时09分, Wikus van de Merwe 
wrote:
> You can do tricks like that, but it does not have the best readability:
> {{ for i in range(10):}}  text {{=i}} text  {{
>
> pass }}


[web2py] How can I Show the html output of a controller function from shell

2012-02-21 Thread guruyaya
I'm looking for a way to create a command line script, that will
enable me to send all possible params for a certin request
(originating ip, requested app, requested controller and so on), and
get the HTML output (or, if possible, an object containing the full
response, including header options). Is there any way to achive that?

Thanks in advance:
Yair


[web2py] Re: Dedicated IDE beginner

2012-02-21 Thread Ashraf Mansour
Thanks

yesterday, I download the wing trial version. it is perfect.

On Feb 21, 2:55 pm, Alan Etkin  wrote:
> Have you followed the installation instructions?
>
> I think I have managed to run welcome inside ide2py (with mercurial)
>
> The alternative installation (without mercurial) shouldn't be much
> different, downloading the packages and extracting de data into the
> specified folders.
>
> http://code.google.com/p/rad2py/wiki/InstallationGuide#ide2py_Quick_I...
>
> On Feb 19, 7:26 am, Ashraf Mansour  wrote:
>
>
>
>
>
>
>
> > Hi all,
>
> > I installed red2py and web2py. No mercurial , No psp.
>
> > ide2py.ini pointing to web2py server.
>
> > ((python main.py)) will showide2py(no files open) and start the
> > application welcome in a browser.
>
> > How can i run and debug welcome application insideide2py(as in the
> > screenshots , no mercurial) ?
>
> > Regards,
>
> > Ashraf


[web2py] Re: How to optimize the output typography of blocks in web2py views?

2012-02-21 Thread Anthony
In the case of blocks, I think Wikus is suggesting:

{{block head
}}[your block markup]{{
end}}

But you can also do:

{{block head}}[your block markup...
...more block markup]{{end}}

Anthony

On Tuesday, February 21, 2012 8:13:11 AM UTC-5, chinakr wrote:
>
> Sorry, but I am puzzled with your suggestion @_@ 
>
> On 2月21日, 下午7时09分, Wikus van de Merwe  
> wrote: 
> > You can do tricks like that, but it does not have the best readability: 
> > {{ for i in range(10):}}  text {{=i}} text  {{ 
> > 
> > pass }}



[web2py] Re: How can I Show the html output of a controller function from shell

2012-02-21 Thread Anthony
Are you saying you want to call a web2py URL from a script and receive the 
HTML output? You should be able to do that the same way as you would any 
external URL:

import urllib
html = urllib.urlopen('http://[web2py url]').read()

Or using the shortcut web2py fetch method:

from gluon.tools import fetch
html = fetch('http://[web2py url]')

If you're running the script in a web2py environment (i.e., python 
web2py.py -S myapp/mycontroller -M -N -R myscript.py), you can do:

html = response.render('mycontroller/myfunction.html', myfunction())

Anthony

On Tuesday, February 21, 2012 8:39:51 AM UTC-5, guruyaya wrote:
>
> I'm looking for a way to create a command line script, that will 
> enable me to send all possible params for a certin request 
> (originating ip, requested app, requested controller and so on), and 
> get the HTML output (or, if possible, an object containing the full 
> response, including header options). Is there any way to achive that? 
>
> Thanks in advance: 
> Yair



[web2py] Re: force mobilize

2012-02-21 Thread OpenMercury
I forgot to mention, this would be done when a user would trigger this
via link or maybe from a specific site that they arrived from.

On Feb 21, 8:12 am, OpenMercury  wrote:
> I was wondering if there is a way to set a global variable that would
> force a site to present in mobile mode.  Thanks for the help.


[web2py] Re: New member and new to web2py and need some clarification about file paths.

2012-02-21 Thread Anthony

>
> Thanks for pointing me in the right direction for the docs. URL 
> rewrite was the next thing I was going to be looking for since right 
> now we're exposing the user pages from default/user/account etc. I 
> wanted to omit the /default/ but I haven't gotten around to that point 
> yet. I'm sure you've saved me a bit of time by pointing that out to 
> me. Thanks for that.


Should be simple -- in /web2py/routes.py, something like:

routers = dict(
BASE = dict(
default_application = 'yourapp',
default_controller = 'default',
default_function = 'index',
root_static = ['robots.txt', 'favicon.ico', 'crossdomain.xml'],
map_hyphen = True
),
)

Anthony



[web2py] Re: Web2py Code University and Officaial Certify Training

2012-02-21 Thread Massimo Di Pierro
There are various people offering web2py courses and certification in
various languages. I think there is a value in putting all the
information together and sharing (some) course material.

I am happy to list them all under web2py.com and/or
experts4solutions.com

If you are teaching using web2py please tell us more here.

Massimo

On Feb 21, 2:26 am, Kanthi Narisetti  wrote:
> I appreciate your thoughts. I would suggest an online course(on Google+),
> tutorials involving some real time projects. Also we can take advantage of
> google hangouts etc to make it more interactive. I have been working on
> building a web development team for my friends startup and I face the same
> issue with the freshers. I can hardly find people with Python  knowledge. I
> am a systems administrator based in hyderabad(India) and interested to
> learn web2py after reading about it. Hope some of the web2py experts also
> become part of this.


[web2py] Re: I save content of textarea into db.doc following,

2012-02-21 Thread Massimo Di Pierro
yes. There are some example in the source and on the
http://web2py.com/examples/default/examples page

On Feb 21, 3:27 am, web2py_lover  wrote:
> I save content of textarea into db.docas  following,
>
>  db.define_table('doc',
>    Field('title'),
>    Field('content', 'text'))
>
>  But how can I save this 'text' content into xxx.doc (as ms office
> format) for downloading?
>
> Can pyRTF do this thing, how to ? Thank you all.


[web2py] Re: New official release, any time soon?

2012-02-21 Thread Massimo Di Pierro
Next week. Meanwhile try the nightly built

On Feb 21, 7:01 am, guruyaya  wrote:
> It's been quite some time since the last official release. There are
> several features in trunk, that I'd love to use, but I cannot use
> unstable releases (like trunk). when are we seeing another version?
> Thanks
>
> Yair


[web2py] Re: How can I Show the html output of a controller function from shell

2012-02-21 Thread guruyaya
Good. I think you'll like what I'm about to do with this one...

On 21 פברואר, 16:06, Anthony  wrote:
> Are you saying you want to call a web2py URL from a script and receive the
> HTML output? You should be able to do that the same way as you would any
> external URL:
>
> import urllib
> html = urllib.urlopen('http://[web2pyurl]').read()
>
> Or using the shortcut web2py fetch method:
>
> from gluon.tools import fetch
> html = fetch('http://[web2pyurl]')
>
> If you're running the script in a web2py environment (i.e., python
> web2py.py -S myapp/mycontroller -M -N -R myscript.py), you can do:
>
> html = response.render('mycontroller/myfunction.html', myfunction())
>
> Anthony
>
>
>
>
>
>
>
> On Tuesday, February 21, 2012 8:39:51 AM UTC-5, guruyaya wrote:
>
> > I'm looking for a way to create a command line script, that will
> > enable me to send all possible params for a certin request
> > (originating ip, requested app, requested controller and so on), and
> > get the HTML output (or, if possible, an object containing the full
> > response, including header options). Is there any way to achive that?
>
> > Thanks in advance:
> > Yair


[web2py] Re: Any way to make web2py SQLFORM.grid accept inserted fields?

2012-02-21 Thread whowhywhat
anybody .. please .. pretty please :)..

On Feb 21, 10:20 am, whowhywhat  wrote:
> I need a web2py SQLFORM.grid to accept and process based on some
> conditions, which need to be triggered based on some check boxes. I
> have inserted these checkboxes into the form by doing something like :
>
> In the controller -
>
> def my_grid():
> form = SQLFORM.grid()
>
> if  len(request.args)>1 and (request.args[0]=='new' or 'edit') and
> (form.create_form or form.edit_form):
>         my_extra_element = TR(TD(LABEL('Process x:'),
> _class='w2p_fl'), INPUT(_name='Do X', default=False,
>             _value='on', _type='checkbox',_id='process_x'))
>     if form.create_form:
>         form.create_form[0].insert(-1,my_extra_element)
>     if form.edit_form:
>         form.edit_form[0].insert(-1,my_extra_element)
>     if request.post_vars: session.tmp = request.post_vars
> return dict(form=form)
>
> Adding the custom elements is straight forward and easy..
> Is there some way to store and pass the value of the custom inserted
> check-box or any such customized form?
> I have tried many things.. but have not been successful so far.
> Any help is greatly appreciated :) ..


[web2py] Re: Any way to make web2py SQLFORM.grid accept inserted fields?

2012-02-21 Thread Cliff
## Caveat beware sloppy syntax below
## DO NOT forget to validate!!

def add_my_field(form):
  form.vars.myfield = request.post_vars.myfield

# After defining the form but before returning the dict
if form[0].process(onvalidation=add_my_field)
On Feb 21, 10:09 am, whowhywhat  wrote:
> anybody .. please .. pretty please :)..
>
> On Feb 21, 10:20 am, whowhywhat  wrote:
>
>
>
>
>
>
>
> > I need a web2py SQLFORM.grid to accept and process based on some
> > conditions, which need to be triggered based on some check boxes. I
> > have inserted these checkboxes into the form by doing something like :
>
> > In the controller -
>
> > def my_grid():
> > form = SQLFORM.grid()
>
> > if  len(request.args)>1 and (request.args[0]=='new' or 'edit') and
> > (form.create_form or form.edit_form):
> >         my_extra_element = TR(TD(LABEL('Process x:'),
> > _class='w2p_fl'), INPUT(_name='Do X', default=False,
> >             _value='on', _type='checkbox',_id='process_x'))
> >     if form.create_form:
> >         form.create_form[0].insert(-1,my_extra_element)
> >     if form.edit_form:
> >         form.edit_form[0].insert(-1,my_extra_element)
> >     if request.post_vars: session.tmp = request.post_vars
> > return dict(form=form)
>
> > Adding the custom elements is straight forward and easy..
> > Is there some way to store and pass the value of the custom inserted
> > check-box or any such customized form?
> > I have tried many things.. but have not been successful so far.
> > Any help is greatly appreciated :) ..


[web2py] Re: how to modify scaffolding form for a specific model

2012-02-21 Thread Can Candan
Great, thank you

On Feb 21, 5:43 am, Anthony  wrote:
> Here are some
> options:http://stackoverflow.com/questions/8146260/best-practice-for-populati...
>
> Anthony
>
>
>
>
>
>
>
> On Sunday, February 19, 2012 2:41:14 PM UTC-5, Can Candan wrote:
>
> > I am willing to extend the behavior of the autogenerated crud interface
> > just for one table so that when the dropdown corresponding to a one-to-many
> > relation is selected
> > another dropdown should display values corresponding to the chosen one.
>
> > In other words i need a dynamic restriction, something like this.
> > db.entity.value.requires=IS_IN_DB(results of query here corresponding to
> > the previous selection)
>
> > What might be the easiest way to do that?


[web2py] Re: Hide the Links based on Permission

2012-02-21 Thread nick name
Whichever way you choose, make sure you verify permissions on the server as 
well -- don't rely on not presenting the link to the client as a form of 
security.


[web2py] Re: Any way to make web2py SQLFORM.grid accept inserted fields?

2012-02-21 Thread whowhywhat
Thanks a lot cliff! :) .. really appreciate it!

On Feb 21, 9:39 pm, Cliff  wrote:
> ## Caveat beware sloppy syntax below
> ## DO NOT forget to validate!!
>
> def add_my_field(form):
>   form.vars.myfield = request.post_vars.myfield
>
> # After defining the form but before returning the dict
> if form[0].process(onvalidation=add_my_field)
> On Feb 21, 10:09 am, whowhywhat  wrote:
>
>
>
>
>
>
>
> > anybody .. please .. pretty please :)..
>
> > On Feb 21, 10:20 am, whowhywhat  wrote:
>
> > > I need a web2py SQLFORM.grid to accept and process based on some
> > > conditions, which need to be triggered based on some check boxes. I
> > > have inserted these checkboxes into the form by doing something like :
>
> > > In the controller -
>
> > > def my_grid():
> > > form = SQLFORM.grid()
>
> > > if  len(request.args)>1 and (request.args[0]=='new' or 'edit') and
> > > (form.create_form or form.edit_form):
> > >         my_extra_element = TR(TD(LABEL('Process x:'),
> > > _class='w2p_fl'), INPUT(_name='Do X', default=False,
> > >             _value='on', _type='checkbox',_id='process_x'))
> > >     if form.create_form:
> > >         form.create_form[0].insert(-1,my_extra_element)
> > >     if form.edit_form:
> > >         form.edit_form[0].insert(-1,my_extra_element)
> > >     if request.post_vars: session.tmp = request.post_vars
> > > return dict(form=form)
>
> > > Adding the custom elements is straight forward and easy..
> > > Is there some way to store and pass the value of the custom inserted
> > > check-box or any such customized form?
> > > I have tried many things.. but have not been successful so far.
> > > Any help is greatly appreciated :) ..


[web2py] Re: New official release, any time soon?

2012-02-21 Thread nick name
Is that going to be 2.0? 

IMO, the rocket download problem which AFAIK has not yet been fixed is a 
blocker for 2.0
Also, IIRC, Bruno is working on Bootstrap integration -- which is probably 
worthy of delaying 2.0 for (Web2py 2: Now with bootstrap!)


[web2py] can the query in IS_IN_DB have more than one table?

2012-02-21 Thread Ashraf Mansour
Hi All,

can the query in IS_IN_DB have more than one table?

And how the fields of these tables be referenced in the format, to be
shown in the dropbox ?

Thanks in advance.

Ashraf


[web2py] cache to disk zipped files

2012-02-21 Thread james c.
My application/controller is creating a zipped folder of files
specific to each use and then the user downloads the folder.  I'm able
to create the zipped folders OK and set up the disk caching without
apparently any errors, and I see that the system is updating the files
in the applications cache folder. Is Web2Py cacheing the original
file? Web2Py is not removing the file and when I have the controller
delete the original file the application crashes upon download,
despite the download is supposed to be from the cached version of the
file.

 What I want to do is have the system automatically remove the zipped
file after they have been downloaded.

I am trying to do this with:

   the_path = 'theZipped_Files' + response.session_id + '.zip';


t = cache.disk('files_zipped', lambda: the_path , time_expire=3*60);
#   import os;
#   os.remove(the_path);
return response.stream(open(t,'rb'),chunk_size=4096)

The above code downloads the correct zipped files. If I un-comment the
above commented code, "empty" zipped files are downloaded.
Any advice appreciated - thanks in advance, James


Re: [web2py] can the query in IS_IN_DB have more than one table?

2012-02-21 Thread Richard Vézina
For represent I usually do :

lambda id: db.fktable1(id).represent_field # 1 table
lambda id: db.fktable2(db.fktable1(id).id).represent_field_table2 # 2 table

You can maybe proceding the same way, but I am not sure... I am still using
old requires syntax...

Please report your experiment and how you solve it.

Richard

On Tue, Feb 21, 2012 at 1:57 PM, Ashraf Mansour wrote:

> Hi All,
>
> can the query in IS_IN_DB have more than one table?
>
> And how the fields of these tables be referenced in the format, to be
> shown in the dropbox ?
>
> Thanks in advance.
>
> Ashraf
>


[web2py] Re: New official release, any time soon?

2012-02-21 Thread Massimo Di Pierro
probably 1.99.6

On Feb 21, 11:26 am, nick name  wrote:
> Is that going to be 2.0?
>
> IMO, the rocket download problem which AFAIK has not yet been fixed is a
> blocker for 2.0
> Also, IIRC, Bruno is working on Bootstrap integration -- which is probably
> worthy of delaying 2.0 for (Web2py 2: Now with bootstrap!)


[web2py] new feature in trunk...

2012-02-21 Thread Massimo Di Pierro
not sure if it should stay and for sure it can be improved. I use it a
lot.

def index():
 import os
 from gluon.tools import Expose
 return dict(expose=Expose(os.path.join(request.folder,'static')))


[web2py] web2py.com is dead

2012-02-21 Thread Richard
Hello,

web2py.com not online...

It just happen.

Richard


[web2py] Re: new feature in trunk...

2012-02-21 Thread Anthony
Cool. Shouldn't:

filename = os.path.join(base, '/'.join(current.request.args))

be:

filename = os.path.join(base, os.path.sep.join(current.request.args))

or maybe just:

filename = os.path.join(base, *current.request.args)

Anthony

On Tuesday, February 21, 2012 2:57:43 PM UTC-5, Massimo Di Pierro wrote:
>
> not sure if it should stay and for sure it can be improved. I use it a 
> lot. 
>
> def index(): 
>  import os 
>  from gluon.tools import Expose 
>  return dict(expose=Expose(os.path.join(request.folder,'static'))) 
>


Re: [web2py] web2py.com is dead

2012-02-21 Thread Vasile Ermicioi
it is down ...


[web2py] concurrency, web2py, and GAE

2012-02-21 Thread howesc
Hello all,

a question about web2py and concurrent requests on GAE - I'm seeing some 
odd behavior and i would like to know if my theory is at all reasonable, 
and suggestions for testing my theory.  an RTFM (read the friggen manual) 
response is just fine - can you point me to the manual?

my assertion:  on GAE web2py puts per-request items into the shared global 
namespace, such as db and auth.  this causes problems on GAE with 
concurrency enabled because data gets clobbered.

why do i believe this?  well, i turned on concurrency (threadsafe: true) in 
app.yaml and after some time as the site gets loaded with real users (i 
have not run into this when testing probably because i don't generate 
enough test traffic) i see errors like:

  File 
"/base/data/home/apps/s~myapp/default-30a0bc01f698.356965928401701861/applications/myapp/controllers/admin_stores.py",
 line 10, in 
auth.settings.actions_disabled=['profile', 'change_password']
NameError: name 'auth' is not defined

AttributeError: 'auth_user' object has no attribute 'preferred_store'

  File 
"/base/data/home/apps/s~myapp/default-30a0bc01f698.356965928401701861/applications/myapp/controllers/order.py",
 line 12, in 
db.store.virtualfields.append(StoreVirtualFields())
NameError: name 'db' is not defined


  File 
"/base/data/home/apps/s~myapp/default-30a0bc01f698.356965928401701861/applications/myapp/controllers/food.py",
 line 22, in menu
response.title = response.title + " - Our Menu"
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'

i'd love to prove or disprove my theory that what is happening is that 
while the request that errors is being processed, db.py (and menu.py) is 
being evaluated for a second request, essentially clearing variables like 
db, auth, and perhaps even response  (the None response.title when 
response.title is set in menu.py is most concerning).

i admit to not fully understanding how the run_X_in_environment(), and 
build_environment() and python variable scoping works well enough to know 
if my theory is valid and how best to test my theory?  i've thought about 
putting a sleep in db.py just to see if i can reliably re-create this type 
of behaviour.

any thoughts?

thanks,

christian



[web2py] Re: what triggers a db migration

2012-02-21 Thread Fred
[Replying to old message; I'm way behind]

On Jan 15, 1:21 am, pbreit  wrote:
> I think web2py compares the .table files to the
> database to figure out what needs to be migrated.

Is this correct?  Everything I've seen suggests that web2py compares
the .table files to the model files (models/*.py) to determine what
has changed and therefore needs migration.  I have not seen any sign
that web2py does introspection on the database itself.


[web2py] book says auth.archive saves old record but it actually saves the new one

2012-02-21 Thread simon
The book says that auth.archive "stores a copy of the record (as it
was before the update)". However with SQLFORM it appears to store a
copy of the record after the update unless you do workaround (from
Anthony in previous post):

if form.process(...onsuccess=lambda archive: auth.archive(form,
archive_current=False))

Seems to me the book version is more intuitive.


[web2py] Re: can the query in IS_IN_DB have more than one table?

2012-02-21 Thread Ashraf Mansour
Thank you for the immediate reply.

please rewrite the example using the old requires syntax.

On Feb 21, 10:39 pm, Richard Vézina 
wrote:
> For represent I usually do :
>
> lambda id: db.fktable1(id).represent_field # 1 table
> lambda id: db.fktable2(db.fktable1(id).id).represent_field_table2 # 2 table
>
> You can maybe proceding the same way, but I am not sure... I am still using
> old requires syntax...
>
> Please report your experiment and how you solve it.
>
> Richard
>
> On Tue, Feb 21, 2012 at 1:57 PM, Ashraf Mansour wrote:
>
>
>
>
>
>
>
> > Hi All,
>
> > can the query in IS_IN_DB have more than one table?
>
> > And how the fields of these tables be referenced in the format, to be
> > shown in the dropbox ?
>
> > Thanks in advance.
>
> > Ashraf


[web2py] Re: Apache/mod_wsgi: Exposing individual web2py apps alongside other non-web2py services

2012-02-21 Thread Fred
I faced something similar when I wanted to run two different versions
of web2py (the framework itself) on one server.  It worked well to use
a pattern like this:

WSGIScriptAliasMatch^/(someappname) 
/var/local/web2py/wsgihandler.py/
$1
AliasMatch ^/(someappname)/static/(.*)  /var/local/web2py/
applications/$1/static/$2

That routes exactly the "/someappname/*" URLs to the particular web2py
instance.  I had other alias rules set up to route things to the
second web2py instance.  That second instance could have instead been
PHP content or the like, I believe.

By passing the matched app path prefix as an argument to
wsgihandler.py I didn't need a routes.py file at all.  The WSGI and
web2py machinery took care of the details.  Very slick.  (Each web2py
instance has its own WSGIProcessGroup associated with its directory.)


[web2py] Re: crontab sytax

2012-02-21 Thread web-dev-m
The chapter works, the link to the syntax does not.

http://web2py.com/books/default/reference/29/cron


On Feb 21, 4:50 am, Wikus van de Merwe 
wrote:
> I say the book works just fine:http://web2py.com/book/default/chapter/04#Cron
>
> The syntax you want to use is: @reboot * * * * root
> *applications/test/controllers/private.py
> Set that in your app/cron/crontab and make sure your controller does
> db.commit() at the end.
>
> Also you need SOFTCRON = True in the wsgihandler (if you run it as WSGI
> script).


Re: [web2py] Re: can the query in IS_IN_DB have more than one table?

2012-02-21 Thread Richard Vézina
Old

IS_IN_DB(helper_set,'table.id','%(field1)s (%(field2)s)',multiple=True)

Maybe this work but not sure :

IS_IN_DB(helper_set,'table.id',db.table2(db.table1.id
).fieldTable2,multiple=True)


Richard

On Tue, Feb 21, 2012 at 4:21 PM, Ashraf Mansour wrote:

> Thank you for the immediate reply.
>
> please rewrite the example using the old requires syntax.
>
> On Feb 21, 10:39 pm, Richard Vézina 
> wrote:
> > For represent I usually do :
> >
> > lambda id: db.fktable1(id).represent_field # 1 table
> > lambda id: db.fktable2(db.fktable1(id).id).represent_field_table2 # 2
> table
> >
> > You can maybe proceding the same way, but I am not sure... I am still
> using
> > old requires syntax...
> >
> > Please report your experiment and how you solve it.
> >
> > Richard
> >
> > On Tue, Feb 21, 2012 at 1:57 PM, Ashraf Mansour  >wrote:
> >
> >
> >
> >
> >
> >
> >
> > > Hi All,
> >
> > > can the query in IS_IN_DB have more than one table?
> >
> > > And how the fields of these tables be referenced in the format, to be
> > > shown in the dropbox ?
> >
> > > Thanks in advance.
> >
> > > Ashraf
>


Re: [web2py] Re: can the query in IS_IN_DB have more than one table?

2012-02-21 Thread Richard Vézina
On Tue, Feb 21, 2012 at 4:27 PM, Richard Vézina  wrote:

> Old
>
> IS_IN_DB(helper_set,'table.id','%(field1)s (%(field2)s)',multiple=True) #
> One table
>
> Maybe this work but not sure :
>
> IS_IN_DB(helper_set,'table.id',db.table2(db.table1.id).fieldTable2,multiple=True)
> # 2 tables
>
>
> Richard
>
> On Tue, Feb 21, 2012 at 4:21 PM, Ashraf Mansour wrote:
>
>> Thank you for the immediate reply.
>>
>> please rewrite the example using the old requires syntax.
>>
>> On Feb 21, 10:39 pm, Richard Vézina 
>> wrote:
>> > For represent I usually do :
>> >
>> > lambda id: db.fktable1(id).represent_field # 1 table
>> > lambda id: db.fktable2(db.fktable1(id).id).represent_field_table2 # 2
>> table
>> >
>> > You can maybe proceding the same way, but I am not sure... I am still
>> using
>> > old requires syntax...
>> >
>> > Please report your experiment and how you solve it.
>> >
>> > Richard
>> >
>> > On Tue, Feb 21, 2012 at 1:57 PM, Ashraf Mansour > >wrote:
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > > Hi All,
>> >
>> > > can the query in IS_IN_DB have more than one table?
>> >
>> > > And how the fields of these tables be referenced in the format, to be
>> > > shown in the dropbox ?
>> >
>> > > Thanks in advance.
>> >
>> > > Ashraf
>>
>
>


[web2py] Re: can the query in IS_IN_DB have more than one table?

2012-02-21 Thread Ashraf Mansour
I will try both and i will let you know.

On Feb 22, 12:27 am, Richard Vézina 
wrote:
> On Tue, Feb 21, 2012 at 4:27 PM, Richard Vézina 
>
>
>
>
>
>
> > wrote:
> > Old
>
> > IS_IN_DB(helper_set,'table.id','%(field1)s (%(field2)s)',multiple=True) #
> > One table
>
> > Maybe this work but not sure :
>
> > IS_IN_DB(helper_set,'table.id',db.table2(db.table1.id).fieldTable2,multiple 
> > =True)
> > # 2 tables
>
> > Richard
>
> > On Tue, Feb 21, 2012 at 4:21 PM, Ashraf Mansour 
> > wrote:
>
> >> Thank you for the immediate reply.
>
> >> please rewrite the example using the old requires syntax.
>
> >> On Feb 21, 10:39 pm, Richard Vézina 
> >> wrote:
> >> > For represent I usually do :
>
> >> > lambda id: db.fktable1(id).represent_field # 1 table
> >> > lambda id: db.fktable2(db.fktable1(id).id).represent_field_table2 # 2
> >> table
>
> >> > You can maybe proceding the same way, but I am not sure... I am still
> >> using
> >> > old requires syntax...
>
> >> > Please report your experiment and how you solve it.
>
> >> > Richard
>
> >> > On Tue, Feb 21, 2012 at 1:57 PM, Ashraf Mansour  >> >wrote:
>
> >> > > Hi All,
>
> >> > > can the query in IS_IN_DB have more than one table?
>
> >> > > And how the fields of these tables be referenced in the format, to be
> >> > > shown in the dropbox ?
>
> >> > > Thanks in advance.
>
> >> > > Ashraf


[web2py] question about response.js

2012-02-21 Thread Richard
Hello,

Why I can't get initialization jquery plugin code to be execute by
view?

# Controller
response.js="""$(".chzn-select").chosen();"""

I already append(pluging file and css) like this :

response.files.append(URL('static','plugin_added/harvesthq-
chosen-ada808d/chosen/chosen.css'))
response.files.append(URL('static','plugin_added/harvesthq-
chosen-ada808d/chosen/chosen.jquery.js'))

I know those works...

In the book at in core chapter is says this :

response.js can contain Javascript Code. This code will be executed if
and only if the response is received by a web2py component as
discussed in Chapter 12.

In chapter 12, there is this example :

response.js = "jQuery('#%s').hide()" % request.cid

Thanks

Richard


Re: [web2py] question about response.js

2012-02-21 Thread Anthony
Is response.files being set by the component action, or by the page that 
contains the component? If the former, it won't work, as response.files is 
ignored when set in a component (response.files is used by layout.html to 
include CSS and JS files in the document head and so is ignored by 
components, which do not load a full page and therefore do not contain a 
head).

Anthony

On Tuesday, February 21, 2012 4:48:51 PM UTC-5, Richard wrote:
>
> Hello, 
>
> Why I can't get initialization jquery plugin code to be execute by 
> view? 
>
> # Controller 
> response.js="""$(".chzn-select").chosen();""" 
>
> I already append(pluging file and css) like this : 
>
> response.files.append(URL('static','plugin_added/harvesthq- 
> chosen-ada808d/chosen/chosen.css')) 
> response.files.append(URL('static','plugin_added/harvesthq- 
> chosen-ada808d/chosen/chosen.jquery.js')) 
>
> I know those works... 
>
> In the book at in core chapter is says this : 
>
> response.js can contain Javascript Code. This code will be executed if 
> and only if the response is received by a web2py component as 
> discussed in Chapter 12. 
>
> In chapter 12, there is this example : 
>
> response.js = "jQuery('#%s').hide()" % request.cid 
>
> Thanks 
>
> Richard 
>


[web2py] Re: can the query in IS_IN_DB have more than one table?

2012-02-21 Thread Ashraf Mansour
Unfortunately, did not work (both).

Do you know of any running example?
in other words, where is it explained, old style and new style?

On Feb 22, 12:33 am, Ashraf Mansour  wrote:
> I will try both and i will let you know.
>
> On Feb 22, 12:27 am, Richard Vézina 
> wrote:
>
>
>
>
>
>
>
> > On Tue, Feb 21, 2012 at 4:27 PM, Richard Vézina 
> > > wrote:
> > > Old
>
> > > IS_IN_DB(helper_set,'table.id','%(field1)s (%(field2)s)',multiple=True) #
> > > One table
>
> > > Maybe this work but not sure :
>
> > > IS_IN_DB(helper_set,'table.id',db.table2(db.table1.id).fieldTable2,multiple
> > >  =True)
> > > # 2 tables
>
> > > Richard
>
> > > On Tue, Feb 21, 2012 at 4:21 PM, Ashraf Mansour 
> > > wrote:
>
> > >> Thank you for the immediate reply.
>
> > >> please rewrite the example using the old requires syntax.
>
> > >> On Feb 21, 10:39 pm, Richard Vézina 
> > >> wrote:
> > >> > For represent I usually do :
>
> > >> > lambda id: db.fktable1(id).represent_field # 1 table
> > >> > lambda id: db.fktable2(db.fktable1(id).id).represent_field_table2 # 2
> > >> table
>
> > >> > You can maybe proceding the same way, but I am not sure... I am still
> > >> using
> > >> > old requires syntax...
>
> > >> > Please report your experiment and how you solve it.
>
> > >> > Richard
>
> > >> > On Tue, Feb 21, 2012 at 1:57 PM, Ashraf Mansour  > >> >wrote:
>
> > >> > > Hi All,
>
> > >> > > can the query in IS_IN_DB have more than one table?
>
> > >> > > And how the fields of these tables be referenced in the format, to be
> > >> > > shown in the dropbox ?
>
> > >> > > Thanks in advance.
>
> > >> > > Ashraf


Re: [web2py] web2py.com is dead

2012-02-21 Thread Bruce Wade
works for me

On Tue, Feb 21, 2012 at 12:36 PM, Vasile Ermicioi  wrote:

> it is down ...




-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.warplydesigned.com
http://www.fitnessfriendsfinder.com


Re: [web2py] Re: can the query in IS_IN_DB have more than one table?

2012-02-21 Thread Richard Vézina
Ok by new style I mean this syntax :

db.dog.owner.requires = IS_IN_DB(db,*db.person.id*,'%(name)s')


Instead of :

db.dog.owner.requires = IS_IN_DB(db,* 'person.id'*, '%(name)s')


In red...

So, I assume this is possible I am maybe wrong :

db.dog.owner.requires = IS_IN_DB(db,db.person.id, db.person(db.person.id
).name)

Then if that is possible, why not :

db.dog.owner.requires = IS_IN_DB(db,db.person.id,'%s' % db.person(
db.person.id).name db.othertable(db.person(db.person.id
).fk_to_other_table_id).field_other_table)

The way your table are related affect how you have to write the request...

db.table(id).field is nothing else then db(db.table.id ==
id).select(db.table.field).first().field

Richard

On Tue, Feb 21, 2012 at 5:00 PM, Ashraf Mansour wrote:

> Unfortunately, did not work (both).
>
> Do you know of any running example?
> in other words, where is it explained, old style and new style?
>
> On Feb 22, 12:33 am, Ashraf Mansour  wrote:
> > I will try both and i will let you know.
> >
> > On Feb 22, 12:27 am, Richard Vézina 
> > wrote:
> >
> >
> >
> >
> >
> >
> >
> > > On Tue, Feb 21, 2012 at 4:27 PM, Richard Vézina <
> ml.richard.vez...@gmail.com
> >
> > > > wrote:
> > > > Old
> >
> > > > IS_IN_DB(helper_set,'table.id','%(field1)s
> (%(field2)s)',multiple=True) #
> > > > One table
> >
> > > > Maybe this work but not sure :
> >
> > > > IS_IN_DB(helper_set,'table.id',db.table2(db.table1.id).fieldTable2,multiple
> =True)
> > > > # 2 tables
> >
> > > > Richard
> >
> > > > On Tue, Feb 21, 2012 at 4:21 PM, Ashraf Mansour <
> ad...@aqar-riyadh.com>wrote:
> >
> > > >> Thank you for the immediate reply.
> >
> > > >> please rewrite the example using the old requires syntax.
> >
> > > >> On Feb 21, 10:39 pm, Richard Vézina 
> > > >> wrote:
> > > >> > For represent I usually do :
> >
> > > >> > lambda id: db.fktable1(id).represent_field # 1 table
> > > >> > lambda id: db.fktable2(db.fktable1(id).id).represent_field_table2
> # 2
> > > >> table
> >
> > > >> > You can maybe proceding the same way, but I am not sure... I am
> still
> > > >> using
> > > >> > old requires syntax...
> >
> > > >> > Please report your experiment and how you solve it.
> >
> > > >> > Richard
> >
> > > >> > On Tue, Feb 21, 2012 at 1:57 PM, Ashraf Mansour <
> ad...@aqar-riyadh.com
> > > >> >wrote:
> >
> > > >> > > Hi All,
> >
> > > >> > > can the query in IS_IN_DB have more than one table?
> >
> > > >> > > And how the fields of these tables be referenced in the format,
> to be
> > > >> > > shown in the dropbox ?
> >
> > > >> > > Thanks in advance.
> >
> > > >> > > Ashraf
>


Re: [web2py] web2py.com is dead

2012-02-21 Thread Richard Vézina
Yeah it come back a couple of minutes ago.

Richard

On Tue, Feb 21, 2012 at 5:10 PM, Bruce Wade  wrote:

> works for me
>
> On Tue, Feb 21, 2012 at 12:36 PM, Vasile Ermicioi wrote:
>
>> it is down ...
>
>
>
>
> --
> --
> Regards,
> Bruce Wade
> http://ca.linkedin.com/in/brucelwade
> http://www.wadecybertech.com
> http://www.warplydesigned.com
> http://www.fitnessfriendsfinder.com
>


[web2py] Re: web2py.com is dead

2012-02-21 Thread Massimo Di Pierro
It was not dead but slow. I think a network problem. Now seems
resolved.

On Feb 21, 4:22 pm, Richard Vézina 
wrote:
> Yeah it come back a couple of minutes ago.
>
> Richard
>
>
>
>
>
>
>
> On Tue, Feb 21, 2012 at 5:10 PM, Bruce Wade  wrote:
> > works for me
>
> > On Tue, Feb 21, 2012 at 12:36 PM, Vasile Ermicioi wrote:
>
> >> it is down ...
>
> > --
> > --
> > Regards,
> > Bruce Wade
> >http://ca.linkedin.com/in/brucelwade
> >http://www.wadecybertech.com
> >http://www.warplydesigned.com
> >http://www.fitnessfriendsfinder.com


Re: [web2py] question about response.js

2012-02-21 Thread Richard Vézina
Ok, understand that, but is the response.js should allow me to insert this
in my view :

 $(".chzn-select").chosen(); 

Is there a way to insert a script into a view from controller... It may be
consider script injection I don't know...

Richard

On Tue, Feb 21, 2012 at 4:59 PM, Anthony  wrote:

> Is response.files being set by the component action, or by the page that
> contains the component? If the former, it won't work, as response.files is
> ignored when set in a component (response.files is used by layout.html to
> include CSS and JS files in the document head and so is ignored by
> components, which do not load a full page and therefore do not contain a
> head).
>
> Anthony
>
>
> On Tuesday, February 21, 2012 4:48:51 PM UTC-5, Richard wrote:
>>
>> Hello,
>>
>> Why I can't get initialization jquery plugin code to be execute by
>> view?
>>
>> # Controller
>> response.js="""$(".chzn-**select").chosen();"""
>>
>> I already append(pluging file and css) like this :
>>
>> response.files.append(URL('**static','plugin_added/**harvesthq-
>> chosen-ada808d/chosen/chosen.**css'))
>> response.files.append(URL('**static','plugin_added/**harvesthq-
>> chosen-ada808d/chosen/chosen.**jquery.js'))
>>
>> I know those works...
>>
>> In the book at in core chapter is says this :
>>
>> response.js can contain Javascript Code. This code will be executed if
>> and only if the response is received by a web2py component as
>> discussed in Chapter 12.
>>
>> In chapter 12, there is this example :
>>
>> response.js = "jQuery('#%s').hide()" % request.cid
>>
>> Thanks
>>
>> Richard
>>
>


Re: [web2py] Re: web2py.com is dead

2012-02-21 Thread Bruce Wade
Curious who are you hosting web2py with? The server seems to go down quite
often.


On Tue, Feb 21, 2012 at 2:24 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> It was not dead but slow. I think a network problem. Now seems
> resolved.
>
> On Feb 21, 4:22 pm, Richard Vézina 
> wrote:
> > Yeah it come back a couple of minutes ago.
> >
> > Richard
> >
> >
> >
> >
> >
> >
> >
> > On Tue, Feb 21, 2012 at 5:10 PM, Bruce Wade 
> wrote:
> > > works for me
> >
> > > On Tue, Feb 21, 2012 at 12:36 PM, Vasile Ermicioi  >wrote:
> >
> > >> it is down ...
> >
> > > --
> > > --
> > > Regards,
> > > Bruce Wade
> > >http://ca.linkedin.com/in/brucelwade
> > >http://www.wadecybertech.com
> > >http://www.warplydesigned.com
> > >http://www.fitnessfriendsfinder.com
>



-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.warplydesigned.com
http://www.fitnessfriendsfinder.com


[web2py] Re: new feature in trunk...

2012-02-21 Thread Massimo Di Pierro
yes. :-)

On Feb 21, 2:30 pm, Anthony  wrote:
> Cool. Shouldn't:
>
> filename = os.path.join(base, '/'.join(current.request.args))
>
> be:
>
> filename = os.path.join(base, os.path.sep.join(current.request.args))
>
> or maybe just:
>
> filename = os.path.join(base, *current.request.args)
>
> Anthony
>
>
>
>
>
>
>
> On Tuesday, February 21, 2012 2:57:43 PM UTC-5, Massimo Di Pierro wrote:
>
> > not sure if it should stay and for sure it can be improved. I use it a
> > lot.
>
> > def index():
> >      import os
> >      from gluon.tools import Expose
> >      return dict(expose=Expose(os.path.join(request.folder,'static')))


Re: [web2py] Re: can the query in IS_IN_DB have more than one table?

2012-02-21 Thread Richard Vézina
Maybe reading IS_IN_DB doc could helps...

Richard

On Tue, Feb 21, 2012 at 5:22 PM, Richard Vézina  wrote:

> Ok by new style I mean this syntax :
>
> db.dog.owner.requires = IS_IN_DB(db,*db.person.id*,'%(name)s')
>
>
> Instead of :
>
> db.dog.owner.requires = IS_IN_DB(db,* 'person.id'*, '%(name)s')
>
>
> In red...
>
> So, I assume this is possible I am maybe wrong :
>
> db.dog.owner.requires = IS_IN_DB(db,db.person.id, db.person(db.person.id
> ).name)
>
> Then if that is possible, why not :
>
> db.dog.owner.requires = IS_IN_DB(db,db.person.id,'%s' % db.person(
> db.person.id).name db.othertable(db.person(db.person.id
> ).fk_to_other_table_id).field_other_table)
>
> The way your table are related affect how you have to write the request...
>
> db.table(id).field is nothing else then db(db.table.id ==
> id).select(db.table.field).first().field
>
> Richard
>
> On Tue, Feb 21, 2012 at 5:00 PM, Ashraf Mansour wrote:
>
>> Unfortunately, did not work (both).
>>
>> Do you know of any running example?
>> in other words, where is it explained, old style and new style?
>>
>> On Feb 22, 12:33 am, Ashraf Mansour  wrote:
>> > I will try both and i will let you know.
>> >
>> > On Feb 22, 12:27 am, Richard Vézina 
>> > wrote:
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > > On Tue, Feb 21, 2012 at 4:27 PM, Richard Vézina <
>> ml.richard.vez...@gmail.com
>> >
>> > > > wrote:
>> > > > Old
>> >
>> > > > IS_IN_DB(helper_set,'table.id','%(field1)s
>> (%(field2)s)',multiple=True) #
>> > > > One table
>> >
>> > > > Maybe this work but not sure :
>> >
>> > > > IS_IN_DB(helper_set,'table.id',db.table2(db.table1.id).fieldTable2,multiple
>> =True)
>> > > > # 2 tables
>> >
>> > > > Richard
>> >
>> > > > On Tue, Feb 21, 2012 at 4:21 PM, Ashraf Mansour <
>> ad...@aqar-riyadh.com>wrote:
>> >
>> > > >> Thank you for the immediate reply.
>> >
>> > > >> please rewrite the example using the old requires syntax.
>> >
>> > > >> On Feb 21, 10:39 pm, Richard Vézina 
>> > > >> wrote:
>> > > >> > For represent I usually do :
>> >
>> > > >> > lambda id: db.fktable1(id).represent_field # 1 table
>> > > >> > lambda id:
>> db.fktable2(db.fktable1(id).id).represent_field_table2 # 2
>> > > >> table
>> >
>> > > >> > You can maybe proceding the same way, but I am not sure... I am
>> still
>> > > >> using
>> > > >> > old requires syntax...
>> >
>> > > >> > Please report your experiment and how you solve it.
>> >
>> > > >> > Richard
>> >
>> > > >> > On Tue, Feb 21, 2012 at 1:57 PM, Ashraf Mansour <
>> ad...@aqar-riyadh.com
>> > > >> >wrote:
>> >
>> > > >> > > Hi All,
>> >
>> > > >> > > can the query in IS_IN_DB have more than one table?
>> >
>> > > >> > > And how the fields of these tables be referenced in the
>> format, to be
>> > > >> > > shown in the dropbox ?
>> >
>> > > >> > > Thanks in advance.
>> >
>> > > >> > > Ashraf
>>
>
>


[web2py] Re: what triggers a db migration

2012-02-21 Thread Massimo Di Pierro
You are right. No database introspection.

On Feb 21, 3:11 pm, Fred  wrote:
> [Replying to old message; I'm way behind]
>
> On Jan 15, 1:21 am, pbreit  wrote:
>
> > I think web2py compares the .table files to the
> > database to figure out what needs to be migrated.
>
> Is this correct?  Everything I've seen suggests that web2py compares
> the .table files to the model files (models/*.py) to determine what
> has changed and therefore needs migration.  I have not seen any sign
> that web2py does introspection on the database itself.


Re: [web2py] question about response.js

2012-02-21 Thread Richard Vézina
I am sure I can just put it into a file and use response.files(URL(tofile))

It just seems to me overkill to use a file for that...

Richard

On Tue, Feb 21, 2012 at 5:25 PM, Richard Vézina  wrote:

> Ok, understand that, but is the response.js should allow me to insert this
> in my view :
>
>  $(".chzn-select").chosen(); 
>
> Is there a way to insert a script into a view from controller... It may be
> consider script injection I don't know...
>
> Richard
>
>
> On Tue, Feb 21, 2012 at 4:59 PM, Anthony  wrote:
>
>> Is response.files being set by the component action, or by the page that
>> contains the component? If the former, it won't work, as response.files is
>> ignored when set in a component (response.files is used by layout.html to
>> include CSS and JS files in the document head and so is ignored by
>> components, which do not load a full page and therefore do not contain a
>> head).
>>
>> Anthony
>>
>>
>> On Tuesday, February 21, 2012 4:48:51 PM UTC-5, Richard wrote:
>>>
>>> Hello,
>>>
>>> Why I can't get initialization jquery plugin code to be execute by
>>> view?
>>>
>>> # Controller
>>> response.js="""$(".chzn-**select").chosen();"""
>>>
>>> I already append(pluging file and css) like this :
>>>
>>> response.files.append(URL('**static','plugin_added/**harvesthq-
>>> chosen-ada808d/chosen/chosen.**css'))
>>> response.files.append(URL('**static','plugin_added/**harvesthq-
>>> chosen-ada808d/chosen/chosen.**jquery.js'))
>>>
>>> I know those works...
>>>
>>> In the book at in core chapter is says this :
>>>
>>> response.js can contain Javascript Code. This code will be executed if
>>> and only if the response is received by a web2py component as
>>> discussed in Chapter 12.
>>>
>>> In chapter 12, there is this example :
>>>
>>> response.js = "jQuery('#%s').hide()" % request.cid
>>>
>>> Thanks
>>>
>>> Richard
>>>
>>
>


[web2py] Re: book says auth.archive saves old record but it actually saves the new one

2012-02-21 Thread Massimo Di Pierro
There was an accidental change of behavior. You are the first to
notice that. You have the option to do one or the other. The issue is
what should be default of archive_current.

what book edition are you looking at?

On Feb 21, 3:14 pm, simon  wrote:
> The book says that auth.archive "stores a copy of the record (as it
> was before the update)". However with SQLFORM it appears to store a
> copy of the record after the update unless you do workaround (from
> Anthony in previous post):
>
> if form.process(...onsuccess=lambda archive: auth.archive(form,
> archive_current=False))
>
> Seems to me the book version is more intuitive.


[web2py] Re: web2py.com is dead

2012-02-21 Thread Massimo Di Pierro
I use VPS.net.

I really like their interface and they do respond to emails. They do
have problems but not sure 100% this problem is their fault. Most of
the problems I had with them were with their Atlanta data center (I
would not recommend) but the Chicago one (where web2py.com is) had
good service.

Massimo

On Feb 21, 4:25 pm, Bruce Wade  wrote:
> Curious who are you hosting web2py with? The server seems to go down quite
> often.
>
> On Tue, Feb 21, 2012 at 2:24 PM, Massimo Di Pierro <
>
>
>
>
>
>
>
>
>
> massimo.dipie...@gmail.com> wrote:
> > It was not dead but slow. I think a network problem. Now seems
> > resolved.
>
> > On Feb 21, 4:22 pm, Richard Vézina 
> > wrote:
> > > Yeah it come back a couple of minutes ago.
>
> > > Richard
>
> > > On Tue, Feb 21, 2012 at 5:10 PM, Bruce Wade 
> > wrote:
> > > > works for me
>
> > > > On Tue, Feb 21, 2012 at 12:36 PM, Vasile Ermicioi  > >wrote:
>
> > > >> it is down ...
>
> > > > --
> > > > --
> > > > Regards,
> > > > Bruce Wade
> > > >http://ca.linkedin.com/in/brucelwade
> > > >http://www.wadecybertech.com
> > > >http://www.warplydesigned.com
> > > >http://www.fitnessfriendsfinder.com
>
> --
> --
> Regards,
> Bruce 
> Wadehttp://ca.linkedin.com/in/brucelwadehttp://www.wadecybertech.comhttp://www.warplydesigned.comhttp://www.fitnessfriendsfinder.com


Re: [web2py] question about response.js

2012-02-21 Thread Anthony

>
> Ok, understand that, but is the response.js should allow me to insert this 
> in my view :
>
>  $(".chzn-select").chosen(); 
>

response.js does not insert a script tag into the page. Instead, the 
javascript function that makes the ajax call to load the component reads 
the response.js code from a special response header and eval's the code.
 

>
> Is there a way to insert a script into a view from controller... It may be 
> consider script injection I don't know...
>

If it's a web2py component, why not just include the above script element 
in the component's view?

Anthony



Re: [web2py] question about response.js

2012-02-21 Thread Richard Vézina
I try to bring back in controller initialization for jquery plugins because
I am not using them everywhere most of the time and also because sometimes
I initialize them differently in particular Datatables... Also, when I
change version of the plugin I found my self to always forgot a views that
contains a plugin... So I have little fix to do... I would avoid or
minimize those little issue and I thought that bring the initalization
script in controller where I spend most of my time could be a good move...

Richard

On Tue, Feb 21, 2012 at 5:35 PM, Anthony  wrote:

> Ok, understand that, but is the response.js should allow me to insert this
>> in my view :
>>
>>  $(".chzn-select").chosen(); 
>>
>
> response.js does not insert a script tag into the page. Instead, the
> javascript function that makes the ajax call to load the component reads
> the response.js code from a special response header and eval's the code.
>
>
>>
>> Is there a way to insert a script into a view from controller... It may
>> be consider script injection I don't know...
>>
>
> If it's a web2py component, why not just include the above script element
> in the component's view?
>
> Anthony
>
>


[web2py] Setting form method in web2py

2012-02-21 Thread Yarin
Is there a proper way to set the form method in web2py, or is it done
by FORM( _method = "POST")? Is there way to have all forms globally
use POST instead of GET?


[web2py] Understanding web2py coming from a PHP background

2012-02-21 Thread Jean M.
Hello,

I am a PHP developer interested in understanding the fundamentals of web2py 
framework and after reading the book and the documentation, I have some 
questions which I would very much appreciate to have answered.

1) Why (or "is") a VPS is necessary to host web2py Python web-apps? Can it 
not run under any Linux shared web-host which has python installed?

2) Is web2py restrictive in any way? How broad is the freedom to define 
custom routes, naming controllers, models and views? Can this happen 
without sharing the same name?

3) What is web2py approach to configuration, settings and programming? CoC? 
What do you think about it?

4) Is it possible to get web2py like PHP frameworks without installations? 
Do an unzip and have the folder structure to develop on without admin 
interfaces and such?

5) What would be deemed as good read for people from PHP background to 
understand web2py's ways?

Thank you


[web2py] Re: book says auth.archive saves old record but it actually saves the new one

2012-02-21 Thread simon
4th edition current online version:

http://web2py.com/books/default/chapter/29/7?search=archive

Also there is no mention of archive_current. I found that in a post on
this forum

http://groups.google.com/group/web2py/browse_thread/thread/f4e37fe9185c7c4c/ea252ad81709d67e?lnk=gst&q=archive_current#ea252ad81709d67e

On Feb 21, 10:30 pm, Massimo Di Pierro 
wrote:
> There was an accidental change of behavior. You are the first to
> notice that. You have the option to do one or the other. The issue is
> what should be default of archive_current.
>
> what book edition are you looking at?
>
> On Feb 21, 3:14 pm, simon  wrote:
>
>
>
>
>
>
>
> > The book says that auth.archive "stores a copy of the record (as it
> > was before the update)". However with SQLFORM it appears to store a
> > copy of the record after the update unless you do workaround (from
> > Anthony in previous post):
>
> > if form.process(...onsuccess=lambda archive: auth.archive(form,
> > archive_current=False))
>
> > Seems to me the book version is more intuitive.


[web2py] Automatically reload custom modules?

2012-02-21 Thread Bruce Wade
Hi,

I am starting to find this situation a little annoying. I have a package at
the same level as gluon, adviewerAPI. Which contains several modules that I
will be using across all my applications. (Main website, customer service
app etc...)

Now the issue is whenever I make a change to any of the modules, I need to
stop and restart the development server. Is there a setting to for auto
reload when a module changes?

-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.warplydesigned.com
http://www.fitnessfriendsfinder.com


[web2py] Re: Setting form method in web2py

2012-02-21 Thread Massimo Di Pierro
al forms already default to POST.

FORM(_method='POST") and/or SQLFORM(_method="POST") is default.

On Feb 21, 4:51 pm, Yarin  wrote:
> Is there a proper way to set the form method in web2py, or is it done
> by FORM( _method = "POST")? Is there way to have all forms globally
> use POST instead of GET?


[web2py] Re: book says auth.archive saves old record but it actually saves the new one

2012-02-21 Thread Massimo Di Pierro
Thanks. If there is a disconnect between this and the book we can fix
it in the next version. Please open a ticket about this.

On Feb 21, 5:15 pm, simon  wrote:
> 4th edition current online version:
>
> http://web2py.com/books/default/chapter/29/7?search=archive
>
> Also there is no mention of archive_current. I found that in a post on
> this forum
>
> http://groups.google.com/group/web2py/browse_thread/thread/f4e37fe918...
>
> On Feb 21, 10:30 pm, Massimo Di Pierro 
> wrote:
>
>
>
>
>
>
>
> > There was an accidental change of behavior. You are the first to
> > notice that. You have the option to do one or the other. The issue is
> > what should be default of archive_current.
>
> > what book edition are you looking at?
>
> > On Feb 21, 3:14 pm, simon  wrote:
>
> > > The book says that auth.archive "stores a copy of the record (as it
> > > was before the update)". However with SQLFORM it appears to store a
> > > copy of the record after the update unless you do workaround (from
> > > Anthony in previous post):
>
> > > if form.process(...onsuccess=lambda archive: auth.archive(form,
> > > archive_current=False))
>
> > > Seems to me the book version is more intuitive.


[web2py] Re: Automatically reload custom modules?

2012-02-21 Thread Massimo Di Pierro
from gluon.custom_import import track_changes; track_changes(True)

On Feb 21, 5:18 pm, Bruce Wade  wrote:
> Hi,
>
> I am starting to find this situation a little annoying. I have a package at
> the same level as gluon, adviewerAPI. Which contains several modules that I
> will be using across all my applications. (Main website, customer service
> app etc...)
>
> Now the issue is whenever I make a change to any of the modules, I need to
> stop and restart the development server. Is there a setting to for auto
> reload when a module changes?
>
> --
> --
> Regards,
> Bruce 
> Wadehttp://ca.linkedin.com/in/brucelwadehttp://www.wadecybertech.comhttp://www.warplydesigned.comhttp://www.fitnessfriendsfinder.com


[web2py] Re: Understanding web2py coming from a PHP background

2012-02-21 Thread Massimo Di Pierro


On Feb 21, 4:33 pm, "Jean M."  wrote:
> Hello,
>
> I am a PHP developer interested in understanding the fundamentals of web2py
> framework and after reading the book and the documentation, I have some
> questions which I would very much appreciate to have answered.
>
> 1) Why (or "is") a VPS is necessary to host web2py Python web-apps? Can it
> not run under any Linux shared web-host which has python installed?

web2py can run under shared hosts.
The only issue is that each shared hosting is a little different
therefore how depends on details.
What web server do they provide? Do they provide mod_wsgi? Do they
assign you a port? Do they allow long running processes?
If they allow long running processes I'd suggest running web2py under
your own account and configure their web server to act as proxy.

> 2) Is web2py restrictive in any way? How broad is the freedom to define
> custom routes, naming controllers, models and views? Can this happen
> without sharing the same name?

Not sure I understand the question. web2py does not impose any
restriction on the number of apps. The models and controller must be
valid python file names but you can use routes to map them into
arbitrary URI paths.

>
> 3) What is web2py approach to configuration, settings and programming? CoC?
> What do you think about it?

What is CoC? Web2py has no configuration files except for the optional
routes.py You use it when you do not want to use the default URLs.

> 4) Is it possible to get web2py like PHP frameworks without installations?

Web2py does not require installation. PHP does. Python does. Most
system come with PHP and Python pre-installed but no web2py. You do
not need to install it, you just need to download it somewhere. No
need for root permission.

> Do an unzip and have the folder structure to develop on without admin
> interfaces and such?

Again, I do not understanding the question. Anyway on any shared host
you can do:

wget http://web2py.com/examples/static/web2py_src.zip
unzip web2py_src.zip
cd web2py
mkdir applications/myapp
cp -r applications/welcome/* applications/myapp/
python web2py.py -a somepassword -i 0.0.0.0 -p  &
open  http://yourhostname/myapp

> 5) What would be deemed as good read for people from PHP background to
> understand web2py's ways?

try the above commands. Read chapter 3 of the book. Ask questions
here.

> Thank you


[web2py] Re: Understanding web2py coming from a PHP background

2012-02-21 Thread pbreit
1) Python hosting is much harder than PHP hosting. While hosts that support 
Python should be able to support Web2py, that is not always the case 
because they don't support one of the web server communication mechanisms 
such as mod_wsgi or fastcgi. If the host supports Django apps, it should be 
possible to get Web2py to work.

2) It's pretty flexible but there are some restrictions enforced by Web2py, 
Python and/or the database. Routing is pretty flexible.

3) There isn't much of a concept of config files or anything. The optional 
routes.py file is sort of like a config file for routes. You can place 
config-like settings in models files as well. I'd say CoC has an edge.

4) Once again, setting up Python apps is harder than PHP. You don't just 
drop files into a folder. However, once you have Web2py up and running, 
then you can just drop a bundle of web2py app code in the applications 
directory (possibly requiring a server restart).

5) The Web2py book is the best I've seen. You can get started quickly by 
just downloading the Windows or Mac package and running it from your own 
computer. Later you can figure out how to deploy to a remote web server.



Re: [web2py] Re: Automatically reload custom modules?

2012-02-21 Thread Bruce Wade
Thank you that makes live much easier.

On Tue, Feb 21, 2012 at 4:14 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> from gluon.custom_import import track_changes; track_changes(True)
>
> On Feb 21, 5:18 pm, Bruce Wade  wrote:
> > Hi,
> >
> > I am starting to find this situation a little annoying. I have a package
> at
> > the same level as gluon, adviewerAPI. Which contains several modules
> that I
> > will be using across all my applications. (Main website, customer service
> > app etc...)
> >
> > Now the issue is whenever I make a change to any of the modules, I need
> to
> > stop and restart the development server. Is there a setting to for auto
> > reload when a module changes?
> >
> > --
> > --
> > Regards,
> > Bruce Wadehttp://
> ca.linkedin.com/in/brucelwadehttp://www.wadecybertech.comhttp://www.warplydesigned.comhttp://www.fitnessfriendsfinder.com
>



-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.warplydesigned.com
http://www.fitnessfriendsfinder.com


[web2py] Re: How to optimize the output typography of blocks in web2py views?

2012-02-21 Thread chinakr
I get the point, it really works, thx!

On 2月21日, 下午9时45分, Anthony  wrote:
> In the case of blocks, I think Wikus is suggesting:
>
> {{block head}}[your block markup]{{
>
> end}}
>
> But you can also do:
>
> {{block head}}[your block markup...
> ...more block markup]{{end}}
>
> Anthony
>
>
>
>
>
>
>
> On Tuesday, February 21, 2012 8:13:11 AM UTC-5, chinakr wrote:
>
> > Sorry, but I am puzzled with your suggestion @_@
>
> > On 2月21日, 下午7时09分, Wikus van de Merwe 
> > wrote:
> > > You can do tricks like that, but it does not have the best readability:
> > > {{ for i in range(10):}}  text {{=i}} text  {{
>
> > > pass }}


[web2py] Re: Web2Py/Google App Engine Apps - How to get ID or key after Inserting New Rec

2012-02-21 Thread howesc
bulk insert fails?  or bulk insert does not return a list of IDs?

i assert that bulk insert does indeed work (at least for me 1.99.4), but 
that it does not return a list of IDs.

google provides no way to see the IDs it has assigned in a bulk insert 
unless you have specified the IDs yourself (which i don't think that the 
web2py DAL supports at this time).  i could be wrong - if you see in the 
google docs that they do return a list of IDs i'm happy to help with a 
patch!

cfh


[web2py] Re: BELONGS is not supported on GAE?

2012-02-21 Thread howesc
what version of web2py are you using?  belongs was not supported on ID at 
one point, but we fixed that i believe

anyhow, i would write the queries for GAE like:

# Construct a query to fetch all the mootid's from the group 
mootGroup = db(db.moot_groups.gid==groupid).select()
###NOTE: you may only have up to 30 items in a belongs (IN) statement on 
GAE, you might need to split the following into multiple queries
 
# Gets moots only if the moot ID exists in the Group query 
moots = db((db.moots.url==request.get_vars.url)&(db.moots.id.belongs([r.id 
for r in mootGroup]))).select(db.moots.ALL) 

good luck, and ask questions - i'm running several apps of various sizes on 
GAE so hopefully myself and others can guide you through the GAE pitfalls!

cfh


[web2py] support for bound (instance) methods for represent

2012-02-21 Thread Carlos
Hi Massimo,

Can we please add support for bound (instance) methods for represent?.

I propose to add the following line (immediately after assigning "n" in 
"represent" function at sqlhtml.py):

   if getattr(f, 'im_self', None): n -= 1

At aprox. line # 41.

Alternatively you can check n==1 (for one arg calls) with an else clause 
for two arg calls ... and removing the current else (RuntimeError).

Thanks!,

   Carlos



[web2py] Re: support for bound (instance) methods for represent

2012-02-21 Thread Massimo Di Pierro
I believe represent cal already be methods. Can you please provide an
example of what you need to do and the behavior you expect?

massimo

On Feb 21, 7:07 pm, Carlos  wrote:
> Hi Massimo,
>
> Can we please add support for bound (instance) methods for represent?.
>
> I propose to add the following line (immediately after assigning "n" in
> "represent" function at sqlhtml.py):
>
>    if getattr(f, 'im_self', None): n -= 1
>
> At aprox. line # 41.
>
> Alternatively you can check n==1 (for one arg calls) with an else clause
> for two arg calls ... and removing the current else (RuntimeError).
>
> Thanks!,
>
>    Carlos


[web2py] Re: Understanding web2py coming from a PHP background

2012-02-21 Thread Jean M.
Thank you, both of you. I am really struggling to understanding the very 
basics of how Python Web-apps work. Your answers do help.

So basically, a python app (running on web2py or not) is actually an app, 
and it runs on Python interpreter (just like Java apps).
So they also contain, naturally, the web server or a web server interface 
to respond to requests.

One more question:

PHP allows writing stupid code. Because even if a part of the code starts 
performing an infinite root or somthing, the process in the end dies 
without affecting other connections or parts of the web-app. 

How does this work with Python? What happens if a part of the app, during 
production, goes crazy? Will the web2py app crash? Will it re-launch it 
self automatically or is it necessary to use something like "forever"?

Thanks again!


[web2py] Re: Understanding web2py coming from a PHP background

2012-02-21 Thread Anthony

>
> 3) What is web2py approach to configuration, settings and programming?
>

As noted, the only real configuration file is routes.py, which is optional 
and used for routing (URL rewrite and routes on error). In addition to the 
root routes.py file in the /web2py folder, you can also have app-specific 
routes.py files. Also, note that model files are executed on every request 
(unless they are in subfolders to be executed conditionally based on the 
controller and/or function), so app-specific configuration-like settings 
are sometimes put in a model file (model files are executed alphabetically, 
so if you want some configuration settings to be set before any other app 
code runs, you might put them in a model file named 0_config.py).
 

> CoC?
>

Probably more so than most Python frameworks, web2py does adopt a strong 
"convention over configuration" philosophy (this is in contrast to the 
"explicit is better than implicit" Python mantra followed by most other 
frameworks). See http://web2py.com/books/default/chapter/29/1#Principles. 
In web2py, everything has sane defaults but can be customized as needed. 
That's why the "hello world" is as simple as:

/myapp/controllers/default.py:

def index():
return dict(message='Hello World')


4) Is it possible to get web2py like PHP frameworks without installations? 
> Do an unzip and have the folder structure to develop on without admin 
> interfaces and such?
>

Using the "admin" interface is entirely optional. You can develop using any 
text editor or IDE (and, in fact, you can access most of the "admin" 
functionality programmatically via the gluon.admin module).
 

> 5) What would be deemed as good read for people from PHP background to 
> understand web2py's ways?
>

A little old, but you can check 
out http://www.web2py.com/AlterEgo/default/show/106. That's really 
comparing web2py to plain PHP, not PHP MVC frameworks. Compared with PHP 
MVC frameworks, the biggest difference is probably just the language. You 
should also get a good idea about how web2py works by going through the 
Introduction and Overview chapters of the book, as well 
as http://web2py.com/books/default/chapter/29/4#Workflow 
and http://web2py.com/books/default/chapter/29/4#Dispatching.

Anthony
 

>
> Thank you
>


[web2py] my IE 6.0, the layout of four columns

2012-02-21 Thread web2py_lover

in my IE 6.0, the layout of
http://web2py.com/examples/default/index  shows ok
but mine (Current (1.99.4 stable))
http://127.0.0.1:8000/examplesshows not ok,

I think it is the problem of following, am I right?

I can't find the definition of four columns in any css file,


  Right Sidebar

  

 


[web2py] Re: Web2Py/Google App Engine Apps - How to get ID or key after Inserting New Rec

2012-02-21 Thread BrendanC
howesc,

My bad - you are correct. I retested bulk insert on GAE and it does work. I 
made a mistake with my syntax:

Instead of:

imgids = db.imagetag.bulk_insert(ddlist)

I was using:

   imgids = db.imagetag.bulk_insert(**ddlist)

Complete example:

#Test example - Build a list of dicts to insert
ddlist = []
d1 = {'image_id':10, 'tag_id':101 }
d2 = {'image_id':10, 'tag_id':102 }
d3 = {'image_id':11, 'tag_id':333 }
ddlist.append(d1)
ddlist.append(d2)
ddlist.append(d3)
imgids = db.imagetag.bulk_insert(ddlist)

   Unfortunately as you stated earlier, this inserted id's are not returned 
- just a True/False indicator.


[web2py] Re: new feature in trunk...

2012-02-21 Thread Brian M
So if my quick reading of the code is correct this will "expose" a directory 
listing? Am I close? (Some doc strings would be nice ;-) )


[web2py] request.user_agent() dumping

2012-02-21 Thread weheh
I'm trying to detect the browser being used to access my web2py app.
The literature seems to recommend reading request.env.http_user_agent.
But the results are a little confusing, so I'm trying
request.user_agent(), which uses "gluon/contrib/
user_agent_parser.py" (as per the doc). This throws the following
ticket:

Traceback (most recent call last):
  File "N:\web2py\gluon\main.py", line 518, in wsgibase
session._try_store_on_disk(request, response)
  File "N:\web2py\gluon\globals.py", line 528, in _try_store_on_disk
cPickle.dump(dict(self), response.session_file)
PicklingError: Can't pickle : it's not the
same object as storage.Storage

I'm on web2py v1.99.2

Thanks.


[web2py] GAE and Web2Py - Current Issues and some thoughts on Best Practices?

2012-02-21 Thread BrendanC
Just started testing a small GAE test app with Web2py. I worked with the 
App Engine a few years ago, but have not looked at it for a while.  I know 
there has been some earlier discussion here re proposed DAL changes to 
enhance GAE support. Unfortunately the Web2Py GAE docs are a bit sparse and 
fragmented. It's no fun beating your head against a brick wall trying to do 
something the App Engine is not designed to do (e.g. lots of qns keep 
coming up about joins, many to many  mappings which need to be rethought in 
GAE apps). AFAIK GAE support in Web2Py really is a moving target.

I think we could use some supplementary docs here related to the GAE, 
together with some working examples so that people can see how familiar 
problems (joins) are implemented in an Web2py/GAE app. Perhaps a subsection 
of this forim or an alternative Web2py/GAE specific forum would be useful. 

There are a few on this forum who have done some GAE development with 
Web2py, and they have already figured out some of the issues and solutions. 
So far I am aware of several problems/issues - however this info needs to 
be managed and made available for others to refer to and update. For 
starters:
 
- Separate version of DAL for GAE - ??Big Issue -IMHO if I choose a nosql 
approach, I accept the pros and cons - db portability is highly overrated 
and is market speak for lowest common denominator )??
- Bypassing DAL and making native API calls - does it ever make sense?
- How to configure/run an interactive Web2Py/GAE app shell locally
- How to handle Many to Many  relationships (varioius alternatives) 
- Access to GAE key values (vs ID's)
- Access to GAE ID values of new records after bulk insert
- Where to find some GAE example code (here's one link 
http://code.google.com/p/publicradioroadtrip/, anyone got any others?
- Debugging GAE apps (fwiw -WingWare IDE Pro works and they document the 
process - see here: http://wingware.com/doc/howtos/google-app-engine

I don't have answers here - just suggesting that we provide a mechanism to 
inform users and share ideas/issues/ and examples.

Sorry if this is a bit of  a ramble, but I'd be curious to hear from other 
App Engine developers here..  

BrendanC



[web2py] web2py - Amazon Webservices Integration

2012-02-21 Thread Osama Khan
Hi,


Has anyone tried this tutorial?
http://aws.amazon.com/articles/3998?_encoding=UTF8&jiveRedirect=1

Is there something similar we can do with web2py?
*
Best,
Osama

*


  1   2   >