Re: [web2py] row.update_record()

2017-05-22 Thread Miguel Lopes
On Mon, May 22, 2017 at 4:35 PM, 'Annet' via web2py-users <
web2py@googlegroups.com> wrote:

> I have the following query and form:
>
> user = db.auth_user(vertexID=vertexID)
>
> form = SQLFORM.factory(db.auth_user, db.auth_dummy,
> extra_fields=extra_fields)
>
> If the form validates I want to update user with data I selected from
> other tables and
> with data from the form. I have the following code;
>
> user.update_record(field1=value1, field2=value2)
> user.update_record(**db.auth_user._filter_fields(form.vars))
>
> I wonder whteher there is a more elegant solution than calling
> user.update_record() twice
>
>
Yes. From the book:

"However, if you assign a value to form.vars.field, this value *will* be
part of the insert or update when the form is processed. "

form.vars is a gluon.storage.Storage object ... so you can use it (see:
http://web2py.readthedocs.io/en/latest/storage.html?highlight=gluon.storage.Storage).
Just do:

form.vars.field1 = value1
form.vars.field2 = value2
user.update_record(**db.auth_user._filter_fields(form.vars))

Miguel

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: how to update a digitally signed component via response.js?

2012-07-03 Thread Miguel Lopes
Tx you so much for the solution. This one was really holding me back.
Miguel

On Tue, Jul 3, 2012 at 3:27 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> There is more than one problem.
>
> 1) you can supply your own secret key but there is no need to. If the user
> is logged-in, the secret key is randomly generated once per session. That
> is more secure than having a global one
>
> 2) user_signature is a boolean, not a key
>
> 3) the signature in the url is not the key but the signature computed from
> the url and from the key.
>
> Your code should be (I have not tried it):
>
> def index():
> return dict()
>
> @auth.requires_login()
> def myform():
> form = SQLFORM.factory(Field('name', label='what\'s your name',
> requires=IS_NOT_EMPTY()))
> if form.process().accepted:
> if form.vars.name:
> session.name = form.vars.name + " ME"
> response.js ="web2py_component('%s', 'cname_list')" %
> URL('inter_component','name_list',user_signature=True)
> return form
>
> @auth.requires_signature()
> def name_list():
>
> if session.name == None:
> session.name = "0"
> else:
> session.name +=" 1"
> return "Name list component: %s" % session.name
>
> # the view index.html
> {{extend 'layout.html'}}
> {{=LOAD('inter_component', 'myform', ajax=True, target="cmy_form")}}
> {{=LOAD('inter_component', 'name_list', ajax=True, target='cname_list',
> user_signature=True)}}
>
>
>
>
> On Tuesday, 3 July 2012 06:49:56 UTC-5, miguel wrote:
>>
>> I just can't manage to make this work.
>> I'm trying to follow the book by supplying a hmac_key.
>> Here's the code:
>>
>> # controller inter_component.py
>>
>> HKEY='secret'   # later to be stored in uuid generated and stored in
>> session
>>
>> def index():
>> return dict(HKEY=HKEY)
>>
>> def myform():
>> form = SQLFORM.factory(Field('name', label='what\'s your name',
>> requires=IS_NOT_EMPTY()))
>> if form.process().accepted:
>> if form.vars.name:
>> session.name = form.vars.name + " ME"
>> response.js ="web2py_component('/test_**
>> signature/inter_component/**name_list?_signature=%s', 'cname_list')" %
>> HKEY
>> return form
>>
>> def name_list():
>> if not URL.verify(request, hmac_key=HKEY): raise HTTP(403)
>> if session.name == None:
>>session.name = "0"
>> else:
>> session.name +=" 1"
>> return "Name list component: %s" % session.name
>>
>> # the view index.html
>> {{extend 'layout.html'}}
>> {{=LOAD('inter_component', 'myform', ajax=True, target="cmy_form")}}
>> {{=LOAD('inter_component', 'name_list', ajax=True, target='cname_list',
>> user_signature=HKEY)}}
>>
>> Miguel
>>
>>
>> On Mon, Jul 2, 2012 at 11:41 AM, Miguel Lopes wrote:
>>
>>> I have a view index.html with two components - myform and namelist.
>>> The index action requires_login() and both myform and namelist actions
>>> requires_signature()
>>> This works as expected.
>>>
>>> The problem is that the update of namelist via response.js set in the
>>> myform action fails.
>>>
>>> I figure that since in myform response.js is set to:
>>>
>>> response.js = 
>>> "web2py_component('/test_**signature/inter_component/**name_list',
>>> 'cname_list')"
>>>
>>> This fails because the get var '_signature' that matches name_list is
>>> missing.
>>>
>>> If I'm correct how can one access the signature of other components in
>>> order to update the via the response.js mechanism?
>>> Otherwise, how to update a digitally signed component via response.js?
>>>
>>> TIA
>>> Miguel
>>>
>>>
>>


[web2py] Re: how to update a digitally signed component via response.js?

2012-07-03 Thread Miguel Lopes
I just can't manage to make this work.
I'm trying to follow the book by supplying a hmac_key.
Here's the code:

# controller inter_component.py

HKEY='secret'   # later to be stored in uuid generated and stored in session

def index():
return dict(HKEY=HKEY)

def myform():
form = SQLFORM.factory(Field('name', label='what\'s your name',
requires=IS_NOT_EMPTY()))
if form.process().accepted:
if form.vars.name:
session.name = form.vars.name + " ME"
response.js
="web2py_component('/test_signature/inter_component/name_list?_signature=%s',
'cname_list')" % HKEY
return form

def name_list():
if not URL.verify(request, hmac_key=HKEY): raise HTTP(403)
if session.name == None:
   session.name = "0"
else:
session.name +=" 1"
return "Name list component: %s" % session.name

# the view index.html
{{extend 'layout.html'}}
{{=LOAD('inter_component', 'myform', ajax=True, target="cmy_form")}}
{{=LOAD('inter_component', 'name_list', ajax=True, target='cname_list',
user_signature=HKEY)}}

Miguel


On Mon, Jul 2, 2012 at 11:41 AM, Miguel Lopes  wrote:

> I have a view index.html with two components - myform and namelist.
> The index action requires_login() and both myform and namelist actions
> requires_signature()
> This works as expected.
>
> The problem is that the update of namelist via response.js set in the
> myform action fails.
>
> I figure that since in myform response.js is set to:
>
> response.js =
> "web2py_component('/test_signature/inter_component/name_list',
> 'cname_list')"
>
> This fails because the get var '_signature' that matches name_list is
> missing.
>
> If I'm correct how can one access the signature of other components in
> order to update the via the response.js mechanism?
> Otherwise, how to update a digitally signed component via response.js?
>
> TIA
> Miguel
>
>


Re: [web2py] DAL : fill with zeroes a specific field before insert / update

2012-07-02 Thread Miguel Lopes
On Mon, Jul 2, 2012 at 2:08 PM, Santiago  wrote:

> Hello,
>
> I have a field defined as below :
>
> Field('id_indra', length=5, label=T('ID Indra'), notnull=False,
> requires=[REQUIRED, MAX_5, IS_MATCH(r'^[a-zA-Z0-9]{5}$')])
>
> Is it is possible to intercept all inserts / updates over this field and
> do a zfill() before the accion takes place? So, if the field is '5', they
> it would be completed with zeroes with a result of '5' before insert /
> update.
>
> Thanks in advance
>
> Regards,
> Santiago
>


A way to achieve this would be on form submission with the onvalidation
argument, such as:

def myaction:
def pad_indra(form):
form.vars.id_indra = form.vars.id_indra.zfill(5)

form = SQLFORM(...)
if form.process(onvalidation=pad_indra).accepted:
...

If you use this in multiple form you could move pad_indra to the
'controller' scope to share it.
Miguel
HTH


[web2py] how to update a digitally signed component via response.js

2012-07-02 Thread Miguel Lopes
I have a view index.html with two components - myform and namelist.
The index action requires_login() and both myform and namelist actions
requires_signature()
This works as expected.

The problem is that the update of namelist via response.js set in the
myform action fails.

I figure that since in myform response.js is set to:

response.js =
"web2py_component('/test_signature/inter_component/name_list',
'cname_list')"

This fails because the get var '_signature' that matches name_list is
missing.

If I'm correct how can one access the signature of other components in
order to update the via the response.js mechanism?
Otherwise, how to update a digitally signed component via response.js?

TIA
Miguel


Re: [web2py] Re: problem with encoding in javascript from the server

2012-03-27 Thread Miguel Lopes
Find it.

titles = "'"+titles.replace('|', "','")+"'"
with:
SCRIPT(" ... jQuery.prettyPhoto.open(**images=%(images)s,titles=[%(**
titles)s]);})" % dict(images=images, titles=titles), _language='javascript')

works! Tested on Firefox and Safari.

Though I've failed to find any references on this (there must be), the
problem seems to be Python string formatting. It seems that  when the value
of a dict is a list (haven't tested for other types such as dict and
tuple?), Python uses repr instead of str, so we end-up with a
representation! This does not happen if titles is a string. Note I'm using
Python 2.5.

Miguel



On Tue, Mar 27, 2012 at 6:46 PM, Derek  wrote:

> Check the meta tag - if it's UTF-8, that's most likely the issue.  You can
> try ISO-8859-1 and see if that works for you.
>
>
> On Tuesday, March 27, 2012 10:41:53 AM UTC-7, Derek wrote:
>>
>> What's the character set in your browser?
>>
>> On Tuesday, March 27, 2012 9:13:14 AM UTC-7, miguel wrote:
>>>
>>> This is not strictly a web2py issue. Though it is a problem that apps
>>> dealing with some character sets must deal with.
>>> I confess that the source of my problem is that I have been delaying
>>> reading-up on encoding and decoding far too long. But I'm pressed for time
>>> and I'm sure that this is a simple issue to many of you.
>>>
>>> Here's is it (slightly embarrassed):
>>>
>>> It works if I hardcode a string in a script helper:
>>>
>>> SCRIPT(" ... jQuery.prettyPhoto.open(**images=%(images)s,titles=['**olá',
>>> 'olé']);})" % dict(...images=images), _language='javascript')
>>>
>>> It also works if (getting titles from the db, where it is stored as
>>> "'olá','olé'" - note single quotes included):
>>>
>>> SCRIPT(" ... 
>>> jQuery.prettyPhoto.open(**images=%(images)s,titles=[%(**titles)]);})"
>>> % dict(images=images, titles=titles), _language='javascript')
>>>
>>> However, if I try to parse from the db (where titles is stored as
>>> "olá|olé", such as:
>>> titles = [title.strip() for title in titles.split('|')]
>>>
>>> The jQuery string is adequately adjusted to receive a list:
>>> SCRIPT(" ... jQuery.prettyPhoto.open(**images=%(images)s,titles=%(**
>>> titles));})" % dict(images=images, titles=titles),
>>> _language='javascript')
>>>
>>> All works but when rendered by the browser I do not get: Olá  instead I
>>> get: olá
>>> The same for Olé and olé
>>>
>>> My goal is to have a user supplied string, such as: olá|olé
>>>
>>> BTW this is a prettyPhoto widget I developed for plugin_wiki, which is
>>> awesome :-)
>>>
>>> Txs for the help,
>>> Miguel
>>>
>>


Re: [web2py] Re: problem with encoding in javascript from the server

2012-03-27 Thread Miguel Lopes
No dia 27 de Mar de 2012 17:46, "Derek"  escreveu:
>
> Check the meta tag - if it's UTF-8, that's most likely the issue.  You
can try ISO-8859-1 and see if that works for you.
>
Txs. Will also check that.


Re: [web2py] Re: problem with encoding in javascript from the server

2012-03-27 Thread Miguel Lopes
No dia 27 de Mar de 2012 17:41, "Derek"  escreveu:
>
> What's the character set in your browser?
>
I have safari set for default. But I don't think that's the problem,
because if I hardcode the string there is no problem.
I'm certainly missing something, but the culprit operation seems to be the
string parsing, not the browser rendering:

titles = [title.strip() for title in titles.split('|')]

Miguel


[web2py] Re: problem with encoding in javascript from the server

2012-03-27 Thread Miguel Lopes
No dia 27 de Mar de 2012 16:13, "Miguel Lopes" 
escreveu:
>
>
> BTW this is a prettyPhoto widget I developed for plugin_wiki, which is
awesome :-)
>

I mean plugin_wiki is awesome :-)
lol


[web2py] problem with encoding in javascript from the server

2012-03-27 Thread Miguel Lopes
This is not strictly a web2py issue. Though it is a problem that apps
dealing with some character sets must deal with.
I confess that the source of my problem is that I have been delaying
reading-up on encoding and decoding far too long. But I'm pressed for time
and I'm sure that this is a simple issue to many of you.

Here's is it (slightly embarrassed):

It works if I hardcode a string in a script helper:

SCRIPT(" ... jQuery.prettyPhoto.open(images=%(images)s,titles=['olá',
'olé']);})" % dict(...images=images), _language='javascript')

It also works if (getting titles from the db, where it is stored as
"'olá','olé'" - note single quotes included):

SCRIPT(" ...
jQuery.prettyPhoto.open(images=%(images)s,titles=[%(titles)]);})" %
dict(images=images, titles=titles), _language='javascript')

However, if I try to parse from the db (where titles is stored as "olá|olé",
such as:
titles = [title.strip() for title in titles.split('|')]

The jQuery string is adequately adjusted to receive a list:
SCRIPT(" ... jQuery.prettyPhoto.open(images=%(images)s,titles=%(titles));})"
% dict(images=images, titles=titles), _language='javascript')

All works but when rendered by the browser I do not get: Olá  instead I
get: olá
The same for Olé and olé

My goal is to have a user supplied string, such as: olá|olé

BTW this is a prettyPhoto widget I developed for plugin_wiki, which is
awesome :-)

Txs for the help,
Miguel


Re: [web2py] new web site

2011-11-09 Thread Miguel Lopes
Looks great!

It should be clear what the "Awarded the best..." is. Perhaps using

http://www.infoworld.com/sites/infoworld.com/files/imagecache/slideshow_slide/media/image/36SS-bossies-2011-web2py.jpg

or linking to InfoWorld.

Miguel


Re: [web2py] Re: web2ruby possible?

2011-10-13 Thread Miguel Lopes
what about D?

On Thu, Oct 13, 2011 at 4:49 AM, wwwgong  wrote:

> Vote for node.js
>
> On Sep 11, 5:40 pm, "dustin.b"  wrote:
> > 1+ vote for node.js ;)
> >
> > On 11 Sep., 21:14, David Marko  wrote:
> >
> >
> >
> > > Or to node.js :-)
>


Re: [web2py] return record from a query only shows field from one table

2011-07-28 Thread Miguel Lopes
Ok. One way is to use the represent attribute of db.requests.product field.
You can setup this in models after the table definition with:

db.requests.product.represent = lambda id: db.product(id).description

id is a parameter to lambda which takes the value of the current field value
(for product).
If you don't want to get "description" in place of "id" everytime you access
db.requests.product, you can make the assignment above in the controller
function. This way represent will only get set when that in calls to that
function.

details are at:
http://web2py.com/book/default/chapter/06#Record-Representation


2011/7/28 António Ramos 

> i want to select record from 2 tables.
> I have table requests that have a column product. This column is only the
> id of the product
> to know the meaning of the id  i have to connect the 2 tables to know the
> product.description
>
>
> thank you
>
>
> 2011/7/28 Miguel Lopes 
>
>> The DAL is not SQL, it has a diferent logic.
>> What are you trying to achieve?
>>
>>
>>
>> 2011/7/28 António Ramos 
>>
>>> this
>>> db(db.requests.product==*db.products.id*==3).select()
>>>
>>> returns all field from *product* table only
>>>
>>> this
>>> db(db.products.id==*db.requests.product*==3).select()
>>>
>>>   returns all field from *requests* table only
>>>
>>>
>>> What is the logic?
>>>
>>> and if i want all record from both tables?
>>>
>>>
>>> thank you
>>> António
>>>
>>>
>>
>


Re: [web2py] return record from a query only shows field from one table

2011-07-28 Thread Miguel Lopes
The DAL is not SQL, it has a diferent logic.
What are you trying to achieve?


2011/7/28 António Ramos 

> this
> db(db.requests.product==*db.products.id*==3).select()
>
> returns all field from *product* table only
>
> this
> db(db.products.id==*db.requests.product*==3).select()
>
>   returns all field from *requests* table only
>
>
> What is the logic?
>
> and if i want all record from both tables?
>
>
> thank you
> António
>
>


Re: [web2py] Re: DAL db(db.table.id>1).select() diferent from db.select(db.table.id>1)

2011-07-28 Thread Miguel Lopes
The correct syntax is:

db(query).select( fields_to_include )
You can find the details at:
http://web2py.com/book/default/chapter/06#Query,-Set,-Rows

as for db.select(db.table.id>1) I would expect it to create a ticket due to
a KeyError since db as no select method.


2011/7/28 António Ramos 

> correction
> the first returns what i want and the second returns all records but they
> are empty
>
>
>
> Em 28 de julho de 2011 13:11, António Ramos escreveu:
>
> hello
>>
>> why
>> db(db.table.id>1).select() is diferent from db.select(db.table.id>1)
>>
>> the first returns what i want, the second returns all
>>
>>
>> thank you
>> António
>>
>
>


Re: [web2py] web2py for freelance work

2011-07-26 Thread Miguel Lopes
1. web2py is especially good for freelancers and single developers because
it is such a tight package. Everything works really well together and right
out of the box.

2. From the forum I get the impression that there is a lot of intranet work.
But if you look for sites built with web2py I think that are enough examples
out there to make anyone feel comfortable.

3. It fares really well! One frequently voiced concern is performance, which
is not a problem at all. Python is pretty fast for an interpreted language,
the database io (outside of Python is really the bottleneck). And rocket is
very, very fast.

4. Well, depending on your goals, webdevelopment can be pretty difficult.
Especially for a single developer, browser inconsistencies, many different
skills and know-hows involved (HTML, CSS, deployment, ...). Particularly
powerful and easy is SQLFORM :-) ,  the DAL is pretty sleek. web2py, like
Python, can be said to "fit the brain" (i.e. you won't be looking much at
documentation) which is a real productivity booster - KUDOS Massimo. The
forum is great and answers are generally very very fast.

5. Generally clients don't care. However this might not always be the case.
Python as been around for 20 years! If you look at programming indexes it is
generally found among the top used languages:

* http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html
* http://langpop.com/
* http://www.devtopics.com/most-popular-programming-languages/

Those who feel more comfortable with corporation languages should check that
open-source languages are not subject to corporate whims, so contrary to
popular belief they tend to die less. Most importantly, Python is also on
multiple platforms, like dotNet and Java, so it is being used as a scripting
langugage not only in C/C++ (and others) but also in C# and Java. And a
cursory inquiry on who uses it leads to replies like:

* Google - also hired GvR
* NASA
* Disney
* Civilization IV (Firaxis Games)
* Plone (most likely the best CMS around opensource or not)
* Yahoo Maps

The list goes on and on. For some of this and other references :
* http://www.python.org/about/success/
* http://wiki.python.org/moin/OrganizationsUsingPython

No one should be concerned with using Python!

HTH,
Miguel


On Mon, Jul 25, 2011 at 6:26 PM, spiffytech  wrote:

> I'm picking out a framework to use for freelance web development. Does
> anyone use web2py in that sort of situation? How does it fare? Do you
> find anything particularly limiting or particularly easy? How do
> clients respond when you tell them you're building the site in Python
> (not PHP), and that you're building it in one of the less-common
> frameworks?


Re: [web2py] The web2py grid/crud plugin you've always dreamed about!

2011-07-24 Thread Miguel Lopes
Great work, it will be/is very useful for many of us!
Thanks,
Miguel

On Fri, Jul 22, 2011 at 11:35 PM, Bruno Rocha  wrote:

> Hi,
>
> I present you PowerGrid Plugin (now in beta 0.1) [
> http://labs.blouweb.com/PowerGrid/]
>
> What is it?
>
> A plugin to show, manage and paginate data
> It works with paginated JSON callbacks, you can use web2py DAL's Query or
> Table, or you can create your own callback returning the desired JSON or
> JSONP
>
> What is has in special?
> - Based on Jquery templates
> - Server side pagination loads records on demand
> - Ajax Caching option
> - Programable in pure Python & web2py
> - You can pass JS callbacks to the event handlers
> - Can show images with Virtual Fields
> - has button system
> - totally integrated with CRUD
> - Easy to integrate with Auth
> - Can be used to manage a site content (a CMS admin page)
> - can be used to create any kind of paginated data view
>
> Changelog:
> - Some issues solved
> - Tested in Windows, Linux, I.E, Opera, Chrome, FF
> - Better default layout
>
> Beta:
> - Needs tests with different datasources
> - Need to be tested on GAE
> - Need to test multiple on the same page
> - Need to test wotking with another UI libs
>
> EXAMPLES:
> images - http://labs.blouweb.com/PowerGrid/default/withimages
> dataGRid - http://labs.blouweb.com/PowerGrid/default/onlydata
> Buttons - http://labs.blouweb.com/PowerGrid/default/buttons
> Scrolling - http://labs.blouweb.com/PowerGrid/default/scroll
> Customization: http://labs.blouweb.com/PowerGrid/default/nocontrol /
> http://labs.blouweb.com/PowerGrid/default/noadd /
> http://labs.blouweb.com/PowerGrid/default/nosearch
> Default search system:
> http://labs.blouweb.com/PowerGrid/default/defaultsearch?what=Ferrari&where=manufacturer
> SubGrids: http://labs.blouweb.com/PowerGrid/default/gridinpopup
> JavaScript callbacks:
> http://labs.blouweb.com/PowerGrid/default/jscallbacks
> Custom templates: http://labs.blouweb.com/PowerGrid/default/blog (a blog
> created with it)
>
>
> DOCUMENTATION:
> Is being writen in home page
> http://labs.blouweb.com/PowerGrid/default/index (in the grid)
> source example app is well commented with options.
>
> IT USES:
> http://labs.blouweb.com/PowerGrid/default/about
>
>
> Comments:
> http://labs.blouweb.com/PowerGrid/default/support
>
>
> Get it:
> http://labs.blouweb.com/PowerGrid/default/get
>
>
> !!! BETA VERSION, SOME THINGS CAN CRASH, THE SERVER IS A BIT SLOW, IT WILL
> BE VERY MORE QUICKLY IN A GOOD SERVER OR GAE !!!
>
> Thanks if you can test and report on BitBucker or omments page.
>
>
> Bruno Rocha
> [ About me: http://zerp.ly/rochacbruno ]
> [ Aprenda a programar: http://CursoDePython.com.br ]
> [ O seu aliado nos cuidados com os animais: http://AnimalSystem.com.br ]
> [ Consultoria em desenvolvimento web: http://www.blouweb.com ]
>
>


Re: [web2py] web2py videos on the internet

2011-07-23 Thread Miguel Lopes
Cool!

On Fri, Jul 22, 2011 at 3:24 PM, Bruno Rocha  wrote:

> I have some (in portuguese)
>
> web2py + Ipython ( IDE for what?)
> http://vimeo.com/26387038
>
> Comet
> http://vimeo.com/18399381
>
> PowerTable
> http://vimeo.com/18447603
>
> Uploadify
> http://vimeo.com/20107460
>
> I am also recording new videos(which will be subtitled)
>
> There are more videos from brazilian people
>
> This is the web2oy channel on VIMEO -> http://vimeo.com/channels/139244 the
> same content as listed in http://web2py.com/examples/default/videos
>
>
>
> 2011/7/22 António Ramos 
>
>> Sorry all post lately but its pertinent ( i think... :)
>>
>>
>> all videos that i found in the internet are made by massimo(99,99%).
>>
>> Great videos but i think that with a lot of people using and loving web2py
>> there shoud be videos from other users experience.
>>
>>
>> Maximo could stimulate his students to post videos of web2py in the
>> internet.
>>
>>
>>
>> It seems that only Massimo cares about videos...
>>
>> As a brilliant guy that he is he should be woking on more important
>> things.
>>
>>
>> IMO
>>
>>
>> Best regards
>>
>> António
>>
>
>
>
> --
>
>
>
> --
> Bruno Rocha
> [ About me: http://zerp.ly/rochacbruno ]
> [ Aprenda a programar: http://CursoDePython.com.br ]
> [ O seu aliado nos cuidados com os animais: http://AnimalSystem.com.br ]
> [ Consultoria em desenvolvimento web: http://www.blouweb.com ]
>
>


Re: [web2py] Web2py Certification Program ?

2011-07-22 Thread Miguel Lopes
There is some private offering, which I think should be listed in web2py.com
:

* a program at DePaul University:
http://www.cdm.depaul.edu/ipd/Programs/Pages/WebDevelopmentwithPython.aspx
* a program in Brasil: http://www.cursodepython.com.br/

And free courses (structured content, besides the www.web2py.com/book)
* in Brasil too (go Brasil!):
http://web2pybrasil.appspot.com/init/plugin_wiki/page/curso-web2py-000

The DePaul program page doesn't mention web2py, but the program used to be
done with web2py, and I guess still is (the word is that  Massimo used to be
the instructor :-)

HTH

2011/7/22 António Ramos 

> Hello,
>
> Why not create a web2py certification program?
> It would be good for the programmer and for web2py
>
> Thank you
> António
>
>
>
>
>


Re: [web2py] Re: Limitation in template system

2011-07-21 Thread Miguel Lopes
Actually I began by using functions too. But had some problems (can't
remember exactly what), and view functions, even if comprised exclusively of
view code didn't really tick my fancy. I much rather extract those snippets
of HTML to a module or model file exclusively dedicated to html snippets. In
terms of code organization I find that to be a better way of centralizing
templates and such - thus making it much simpler to find them for
maintenance. Actually, I recently been playing with plugin_wiki and found
the same strategy applied. So you just:

{{=ClassOrInstanceFromModels.whateverHTMLBlock()}}

Since I mainly use blocks for sidebars I want to conditionally render two
alternatives suit me:

{{if renderSiderbar:}}
{{=ClassOrInstanceFromModels.whateverHTMLForSideBar()}}
{{pass}}

Which is nice and clean. But I like to have expressed in the main layout
that such sidebar may exist. Hence the using template block:
{{block right_sidebar}}
{{if renderSidebar:  # comes from controller right ;-) }}
 {{=Whatever}}
{{pass}}
{{end}}

Anyway, it is possible the best solution may depend on the situation and
individual preferences.


On Tue, Jul 19, 2011 at 9:26 PM, Bruno Rocha  wrote:

> I prefer to work in the old way, used when web2py had no block in views. It
> is very easy and pure Python code.
>
>
> {{def myblock():}}
> 
> {{return}}
>
> So, in any place of views...
>
> {{=myblock()}}
>
> Obviouslly in this way you cannot have {{super}} and other cool things, but
> it is easy to adjust in pure Python, even using classes..
>
>


Re: [web2py] Re: Limitation in template system

2011-07-21 Thread Miguel Lopes
No problem be as criticl as you wish.


> Please do not take my critique in a bad way, but be very careful when
> adding "blocks of code" in your views, I understand the example above
> is just a "code sample" to illustrate a perceived deficiency in the
> view templating system, but unless you are a PHP developer, this just
> looks "ugly", If you have to define variables inside your views, there
> most likely is a problem with the design IMO.  In the general sense,
> variables _control[ler]_ program flow, please place them where they
> belong, even though web2py allows this, and there is even a section
> for this in the book (adding full-fledged python code inside a view
> (html) page), it doesn't mean you "must" use it.
>
> There are exceptions as always, you may need to use python code in a
> view, or html code in a controller, there is nothing "wrong" with
> that, but it should be that, exceptions, please do not turn web2py
> into another PHP-like web development environment and further fuel
> those that want to see us struggle... Thanks.


Re: [web2py] Re: Limitation in template system

2011-07-19 Thread Miguel Lopes
I missed that comments feature. Great you added one!
Miguel

On Tue, Jul 19, 2011 at 12:48 PM, Nico de Groot  wrote:

> Good point, was just going to post this myself, you beat me to it. A hint
> should be added to the web2py book in chapter 5
> http://web2py.com/book/default/chapter/05?search=block#Blocks-in-Views 
> something
> like:
>
> The *{{block}} {{end}}* construction *cannot be used* inside a python
> condition specified by *{{if some_condition:}}*. The current
> implementation will ignore the condition. But you can use conditions *
> inside* a *{block}} *construction or use the {{def}} construction.
>
> I've added this to the web2py book as a comment. One of the editors will
> process this.
>
> Nico
>
>
>
>


[web2py] Limitation in template system

2011-07-13 Thread Miguel Lopes
I think this behavior I've just found is worth sharing.

Templates don't honor the if statement that conditionally "try" to include
or exclude template blocks.
I've just detected this (in 1.96.4 I think) and upgrade to 1.97.1 and the
issue/behavior remains.

{{rsd=None}}
{{if rsd!=None:}}
   {{block right_sidebar}} {{=rsd==None}} {{=repr(rsd)}} {{end}}
{{pass}}

The solution is to put the condition *inside the template block* (tested in
1.97.1)
{{rsd=None}}
{{block right_sidebar}}
{{if rsd!=None:}} {{=rsd==None}} {{=repr(rsd)}} {{pass}}
{{end}}

Miguel


Re: [web2py] web2py - Best Practice

2011-07-13 Thread Miguel Lopes
Let me add the advantage that the initiative stimulates focuses contribution
and supplies a platform for learning.

Some people may not wish, have the time or expertise to get involved with
the development of the web2py framework. This sort of initiative supplies a
narrower ground for contribution that is likely to impose less demands on
contribution or to be more accessible. Thus, it also provides a route for
many to increase both individual knowledge and for the community to explore
and develop framework usage patterns.

Miguel

On Wed, Jul 13, 2011 at 6:45 AM, nic  wrote:

> Dear friends,
>
> I am a huge web2py fan and would like to propose an idea to the
> community.
>
> I understand that web2py is a development environment and has it’s
> roots as an educational platform. One of the things that I have
> personally found most useful are the free appliances. However as
> web2py has matured over time a lot of these have become dated and as
> new developments have emerged I have often been confused about best
> practices going forward.
>
> I would like to propose that we develop a suite of products (open
> source of course) based on the best practices of web2py that would be:
>
> Useful and usable by non-programmers
> Serve as a focal point for the community on just how great web2py
> could be
> Serve as a template for developers
>
> To be clear the idea is to create a separate project from web2py
> itself and then find the best of breed products and develop them in
> web2py. Things like:
>
> A Wiki / Blog / CMS / Forum
> An Online Store
> A Personal Accounting System
> A Media Center
> etc ...
>
> The focus would be on producing complete usable and beautiful
> applications.
>
> I feel that the creation of a separate project will have some
> important advantages such as:
>
> We can create a “brand” around the products.
> It will not “hijack” the core web2py focus.
> Can have separate focus such as functionality and look and feel
> Can include complimentary, tested projects such as open source icons
> and skins
> Can have it’s own development cycle, (eg release every 6 months)
> Can have it’s own repositories etc.
>
> Ultimately the products could be made available by web hosts just by
> the click of a button just like the php ones are now.
>
> I am very interested in the thoughts of the community and if there is
> interest I will move to the next step and create a site (probably on
> GAE) for further discussion such as:
>
> decide on a name
> decide on goals
> decide on processes
> find a home
> decide on products
> etc ...


Re: [web2py] Re: Python newbie: is knowledge of network programming must for web development stuff ?

2011-07-12 Thread Miguel Lopes
Yes. In my opinion basic Python is the only "almost requisite". The book
does a very good job at hand holding, it really helps to know a little
Python (which the book also caters for). My advice is follow along with the
book. If you get stuck by any Python stuff. Take a minute out of web2py and
just solve that issue with Python (at the command line interpreter or with
one of the many excellent shells, e.g. IDLE), then go back. Pretty soon
you'll feel incredibly productive :-)

There's a lot to web development, but the best way is to go and find out as
you feel the need, otherwise you will soon feel overwhelmed.


Re: [web2py] Re: A catchall action per controller - would be proposal

2011-07-08 Thread Miguel Lopes
Yes. That's what I meant. Thank you for making it much clearer.

Like you mention the benefit is unclear. This makes it unnecessary to toy
with routes or router, which I believe is in the spirit of web2py and
benefits beginners with one less location to edit, thing to learn (routes
rules vs. simply overriding a magic function). On the other hand, this is
use case is arguably uncommon and advanced, a clean solution exists, and
__catchall() can be seem as very magical and just adding more to the inner
plumbings of web2py.

Because I'm unsure of the value of the idea I posted the suggestion.
However, after considering better routes/router arguments and the fact that
they do not impose a real penalty on performance this is likely unnecessary.

Miguel


On Thu, Jul 7, 2011 at 6:28 PM, Anthony  wrote:

> Are you suggesting the possibility of defining a function like:
>
> def __catchall():
> # do stuff
> return dict(...)
>
> in a controller, and any time a request comes in for a function that
> doesn't exist in the controller, web2py looks for a function called
> __catchall, and if it exists, passes the request to that function (and
> converts the function part of the url to the first argument, so the
> __catchall function knows what to do with the request)?
>
> What is the benefit of that over using routes and simply specifying a
> default function (which would then not have to appear in URLs)?
>
> Anthony
>
>
> On Thursday, July 7, 2011 3:52:08 AM UTC-4, miguel wrote:
>
>> Yesterday I posted about implementing dynamic actions (functions) in a
>> controller.
>> This is interesting because one can achieve clean urls, instead of passing
>> the names of the dynamic pages in args or vars. In a system with a cms this
>> has the benefit of user defined pages being indistinguishable from extant
>> "hard-coded" actions (if any).
>>
>> However, given the static nature of controllers (they are compiled with
>> web2py) this cannot be achieved with closures or metaprogramming. The
>> solution is to use routes to hide a dispatching action. It maybe possible to
>> add to the controller namespace at runtime (but it is beyond my knowledge to
>> explore this).
>>
>> This made me think that controllers might allow for the implementation
>> (override?) a single dynamic action that would serve as a catchall for calls
>> to non defined actions. I wonder if there as been any debate on this sort of
>> built-in default action? This would supply a way to dealt with all calls
>> that have no defined action per controller (including errors) without having
>> to use routes. A small idea that perhaps does not bring enough benefits to
>> be argued for. What do you think?
>>
>> Miguel
>>
>


Re: [web2py] Re: Metaprogramming in controller

2011-07-08 Thread Miguel Lopes
:-)

On Fri, Jul 8, 2011 at 2:25 AM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> yes. even better use router (vs routes)
>
> On Jul 6, 10:03 am, Miguel Lopes  wrote:
> > Humm,
> >
> > Nice. Yes, closures are enough, and cleaner too.
> > Is routes OK for production mode?
> > Txs,
> > Miguel
> >
> > On Wed, Jul 6, 2011 at 3:54 PM, Massimo Di Pierro <
> >
> >
> >
> >
> >
> >
> >
> > massimo.dipie...@gmail.com> wrote:
> > > Jonathan is right. Here is a simple way around.
> >
> > > Create a single controller called dynamical. use request.args(0) to
> > > parse the name of one of the dynamical actions and remap
> >
> > > def dynamical():
> > > actionname, request.args[:] = request.args(0), request.args[1:]
> > > # call actionname and pass request.args and request.vars
> >
> > > use routes to remove the 'dynamical/' part form the URL.
> >
> > > This allows you to do what you want without necessarily meta-
> > > programming.
> >
> > > On Jul 6, 9:35 am, Miguel Lopes  wrote:
> > > > Thanks. In conjunction with routes could supply a solution
> (shortening
> > > the
> > > > urls).
> > > > I think I should rethink the payoff (see my reply to Massimo
> regarding my
> > > > goals).
> > > > Thanks,
> > > > Miguel
> >
> > > > On Wed, Jul 6, 2011 at 3:12 PM, Jonathan Lundell  >
> > > wrote:
> > > > > On Jul 6, 2011, at 1:23 AM, Miguel Lopes wrote:
> >
> > > > > I'm experimenting with dynamically generating functions, aka
> 'actions'
> > > in
> > > > > controllers. However, I've been unsuccessful. I can use exec and
> > > closures
> > > > > successfully in regular Python code, but I can't make it work with
> > > web2py.
> > > > > Any thoughts on how to achieve this?
> >
> > > > > web2py finds functions by reading the (static) controller file
> itself.
> > > See
> > > > > gluon.compileapp.run_controller_in, in particular this line:
> >
> > > > > exposed = regex_expose.findall(code)
> >
> > > > > So, no dynamically generated controller actions, at least not
> directly.
> >
> > > > > I haven't given this much thought, but one way you might accomplish
> the
> > > > > same effect would be to push the dynamic function name down one
> level
> > > in the
> > > > > URL, something like:http://domain.com/app/dynamic/index/function/.
> ..
> >
> > > > > ...where 'dynamic' is the controller with dynamic functions, and
> index
> > > is a
> > > > > (static) function that calls function dynamically. You might
> optimize
> > > the
> > > > > lookup function to extract only the one desired function from your
> page
> > > > > table.
> >
> > > > > Depending on your overall URL structure, you could rewrite the URLs
> to
> > > > > shorten them up.
> >
> > > > > A closure example - FAILS in web2py:
> > > > > top_pages = db(db.page.id > 0).select()
> > > > > def add_actions(top_pages):
> > > > > for page in top_pages:
> > > > > def inneraction(msg):
> > > > > sidebar = None
> > > > > return dict(message=msg, sidebar=sidebar)
> > > > > inneraction.__name__ = page.link_name
> > > > > globals()[page.link_name] = inneraction
> >
> > > > > add_actions(top_pages)
> >
> > > > > A exec example - FAILS in web2py:
> >
> > > > > ACTION_TEMPLATE = """
> > > > >  def NEW_ACTION():
> > > > > sidebar = None
> > > > > return dict(message='s', sidebar=sidebar)
> > > > >  """
> > > > > top_pages = db(db.page.id > 0).select()
> > > > > def makePages(pages):
> > > > > for page in top_pages:
> > > > > exec ACTION_TEMPLATE
> > > > > NEW_ACTION.__name__ = page.link_name
> > > > > globals()[page.link_name] = NEW_ACTION
> >
> > > > > makePages(pages)
> >
> > > > > Miguel
>


[web2py] A catchall action per controller - would be proposal

2011-07-07 Thread Miguel Lopes
Yesterday I posted about implementing dynamic actions (functions) in a
controller.
This is interesting because one can achieve clean urls, instead of passing
the names of the dynamic pages in args or vars. In a system with a cms this
has the benefit of user defined pages being indistinguishable from extant
"hard-coded" actions (if any).

However, given the static nature of controllers (they are compiled with
web2py) this cannot be achieved with closures or metaprogramming. The
solution is to use routes to hide a dispatching action. It maybe possible to
add to the controller namespace at runtime (but it is beyond my knowledge to
explore this).

This made me think that controllers might allow for the implementation
(override?) a single dynamic action that would serve as a catchall for calls
to non defined actions. I wonder if there as been any debate on this sort of
built-in default action? This would supply a way to dealt with all calls
that have no defined action per controller (including errors) without having
to use routes. A small idea that perhaps does not bring enough benefits to
be argued for. What do you think?

Miguel


Re: [web2py] Re: Metaprogramming in controller

2011-07-07 Thread Miguel Lopes
I see closures are not even necessary. The solution is using routes.

For the interested routes is ok for production (the embargo was old-news).
Here's some info:
https://mail.google.com/mail/?shva=1#search/routes+production/12a53a18e7f6b2d5

Miguel

On Wed, Jul 6, 2011 at 4:03 PM, Miguel Lopes  wrote:

> Humm,
>
> Nice. Yes, closures are enough, and cleaner too.
> Is routes OK for production mode?
> Txs,
> Miguel
>
>
> On Wed, Jul 6, 2011 at 3:54 PM, Massimo Di Pierro <
> massimo.dipie...@gmail.com> wrote:
>
>> Jonathan is right. Here is a simple way around.
>>
>> Create a single controller called dynamical. use request.args(0) to
>> parse the name of one of the dynamical actions and remap
>>
>> def dynamical():
>> actionname, request.args[:] = request.args(0), request.args[1:]
>> # call actionname and pass request.args and request.vars
>>
>> use routes to remove the 'dynamical/' part form the URL.
>>
>> This allows you to do what you want without necessarily meta-
>> programming.
>>
>> On Jul 6, 9:35 am, Miguel Lopes  wrote:
>> > Thanks. In conjunction with routes could supply a solution (shortening
>> the
>> > urls).
>> > I think I should rethink the payoff (see my reply to Massimo regarding
>> my
>> > goals).
>> > Thanks,
>> > Miguel
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > On Wed, Jul 6, 2011 at 3:12 PM, Jonathan Lundell 
>> wrote:
>> > > On Jul 6, 2011, at 1:23 AM, Miguel Lopes wrote:
>> >
>> > > I'm experimenting with dynamically generating functions, aka 'actions'
>> in
>> > > controllers. However, I've been unsuccessful. I can use exec and
>> closures
>> > > successfully in regular Python code, but I can't make it work with
>> web2py.
>> > > Any thoughts on how to achieve this?
>> >
>> > > web2py finds functions by reading the (static) controller file itself.
>> See
>> > > gluon.compileapp.run_controller_in, in particular this line:
>> >
>> > > exposed = regex_expose.findall(code)
>> >
>> > > So, no dynamically generated controller actions, at least not
>> directly.
>> >
>> > > I haven't given this much thought, but one way you might accomplish
>> the
>> > > same effect would be to push the dynamic function name down one level
>> in the
>> > > URL, something like:http://domain.com/app/dynamic/index/function/...
>> >
>> > > ...where 'dynamic' is the controller with dynamic functions, and index
>> is a
>> > > (static) function that calls function dynamically. You might optimize
>> the
>> > > lookup function to extract only the one desired function from your
>> page
>> > > table.
>> >
>> > > Depending on your overall URL structure, you could rewrite the URLs to
>> > > shorten them up.
>> >
>> > > A closure example - FAILS in web2py:
>> > > top_pages = db(db.page.id > 0).select()
>> > > def add_actions(top_pages):
>> > > for page in top_pages:
>> > > def inneraction(msg):
>> > > sidebar = None
>> > > return dict(message=msg, sidebar=sidebar)
>> > > inneraction.__name__ = page.link_name
>> > > globals()[page.link_name] = inneraction
>> >
>> > > add_actions(top_pages)
>> >
>> > > A exec example - FAILS in web2py:
>> >
>> > > ACTION_TEMPLATE = """
>> > >  def NEW_ACTION():
>> > > sidebar = None
>> > > return dict(message='s', sidebar=sidebar)
>> > >  """
>> > > top_pages = db(db.page.id > 0).select()
>> > > def makePages(pages):
>> > > for page in top_pages:
>> > > exec ACTION_TEMPLATE
>> > > NEW_ACTION.__name__ = page.link_name
>> > > globals()[page.link_name] = NEW_ACTION
>> >
>> > > makePages(pages)
>> >
>> > > Miguel
>>
>
>


Re: [web2py] know if a form have pass every validators

2011-07-06 Thread Miguel Lopes
You can also use form.errors

if form.accepts(...):
   ...
elif form.errors:
   ...
HTH,
Miguel

On Wed, Jul 6, 2011 at 5:08 PM, Anthony  wrote:

> form.accepts(...) returns True if all validators pass and False otherwise
> -- is that what you're looking for?
>
> Anthony
>
> On Wednesday, July 6, 2011 11:43:29 AM UTC-4, Richard wrote:
>
>> Hello,
>>
>> Is there a way I can test if form have been submit and if no validators
>> have triggered?
>>
>> Thanks
>>
>> Richard
>>
>


[web2py] "Movie not loaded..." problem with flash

2011-07-06 Thread Miguel Lopes
It is unlikely that this is web2py related, but I'm about to go crazy with
this one. But I guess it's such a general thing someone must know what is
going on.

I'm using different uploaded media, such as files, images and flash files
(.swf files). I can display images without problem, but not flash. Here's my
view template:


  
  



The movie does not load and the flash player menu states "Movie not
loaded...". However this should work, since it works fine with static files:


  
  


Any tips?
Miguel


Re: [web2py] Re: Metaprogramming in controller

2011-07-06 Thread Miguel Lopes
Humm,

Nice. Yes, closures are enough, and cleaner too.
Is routes OK for production mode?
Txs,
Miguel

On Wed, Jul 6, 2011 at 3:54 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> Jonathan is right. Here is a simple way around.
>
> Create a single controller called dynamical. use request.args(0) to
> parse the name of one of the dynamical actions and remap
>
> def dynamical():
> actionname, request.args[:] = request.args(0), request.args[1:]
> # call actionname and pass request.args and request.vars
>
> use routes to remove the 'dynamical/' part form the URL.
>
> This allows you to do what you want without necessarily meta-
> programming.
>
> On Jul 6, 9:35 am, Miguel Lopes  wrote:
> > Thanks. In conjunction with routes could supply a solution (shortening
> the
> > urls).
> > I think I should rethink the payoff (see my reply to Massimo regarding my
> > goals).
> > Thanks,
> > Miguel
> >
> >
> >
> >
> >
> >
> >
> > On Wed, Jul 6, 2011 at 3:12 PM, Jonathan Lundell 
> wrote:
> > > On Jul 6, 2011, at 1:23 AM, Miguel Lopes wrote:
> >
> > > I'm experimenting with dynamically generating functions, aka 'actions'
> in
> > > controllers. However, I've been unsuccessful. I can use exec and
> closures
> > > successfully in regular Python code, but I can't make it work with
> web2py.
> > > Any thoughts on how to achieve this?
> >
> > > web2py finds functions by reading the (static) controller file itself.
> See
> > > gluon.compileapp.run_controller_in, in particular this line:
> >
> > > exposed = regex_expose.findall(code)
> >
> > > So, no dynamically generated controller actions, at least not directly.
> >
> > > I haven't given this much thought, but one way you might accomplish the
> > > same effect would be to push the dynamic function name down one level
> in the
> > > URL, something like:http://domain.com/app/dynamic/index/function/...
> >
> > > ...where 'dynamic' is the controller with dynamic functions, and index
> is a
> > > (static) function that calls function dynamically. You might optimize
> the
> > > lookup function to extract only the one desired function from your page
> > > table.
> >
> > > Depending on your overall URL structure, you could rewrite the URLs to
> > > shorten them up.
> >
> > > A closure example - FAILS in web2py:
> > > top_pages = db(db.page.id > 0).select()
> > > def add_actions(top_pages):
> > > for page in top_pages:
> > > def inneraction(msg):
> > > sidebar = None
> > > return dict(message=msg, sidebar=sidebar)
> > > inneraction.__name__ = page.link_name
> > > globals()[page.link_name] = inneraction
> >
> > > add_actions(top_pages)
> >
> > > A exec example - FAILS in web2py:
> >
> > > ACTION_TEMPLATE = """
> > >  def NEW_ACTION():
> > > sidebar = None
> > > return dict(message='s', sidebar=sidebar)
> > >  """
> > > top_pages = db(db.page.id > 0).select()
> > > def makePages(pages):
> > > for page in top_pages:
> > > exec ACTION_TEMPLATE
> > > NEW_ACTION.__name__ = page.link_name
> > > globals()[page.link_name] = NEW_ACTION
> >
> > > makePages(pages)
> >
> > > Miguel
>


Re: [web2py] Metaprogramming in controller

2011-07-06 Thread Miguel Lopes
Thanks. In conjunction with routes could supply a solution (shortening the
urls).
I think I should rethink the payoff (see my reply to Massimo regarding my
goals).
Thanks,
Miguel

On Wed, Jul 6, 2011 at 3:12 PM, Jonathan Lundell  wrote:

> On Jul 6, 2011, at 1:23 AM, Miguel Lopes wrote:
>
> I'm experimenting with dynamically generating functions, aka 'actions' in
> controllers. However, I've been unsuccessful. I can use exec and closures
> successfully in regular Python code, but I can't make it work with web2py.
> Any thoughts on how to achieve this?
>
>
> web2py finds functions by reading the (static) controller file itself. See
> gluon.compileapp.run_controller_in, in particular this line:
>
> exposed = regex_expose.findall(code)
>
> So, no dynamically generated controller actions, at least not directly.
>
> I haven't given this much thought, but one way you might accomplish the
> same effect would be to push the dynamic function name down one level in the
> URL, something like: http://domain.com/app/dynamic/index/function/...
>
> ...where 'dynamic' is the controller with dynamic functions, and index is a
> (static) function that calls function dynamically. You might optimize the
> lookup function to extract only the one desired function from your page
> table.
>
> Depending on your overall URL structure, you could rewrite the URLs to
> shorten them up.
>
>
> A closure example - FAILS in web2py:
> top_pages = db(db.page.id > 0).select()
> def add_actions(top_pages):
> for page in top_pages:
> def inneraction(msg):
> sidebar = None
> return dict(message=msg, sidebar=sidebar)
> inneraction.__name__ = page.link_name
> globals()[page.link_name] = inneraction
>
> add_actions(top_pages)
>
> A exec example - FAILS in web2py:
>
> ACTION_TEMPLATE = """
>  def NEW_ACTION():
> sidebar = None
> return dict(message='s', sidebar=sidebar)
>  """
> top_pages = db(db.page.id > 0).select()
> def makePages(pages):
> for page in top_pages:
> exec ACTION_TEMPLATE
> NEW_ACTION.__name__ = page.link_name
> globals()[page.link_name] = NEW_ACTION
>
> makePages(pages)
>
> Miguel
>
>
>
>


Re: [web2py] Re: Metaprogramming in controller

2011-07-06 Thread Miguel Lopes
I putting together an interface where users can add pages to a site and have
these pages indistinguishable from "hard-coded" pages/functions. However, I
would have the best of both worlds and have very clean urls. Thus, I'm
trying to avoid things like:

/application/controller/catchall_function/page/1/12
/application/controller/catchall_function?_page=books?title=12

And have something like:

/application/controller/books/12

I know I could use routes to send everything to a function to process the
response, but I was wondering about doing this with closures.

Thanks,
Miguel


On Wed, Jul 6, 2011 at 1:57 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> Can you explain the goal?
>
> On Jul 6, 3:23 am, Miguel Lopes  wrote:
> > I'm experimenting with dynamically generating functions, aka 'actions' in
> > controllers. However, I've been unsuccessful. I can use exec and closures
> > successfully in regular Python code, but I can't make it work with
> web2py.
> > Any thoughts on how to achieve this?
> >
> > A closure example - FAILS in web2py:
> >
> > top_pages = db(db.page.id > 0).select()
> >
> > def add_actions(top_pages):
> >
> > for page in top_pages:
> >
> > def inneraction(msg):
> >
> > sidebar = None
> >
> > return dict(message=msg, sidebar=sidebar)
> >
> > inneraction.__name__ = page.link_name
> >
> > globals()[page.link_name] = inneraction
> >
> > add_actions(top_pages)
> >
> > A exec example - FAILS in web2py:
> >
> > ACTION_TEMPLATE = """
> >
> >  def NEW_ACTION():
> >
> > sidebar = None
> >
> > return dict(message='s', sidebar=sidebar)
> >
> >  """
> >
> > top_pages = db(db.page.id > 0).select()
> >
> > def makePages(pages):
> >
> > for page in top_pages:
> >
> > exec ACTION_TEMPLATE
> >
> > NEW_ACTION.__name__ = page.link_name
> >
> > globals()[page.link_name] = NEW_ACTION
> >
> > makePages(pages)
> >
> > Miguel
>


[web2py] Metaprogramming in controller

2011-07-06 Thread Miguel Lopes
I'm experimenting with dynamically generating functions, aka 'actions' in
controllers. However, I've been unsuccessful. I can use exec and closures
successfully in regular Python code, but I can't make it work with web2py.
Any thoughts on how to achieve this?

A closure example - FAILS in web2py:

top_pages = db(db.page.id > 0).select()

def add_actions(top_pages):

for page in top_pages:

def inneraction(msg):

sidebar = None

return dict(message=msg, sidebar=sidebar)

inneraction.__name__ = page.link_name

globals()[page.link_name] = inneraction


add_actions(top_pages)


A exec example - FAILS in web2py:

ACTION_TEMPLATE = """

 def NEW_ACTION():

sidebar = None

return dict(message='s', sidebar=sidebar)

 """

top_pages = db(db.page.id > 0).select()

def makePages(pages):

for page in top_pages:

exec ACTION_TEMPLATE

NEW_ACTION.__name__ = page.link_name

globals()[page.link_name] = NEW_ACTION


makePages(pages)


Miguel


Re: [web2py] web2py 1.96.1 is OUT

2011-06-02 Thread Miguel Lopes
On Wed, Jun 1, 2011 at 7:40 PM, Jason Brower  wrote:

>  Me does a dance. Thanks!
> And yes it makes rain :-)
>


Re: [web2py] form in loop view

2011-05-23 Thread Miguel Lopes
On Mon, May 23, 2011 at 10:50 AM, Stifan Kristi <
steve.van.chris...@gmail.com> wrote:

> ...
> === controller ===
> def blog_index():
> for i, row in enumerate(rows):
>if i == items_per_page: break
>
>db.blog_comment.blog_id.default = row.id
>form = crud.create(db.blog_comment,
> message = T('Record Inserted'))
> return dict (form, rows.id, rows.title, rows.content)
>
>
I guess this code is an example, and not what you are trying to run! Since
your return dict makes no sense.

Regarding the forms, this will not work because in every loop iteration you
overwrite the default id and form. Thus, you will only send to the view the
last form you created.

You would need something like (untested):
def blog_index():
forms = []
for i, row in enumerate(rows):
...
forms.append(crud.create(db.blog_comment, message = T('Record
Inserted')))
return dict(forms=forms)

Miguel


Re: [web2py] form in loop view

2011-05-23 Thread Miguel Lopes
On Sun, May 22, 2011 at 9:02 AM, 黄祥  wrote:

> hi,
>
> is it possible to use form in loop view?
>
> e.g.
> {{for i, row in enumerate(rows):}}
>{{if i == items_per_page: break}}
>
>{{db.blog_comment.blog_id.default = row.id}}
>{{form = crud.create(db.blog_comment,
> message = T('Record Inserted'))}}
>
>{{=DIV(form)}}
> {{pass}}
>
> i just can show the form, but when i submit the data is not in
> database blog comment, i've already tried sqlform too but got same
> result.
>
> did anyone know how to fix it?
> any hints, solutions is greatly appreciate, thank you so much before.


Like Massimo wrote and advised against, it is possible like you are
suggesting to create forms on the view. A simple way to keep logic in the
controller is to do something like this (which is what I think you want):

In the controller you pass some you data - for example a set of rows
"contacts"
In the view:
{{for rec in contacts:}}

 {{=edit_contact_form(rec)}}

{{pass}}

Please note:
  * each div as a standard name with the contacts id added as sufix
"edit_contact_bock{{=rec.id}}"
  * initial style="display:none" the form is shown by the user using jquery

The forms are created with a function defined in the controller. Here's the
function code:
def edit_contact_form(contact):
id='edit_contact_form'+str(contact.id)
form = SQLFORM(db.contact, contact,
   fields=['contact', 'contact_role', 'value_offered',
'value_closed'],
   submit_button='Save',
   showid=False, _id=id,
   deletable=True,
   delete_label='Delete:')
form[0][-1][1].append(INPUT(_type="button", _value='Cancel',
_class='cancel_edit_contact',
_style="margin-left:3px;"))
if form.accepts(request.vars, session, formname=id):
 redirect(URL(r=request, f='view_opportunity', args=contact.oppty.id
))
elif form.errors:
response.flash='Edition failed!'
return form

Please note the juju:
id='edit_contact_form'+str(contact.id)
...
if form.accepts(request.vars, session, formname=id):

Which links each form to a single contact.

Note that some javascript (jquery) is needed to show and hide data and
forms. Since the specific javascript / css to do this is limited to this
specific page (in my app), I append it to response files:

{{response.files.append(URL(r=request,c='static/biz',f='common.js'))}}
{{response.files.append(URL(r=request,c='static',f='view_oppty.css'))}}
{{response.files.append(URL(r=request,c='static/biz',f='view_opportunity.js'))}}

{{extend 'layout.html'}}

I assume that you either show every form or know how to do this in
javascript/jquery.
If anyone as a clearer method to do this I am VERY interested in knowing
about it!

HTH,
Miguel


Re: [web2py] Re: problems with conditional login redirection on on_failed_authorization

2011-01-30 Thread Miguel Lopes
On Sun, Jan 30, 2011 at 9:16 PM, Niphlod  wrote:
> try with auth.settings.on_failed_authorization =
> failedAuthHandlerandler()
>
>  it works for me ^_^
>

Not for me! And I can't see how.
Miguel


[web2py] Re: problems with conditional login redirection on on_failed_authorization

2011-01-30 Thread Miguel Lopes
I'm still in need of help. Here's what I've managed to find.
My problem is that if I don't use good credentials in the command line
I get an exception because web2py is replying with the login_url. This
suggests that the failedAuthHandler I'm using in
auth.settings.on_failed_authorization is not working.

[in models/db.py]
def failedAuthHandler():
if request.function == 'private_call':
redirect(URL(f='failed_login')) # just a regular action
# or alternatively:
redirect(URL(f='public_call', args=['jsonrpc', 'failed_login']))
else:
redirect(URL(request))
auth.settings.on_failed_authorization = failedAuthHandler

Since using "failed_login" as a regular action or as a public_call
makes no difference. is this the correct way to use
auth.settings.on_failed_authorization = function ?

Txs for the help,
Miguel

On Sun, Jan 30, 2011 at 10:55 AM, Miguel Lopes  wrote:
> on_failed_authorization can be a URL or a function.
> I'm think I could use this to achieve conditional login redirection.
> A use case would be service calls returning a simple string (or a JSON
> or an XML reply to non-validated requests), while still allowing for
> regular (non-service requests) to be redirected to a login page.
> This is useful for command-line clients (as a recent post argues) and
> desktops clients, but also to browser based RIA apps (e.g. Pyjamas
> based, Flex,...) where session expiration could lead to wanted
> redirections (as is mentioned in
> http://www.web2pyslices.com/main/slices/take_slice/48 ).
>
> I would see this as something as simple as:
>
> [in models/db.py]
> private_service = Service(globals())           # PRIVATE - for json,
> xml, jsonrpc, xmlrpc, amfrpc
> public_service = Service(globals())            # PUBLIC - for json,
> xml, jsonrpc, xmlrpc, amfrpc
> ...
> auth.settings.allow_basic_login = True
> def failedAuthHandler():
>   if request.function == 'private_call':
>       redirect(URL(f='public_call', args='failed_login'))
>   else:
>       redirect(URL(request))
> auth.settings.on_failed_authorization = failedAuthHandlerandler
>
> [in controllers/default]
> @private_service.jsonrpc
> def jsoncount():
>    return dict(response=response.session_id_name, now=request.now)
>
> @public_service.jsonrpc
> def failed_login():
>    return dict(error='Failed login')
>
> def public_call():
>    return public_service()
>
> @auth.requires_login()
> def private_call():
>    return private_service()
>
> However, I'm unable to make this code work.
> From the command line, if I issue a call with basic auth, with good
> credentials, such as:
>>>> import jsonrpc
>>>> sv = 
>>>> jsonrpc.ServiceProxy("http://GOOD_USER:GOOD_PASS@127.0.0.1:8080/json_auth_test/default/private_call/jsonrpc";)
>>>> sv.jsoncount()
>>>> {'now': '2011-01-30 10:31:21', 'response': 'session_id_json_auth_test'}
>
> But bad credentials don't work as expected:
>>>> import jsonrpc
>>>> sv = 
>>>> jsonrpc.ServiceProxy("http://GOOD_USER:BAD_PASS@127.0.0.1:8080/json_auth_test/default/private_call/jsonrpc";)
>>>> sv.jsoncount()
> Traceback (most recent call last):
>  File "", line 1, in 
>  File 
> "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/jsonrpc/proxy.py",
> line 43, in __call__
>    resp = loads(respdata)
>  File 
> "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/jsonrpc/json.py",
> line 211, in loads
>    raise JSONDecodeException('Expected []{}," or Number, Null, False or True')
> jsonrpc.json.JSONDecodeException: Expected []{}," or Number, Null, False or 
> True
>>>>
>
> From the browser using an url with or without credentials, for both:
> .../default/private_call/jsoncount
> .../default/public_call/failed_login
>
> I get:
> Object does not exist with a Status 404 content header
>
> Am I on the right track?
> How could this be achieved?
> Txs,
> Miguel
>


[web2py] problems with conditional login redirection on on_failed_authorization

2011-01-30 Thread Miguel Lopes
on_failed_authorization can be a URL or a function.
I'm think I could use this to achieve conditional login redirection.
A use case would be service calls returning a simple string (or a JSON
or an XML reply to non-validated requests), while still allowing for
regular (non-service requests) to be redirected to a login page.
This is useful for command-line clients (as a recent post argues) and
desktops clients, but also to browser based RIA apps (e.g. Pyjamas
based, Flex,...) where session expiration could lead to wanted
redirections (as is mentioned in
http://www.web2pyslices.com/main/slices/take_slice/48 ).

I would see this as something as simple as:

[in models/db.py]
private_service = Service(globals())   # PRIVATE - for json,
xml, jsonrpc, xmlrpc, amfrpc
public_service = Service(globals())# PUBLIC - for json,
xml, jsonrpc, xmlrpc, amfrpc
...
auth.settings.allow_basic_login = True
def failedAuthHandler():
   if request.function == 'private_call':
   redirect(URL(f='public_call', args='failed_login'))
   else:
   redirect(URL(request))
auth.settings.on_failed_authorization = failedAuthHandlerandler

[in controllers/default]
@private_service.jsonrpc
def jsoncount():
return dict(response=response.session_id_name, now=request.now)

@public_service.jsonrpc
def failed_login():
return dict(error='Failed login')

def public_call():
return public_service()

@auth.requires_login()
def private_call():
return private_service()

However, I'm unable to make this code work.
>From the command line, if I issue a call with basic auth, with good
credentials, such as:
>>> import jsonrpc
>>> sv = 
>>> jsonrpc.ServiceProxy("http://GOOD_USER:GOOD_PASS@127.0.0.1:8080/json_auth_test/default/private_call/jsonrpc";)
>>> sv.jsoncount()
>>> {'now': '2011-01-30 10:31:21', 'response': 'session_id_json_auth_test'}

But bad credentials don't work as expected:
>>> import jsonrpc
>>> sv = 
>>> jsonrpc.ServiceProxy("http://GOOD_USER:BAD_PASS@127.0.0.1:8080/json_auth_test/default/private_call/jsonrpc";)
>>> sv.jsoncount()
Traceback (most recent call last):
  File "", line 1, in 
  File 
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/jsonrpc/proxy.py",
line 43, in __call__
resp = loads(respdata)
  File 
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/jsonrpc/json.py",
line 211, in loads
raise JSONDecodeException('Expected []{}," or Number, Null, False or True')
jsonrpc.json.JSONDecodeException: Expected []{}," or Number, Null, False or True
>>>

>From the browser using an url with or without credentials, for both:
.../default/private_call/jsoncount
.../default/public_call/failed_login

I get:
Object does not exist with a Status 404 content header

Am I on the right track?
How could this be achieved?
Txs,
Miguel


Re: [web2py] Re: Fwd: web2py basic auth

2011-01-30 Thread Miguel Lopes
You got me in the right direction.
Txs.
I'll be starting a separate thread on what I'm trying to achieve, so
far without success.


On Sat, Jan 29, 2011 at 8:13 PM, Niphlod  wrote:
> sorry, my mistake!
>
> On Jan 29, 4:01 pm, Miguel Lopes  wrote:
>> gluons/tools.py
>>
>> Txs,
>> Miguel
>>
>> On Sat, Jan 29, 2011 at 12:29 AM, Niphlod  wrote:
>> > call_or_redirect() is the real "addition" here  you can use both a
>> > URL or a function to manage on_failed_authentication and
>> > on_failed_authorization ... take a look in gluon/utils.py
>>
>> > On Jan 28, 1:48 am, miguel  wrote:
>> > > I suppose this is mentioned in the Change Log by:
>> > > "on_failed_authorization can be a function, thanks Niphold"
>>
>> > > How is this used? could the function be a lambda, does it take params,
>> > > is it an action (i.e. a controller function)?
>>
>> > > Also, is it possible to allow the usual login redirection in case it
>> > > is not a service call? I'm thinking in these lines:
>>
>> > > def theFunction():
>> > >     if request.function == 'call':
>> > >         # return case forservice call
>> > >     else:
>> > >         # redirect to login form
>>
>> > > This would be useful for publishing the same service both for browsers
>> > > and for other apps, like it is mentioned in p://
>> >www.web2pyslices.com/main/slices/take_slice/48
>> > > (see "Authentication"). This solution would also be useful for other
>> > > non-browser-based clients. Would it work? How is the function used?
>>
>> > > Txs,
>> > > Miguel
>>
>> > > -- Forwarded message --
>> > > From: mdipierro 
>> > > Date: Sep 23 2010, 2:34 pm
>> > > Subject: web2py basic auth
>> > > To: web2py-users
>>
>> > > Against trunk please. It is ok if you just send me a replacement file.
>> > > I will diff and study it.
>>
>> > > On Sep 23, 8:52 am, Niphlod  wrote:
>>
>> > > > Never done a patch before, but I think in the night (here are 3PM) I
>> > > > can manage to have a first draft.
>>
>> > > > I'd have to test it out, but for the beginning .. What wuold be the
>> > > > patch against ? tools.py in trunk or tools.py in 1.85.3?
>>
>> > > > On 23 Set, 14:52, mdipierro  wrote:
>>
>> > > > > You are right. That would be best. Want to send me a patch?
>>
>> > > > > On Sep 23, 2:26 am, Niphlod  wrote:
>>
>>


Re: [web2py] Re: Learning materials for newbie

2011-01-29 Thread Miguel Lopes
On Fri, Jan 28, 2011 at 11:01 PM, mikech  wrote:
> I've also found it pretty useful recently to run the web2py app from source
> in a good ide, in my case WingIDE which I have a 10 day trial on, and step
> thru the program using the debugger.

Eclipse or Aptana with PyDev is also a good and free solution.
For just debugging the excellent and cross-paltform winpdb is great.
Firebug in Firefox for client side debugging and designing. If you
want to debug on Safari just activate the develop menu (in the
preferences | advanced menu)


Re: [web2py] Re: Fwd: web2py basic auth

2011-01-29 Thread Miguel Lopes
gluons/tools.py

Txs,
Miguel

On Sat, Jan 29, 2011 at 12:29 AM, Niphlod  wrote:

> call_or_redirect() is the real "addition" here  you can use both a
> URL or a function to manage on_failed_authentication and
> on_failed_authorization ... take a look in gluon/utils.py
>
> On Jan 28, 1:48 am, miguel  wrote:
> > I suppose this is mentioned in the Change Log by:
> > "on_failed_authorization can be a function, thanks Niphold"
> >
> > How is this used? could the function be a lambda, does it take params,
> > is it an action (i.e. a controller function)?
> >
> > Also, is it possible to allow the usual login redirection in case it
> > is not a service call? I'm thinking in these lines:
> >
> > def theFunction():
> > if request.function == 'call':
> > # return case forservice call
> > else:
> > # redirect to login form
> >
> > This would be useful for publishing the same service both for browsers
> > and for other apps, like it is mentioned in p://
> www.web2pyslices.com/main/slices/take_slice/48
> > (see "Authentication"). This solution would also be useful for other
> > non-browser-based clients. Would it work? How is the function used?
> >
> > Txs,
> > Miguel
> >
> > -- Forwarded message --
> > From: mdipierro 
> > Date: Sep 23 2010, 2:34 pm
> > Subject: web2py basic auth
> > To: web2py-users
> >
> > Against trunk please. It is ok if you just send me a replacement file.
> > I will diff and study it.
> >
> > On Sep 23, 8:52 am, Niphlod  wrote:
> >
> > > Never done a patch before, but I think in the night (here are 3PM) I
> > > can manage to have a first draft.
> >
> > > I'd have to test it out, but for the beginning .. What wuold be the
> > > patch against ? tools.py in trunk or tools.py in 1.85.3?
> >
> > > On 23 Set, 14:52, mdipierro  wrote:
> >
> > > > You are right. That would be best. Want to send me a patch?
> >
> > > > On Sep 23, 2:26 am, Niphlod  wrote:
> >
> >
>


Re: [web2py] Learning materials for newbie

2011-01-28 Thread Miguel Lopes
Hi,

To learn Python I found these very helpful (no particular order):

   - Hetland's stuff is concise and clear which is not always the case :-)
  - http://hetland.org/writing/instant-hacking.html
  - http://hetland.org/writing/instant-python.html
   - Alan Gaud's on-line is also very clear and more detailed:
  - http://www.freenetpages.co.uk/hp/alan.gauld/tutor2/index.htm
   - Allen Downey's free book is also a good resource for the complete
   newbye (both online and as a free downloadable pdf):
  - http://www.greenteapress.com/thinkpython/thinkpython.html
   - tutor python list may also be helpful at times:
  - http://mail.python.org/mailman/listinfo/tutor

Regarding Python these resources are way more than enough to get by
developing web2py app's. For example although knowing about classes is
helpful to achieve some advanced stuff in web2py, you don't really need it
to accomplish great websites!

As for web2py you have already found the main resources: the book and this
list.
Sooner or later you get the urge to learn about jQuery or someother
javascript library. My advice is delay learning these as long as you can -
it's not a good idea to try to learn everything at once. On this note. Spend
a few days just playing with Python before you pick up web2py, this will
make web2py much simpler to learn. Following Alan Gauld's tut do the basics,
then the advanced (ignore the part about GUI programming - that's desktop).

You also have to pick some basic html to start with. For me learning html on
a need to know basis worked out fine.

Remember to google, google, then ask on the net/list(s)
Happy coding
HTH,
Miguel

On Fri, Jan 28, 2011 at 9:46 PM, Richard Vézina  wrote:

> Web2py book : http://www.web2py.com/book
>
> Richard
>
>
> On Fri, Jan 28, 2011 at 4:38 PM, noob.py  wrote:
>
>> Hello,
>> I'm totally new to programming, but very motivated to learn it. I'm
>> especially interested in creating web application (that's why I post
>> here). So, can anyone tell me what do I have to learn (except Python
>> and web2py of course) and point me some good learning materials and
>> resources (books, ebooks, web tutorials, etc.)?
>
>
>


Re: [web2py] Re: minimal setup on Debian for using Mail()

2010-12-05 Thread Miguel Lopes
Ok. Solved!
It was really just a configuration issue:
mail.settings.server = 'localhost:25'# I
wasn't referring to the server properly!
mail.settings.sender = 'whatever.m...@yourdomain.com'  # your email

with this setup I can send email with sendmail from web2py.
Txs for pointing me to the right direction.
Miguel

On Sun, Dec 5, 2010 at 5:17 PM, Miguel Lopes  wrote:

> Ok. here's the situation:
>
> I only have sendmail installed and running, no exim, postfix or other. I've
> checked this listing running services by using:
> netstat -tap
>
>  I successfully sent email using telnet like Bernardo suggested.
> Since I have sendmail working, couldn't I use it with web2py, instead of
> using some other solution?
>
>
> Txs José for the tip regarding sSMTP, I've also spotted what seems like a
> easy way to install and configure a mail server http://www.iredmail.org/.
> In case I can get this going I just might use sSMTP.
>
> txs,
> Miguel
> *
> *
> *
> *
> *
> *
> On Sun, Dec 5, 2010 at 9:44 AM, José L.  wrote:
>
>>
>>
>> On 4 dic, 21:54, Miguel Lopes  wrote:
>> > Hi Bernado,
>> >
>> > 2010/12/4 Bernardo Botella Corbí 
>> >
>> > > Hi Miguel,
>> >
>> > > which test did you do from command line?
>> > > does web2py print something? Any error?
>> >
>> > > Try to do the next thing from the command line:
>> > > tail -f /var/log/mail.log
>> >
>> > If I try to send mail from web2py using local resources it fails
>> silently.
>> > I can use a gmail account to send the email it works, so perhaps I'm
>> > configuring gluon.tools.Mail wrongly:
>> > mail.settings.server = 'myIP:25'# your SMTP
>> > server
>> > mail.settings.sender = 'u...@mydomain.pt' # your email
>> > mail.settings.login = 'user:pass'   # your
>> > credentials or None 'username:password'
>> >
>> > I'm unsure about mails.settings.server. Is this correct?
>> >
>> > > (if you are in ubuntu/debian, don't know where it would be in other
>> > > distributions...)
>> >
>> > > I'm using Debian Lenny.
>> >
>> > txs,
>> > Miguel
>>
>>
>> Using Debian Lenny you have probably intalled exim4 as mail server,
>> don't need to install postfix to do the same.
>> Do "dpkg-reconfigure exim4-config" (previously install exim4-config if
>> you don't have it installed) and choose the option of your mail server
>> settings you prefer.
>>
>> Anyway, if you're not going to use it massively, I'd recomend you
>> replacing exim4 by ssmtp (the simplest mail server around), as it's
>> really easy to setup.
>> http://wiki.debian.org/sSMTP
>>
>> To test if it's working, then install  mail-utils, and use the command
>> "mail" to send mails and check if they 're received. Then you are sure
>> your server setup is working and you can think of configuring mail in
>> web2py.
>>
>> Regards
>> José L.
>>
>
>


Re: [web2py] Re: minimal setup on Debian for using Mail()

2010-12-05 Thread Miguel Lopes
Ok. here's the situation:

I only have sendmail installed and running, no exim, postfix or other. I've
checked this listing running services by using:
netstat -tap

I successfully sent email using telnet like Bernardo suggested.
Since I have sendmail working, couldn't I use it with web2py, instead of
using some other solution?


Txs José for the tip regarding sSMTP, I've also spotted what seems like a
easy way to install and configure a mail server http://www.iredmail.org/. In
case I can get this going I just might use sSMTP.

txs,
Miguel
*
*
*
*
*
*
On Sun, Dec 5, 2010 at 9:44 AM, José L.  wrote:

>
>
> On 4 dic, 21:54, Miguel Lopes  wrote:
> > Hi Bernado,
> >
> > 2010/12/4 Bernardo Botella Corbí 
> >
> > > Hi Miguel,
> >
> > > which test did you do from command line?
> > > does web2py print something? Any error?
> >
> > > Try to do the next thing from the command line:
> > > tail -f /var/log/mail.log
> >
> > If I try to send mail from web2py using local resources it fails
> silently.
> > I can use a gmail account to send the email it works, so perhaps I'm
> > configuring gluon.tools.Mail wrongly:
> > mail.settings.server = 'myIP:25'# your SMTP
> > server
> > mail.settings.sender = 'u...@mydomain.pt' # your email
> > mail.settings.login = 'user:pass'   # your
> > credentials or None 'username:password'
> >
> > I'm unsure about mails.settings.server. Is this correct?
> >
> > > (if you are in ubuntu/debian, don't know where it would be in other
> > > distributions...)
> >
> > > I'm using Debian Lenny.
> >
> > txs,
> > Miguel
>
>
> Using Debian Lenny you have probably intalled exim4 as mail server,
> don't need to install postfix to do the same.
> Do "dpkg-reconfigure exim4-config" (previously install exim4-config if
> you don't have it installed) and choose the option of your mail server
> settings you prefer.
>
> Anyway, if you're not going to use it massively, I'd recomend you
> replacing exim4 by ssmtp (the simplest mail server around), as it's
> really easy to setup.
> http://wiki.debian.org/sSMTP
>
> To test if it's working, then install  mail-utils, and use the command
> "mail" to send mails and check if they 're received. Then you are sure
> your server setup is working and you can think of configuring mail in
> web2py.
>
> Regards
> José L.
>


Re: [web2py] Re: minimal setup on Debian for using Mail()

2010-12-04 Thread Miguel Lopes
Hi Bernado,

2010/12/4 Bernardo Botella Corbí 

> Hi Miguel,
>
> which test did you do from command line?
> does web2py print something? Any error?
>
> Try to do the next thing from the command line:
> tail -f /var/log/mail.log
>

If I try to send mail from web2py using local resources it fails silently.
I can use a gmail account to send the email it works, so perhaps I'm
configuring gluon.tools.Mail wrongly:
mail.settings.server = 'myIP:25'# your SMTP
server
mail.settings.sender = 'u...@mydomain.pt' # your email
mail.settings.login = 'user:pass'   # your
credentials or None 'username:password'

I'm unsure about mails.settings.server. Is this correct?


> (if you are in ubuntu/debian, don't know where it would be in other
> distributions...)
>
> I'm using Debian Lenny.

txs,
Miguel


Re: [web2py] Re: minimal setup on Debian for using Mail()

2010-12-03 Thread Miguel Lopes
On Sat, Dec 4, 2010 at 1:12 AM, mdipierro  wrote:

> did you apt-get install portfix?
>
> Do you mean postfix? No I didn't.

By the way, tp be precise in the config I'm using:
mail.settings.server = 'myIPaddress:25'  # your
SMTPserver

since sendmail uses port 25 by default.
Miguel



>
> On Dec 3, 6:36 pm, Miguel Lopes  wrote:
> > I'm having problems trying to make gluon.tools.Mail work on a vps, and
> > wonder if anyone knows what would be a minimal setup for sending mail.
> > I just need to send the an occasional mail. The server as sendmail
> working,
> > which I've confirmed in the command line. However, I'm unable to make it
> > work via web2py.
> > My model file reads:
> >
> > mail.settings.server = 'localhost'  # your
> SMTP
> > server
> > mail.settings.sender = 'r...@mydomain.pt' # your email
> > #mail.settings.login = ''#
> your
> > credentials or None 'username:password'
> >
> > I confess being a complete n00b regarding linux admin.
> > Is sendmail enough? What could I be missing?
> > Miguel
>


[web2py] minimal setup on Debian for using Mail()

2010-12-03 Thread Miguel Lopes
I'm having problems trying to make gluon.tools.Mail work on a vps, and
wonder if anyone knows what would be a minimal setup for sending mail.
I just need to send the an occasional mail. The server as sendmail working,
which I've confirmed in the command line. However, I'm unable to make it
work via web2py.
My model file reads:

mail.settings.server = 'localhost'  # your SMTP
server
mail.settings.sender = 'r...@mydomain.pt' # your email
#mail.settings.login = ''# your
credentials or None 'username:password'

I confess being a complete n00b regarding linux admin.
Is sendmail enough? What could I be missing?
Miguel


Re: [web2py] Re: Multiple submit not working on component

2010-08-24 Thread Miguel Lopes
On Tue, Aug 24, 2010 at 1:04 PM, mdipierro  wrote:

> jquery serialize also does not support type=file. If you have a way to
> get around these, please let me know.
>
>
I've researched this a bit. Although I have not found an authoritarive
source, the "problem" is that Javascript cannot access files on the desktop,
the browser must do it. Thus, not supporting inout type=file is not a jQuery
problem. It is possible to code around this, namely using iframe (any
other?). Someone more knowledgable may confirm this.

Some interesting solutions are (untested):
http://valums.com/ajax-upload/- a dedicated javascript script library
http://trentrichardson.com/2009/06/05/meet-jquery-iframer/- a jQuery
plugin
http://www.webtoolkit.info/ajax-file-upload.html  - a 1Kb Javascript
file

Anyone has experience with these or other solutions?
Miguel


Re: [web2py] Re: Multiple submit not working on component

2010-08-24 Thread Miguel Lopes
Thank you!
Importantly, although it is very convenient to have these values
serialized, it is simple to get around this jQuery imposed limitation (bug).
Miguel

On Tue, Aug 24, 2010 at 4:02 AM, mdipierro  wrote:

> well... it is a bug not not in web2py, in jQuery:
>
>
> http://www.johnnycode.com/blog/2010/04/08/jquery-form-serialize-doesnt-post-submit-and-button-values-duh/
>
> We cannot fork jQuery to fix this. Eventually they will fix it.
>
> Massimo
>
> On Aug 23, 8:46 am, Miguel Lopes  wrote:
> > As an update, the issue remains with the following combinations:
> > * if input type='submit' and different names
> > * if input type='button', with or without different name attributes
> >
> > However, input type='text' are present in form.vars.
> >
> > For the interested a solution for usage in components is to use set a
> hidden
> > input text field via the click event of each button.
> > Miguel
> >
> > On Mon, Aug 23, 2010 at 3:54 AM, Miguel Lopes 
> wrote:
> > > I'm using the "same name to all input type submits" technique. This is
> very
> > > nice because it avoids some js and works like a charm :-)
> > > In a regular controller the code works flawlessly. However when I try
> to
> > > put it in a controller, it fails:
> >
> > > status_form = FORM(_id='status_form')
> > > for status in OPPTY_STATUS:
> > > btn = INPUT(_type='submit', _name='status', _value=status,
> > > _class='status_btn')
> > > status_form.append(btn)
> >
> > > if status_form.accepts(request.vars, session, formname='status_form'):
> > > # status_form.vars.status is None in component
> > > # status_form.vars.status corresponds to whatever submit was
> pressed in
> > > regular controller
> > > ...
> >
> > > It seems like the component mechanisms is ignoring the value of
> 'status'.
> >
> > > Miguel
>


[web2py] Re: Multiple submit not working on component

2010-08-23 Thread Miguel Lopes
As an update, the issue remains with the following combinations:
* if input type='submit' and different names
* if input type='button', with or without different name attributes

However, input type='text' are present in form.vars.

For the interested a solution for usage in components is to use set a hidden
input text field via the click event of each button.
Miguel


On Mon, Aug 23, 2010 at 3:54 AM, Miguel Lopes  wrote:

> I'm using the "same name to all input type submits" technique. This is very
> nice because it avoids some js and works like a charm :-)
> In a regular controller the code works flawlessly. However when I try to
> put it in a controller, it fails:
>
> status_form = FORM(_id='status_form')
> for status in OPPTY_STATUS:
> btn = INPUT(_type='submit', _name='status', _value=status,
> _class='status_btn')
> status_form.append(btn)
>
> if status_form.accepts(request.vars, session, formname='status_form'):
> # status_form.vars.status is None in component
> # status_form.vars.status corresponds to whatever submit was pressed in
> regular controller
> ...
>
> It seems like the component mechanisms is ignoring the value of 'status'.
>
> Miguel
>


[web2py] Multiple submit not working on component

2010-08-22 Thread Miguel Lopes
I'm using the "same name to all input type submits" technique. This is very
nice because it avoids some js and works like a charm :-)
In a regular controller the code works flawlessly. However when I try to put
it in a controller, it fails:

status_form = FORM(_id='status_form')
for status in OPPTY_STATUS:
btn = INPUT(_type='submit', _name='status', _value=status,
_class='status_btn')
status_form.append(btn)

if status_form.accepts(request.vars, session, formname='status_form'):
# status_form.vars.status is None in component
# status_form.vars.status corresponds to whatever submit was pressed in
regular controller
...

It seems like the component mechanisms is ignoring the value of 'status'.

Miguel


Re: [web2py] Re: scripting components

2010-08-13 Thread Miguel Lopes
I wonder if this would also work with block templates -  supposing block
templates are integrated before the header is set.

I remember recently reading about block templates. Have this been integrated
in the reference distribution?

Thank you so much for all the great help.
Miguel

On Fri, Aug 13, 2010 at 4:18 PM, mdipierro  wrote:

> It would be the use of components in plugin_wiki/page pages
>
> ``
> name: oppty_contacts
> 
> ``:widget
>
> in this case you do not need to worry about response.fields.append()
> because the plugin is rendered before it is embedded in view.
>
> On Aug 13, 10:01 am, Miguel Lopes  wrote:
> > Yes your explanation makes perfect sense, and that solves my
> encapsulation
> > problem. Thank you.
> > You mention normal web2py controllers and views, what would the other
> kind
> > be?
> >
> > Miguel
> >
> > On Fri, Aug 13, 2010 at 1:19 PM, mdipierro 
> wrote:
> >
> > > 2) You can include a js in a component
> >
> > > def oppty_contacts():
> > > response.files.append()
> > > ...
> >
> > > and you have not problems with markmin pages.
> >
> > > BUT you will no be able to do
> >
> > >{{=plugin_wiki.widget('oppty_contacts',...)}}
> >
> > > because the response.files.append will be executed after the header is
> > > serialized anyway, if you are using the {{}} syntax that you are
> > > probably using normal web2py controllers actions and views. In this
> > > case you can do
> >
> > > in function:
> >
> > > mycomponent=plugin_wiki.widget('oppty_contacts',...)
> >
> > > in view:
> >
> > > {{=mycomponent}}
> >
> > > Hope this makes sense.
>


Re: [web2py] Re: scripting components

2010-08-13 Thread Miguel Lopes
Yes your explanation makes perfect sense, and that solves my encapsulation
problem. Thank you.
You mention normal web2py controllers and views, what would the other kind
be?

Miguel

On Fri, Aug 13, 2010 at 1:19 PM, mdipierro  wrote:

>
> 2) You can include a js in a component
>
> def oppty_contacts():
> response.files.append()
> ...
>
> and you have not problems with markmin pages.
>
> BUT you will no be able to do
>
>{{=plugin_wiki.widget('oppty_contacts',...)}}
>
> because the response.files.append will be executed after the header is
> serialized anyway, if you are using the {{}} syntax that you are
> probably using normal web2py controllers actions and views. In this
> case you can do
>
> in function:
>
> mycomponent=plugin_wiki.widget('oppty_contacts',...)
>
> in view:
>
> {{=mycomponent}}
>
> Hope this makes sense.
>


[web2py] scripting components

2010-08-13 Thread Miguel Lopes
In order to include scripting in a very dynamic component I'm appending a js
file to the response files of every template that uses the component, such
as:

{{response.files.append(URL(request.application,'static/base_components','view_oppty.js'))}}
{{extend 'layout.html'}}

However, this has the problem of decoupling the scripting from the
component. Although, I find the advantage of leaving the js in its own file
which is convenient for editing and maintenance.
My reading of the web2py Book chapter 13 suggests that the answer would be
to minify the js code and include it in the controller, such as:

def oppty_contacts():
   define var to be used on the template
   ...

response.headers['web2py-component-command']="$('#show_assoc_contact').click(function(event){...);"
   form=...
   return dict(..., form=form)

However I can't get this is to work.

My doubts are:
I wonder if there is a way to couple a scripting file with the component (so
I can enjoy the advantage of having the js in its own file)?
What am I doing wrong in the alternative solution of including the js code
via response.headers?

Miguel


Re: [web2py] using URL() inside a component view

2010-08-10 Thread Miguel Lopes
Txs!
I see the inclusion of request.application makes the URL being rendered with
a .load extension or not. This seems a bit strange.
I wonder if the solution will be stable!
Miguel


On Wed, Aug 11, 2010 at 2:03 AM, Bruno Rocha  wrote:

> I Solved using this way:
>
> URL(request.application,'default','view_detail',args=[rec.contact.id])
>
> .load is not appended to the link.
>
> 2010/8/10 Miguel Lopes 
>
> I'm pretty sure this as been asked, but I can't find it anywhere.
>>
>> I would like to use the URL function to construct a link inside
>> a component view (i.e. views/components/view_x.load). This would be a link
>> to a completely new page, to be loaded in the browser and not in the
>> component div. However, the default behavior is that all links inside a
>> component are trapped and loaded into the same component, thus if I have in
>> the component view:
>>
>> {{
>> rec.contact.name}}
>>
>> This gets translated into:
>> Clockwork Orange
>>
>> And I would like to get:
>> Clockwork Orange
>>
>> How can I achieve this?
>> Txs,
>> Miguel
>>
>
>
>
> --
>
> http://rochacbruno.com.br
>


[web2py] using URL() inside a component view

2010-08-10 Thread Miguel Lopes
I'm pretty sure this as been asked, but I can't find it anywhere.

I would like to use the URL function to construct a link inside
a component view (i.e. views/components/view_x.load). This would be a link
to a completely new page, to be loaded in the browser and not in the
component div. However, the default behavior is that all links inside a
component are trapped and loaded into the same component, thus if I have in
the component view:

{{
rec.contact.name}}

This gets translated into:
Clockwork Orange

And I would like to get:
Clockwork Orange

How can I achieve this?
Txs,
Miguel


Re: [web2py] Re: code organization

2010-08-03 Thread Miguel Lopes
Iceberg,

Thank you.
Maybe I didn't explain what I wanted well, but you understood very well!
Actually the solution is so simple it is embarrassing :-)

Miguel


On Tue, Aug 3, 2010 at 9:51 AM, Iceberg  wrote:

> Don't what you really want. In short, modules organize your functional
> code, but you still need to "expose" them in your controller.
>
> # In controllers/default.py
> def index():
>return {'': DIV( LOAD(url=URL(r=request, f='foo.load')) )}
> def foo():
>return {'': local_import('my_module').my_func()}
>
> # In modules/my_module.py
> def my_func():
>return FORM(...)
>
> Iceberg
>
> On Aug 2, 10:19 pm, Miguel Lopes  wrote:
> > yes I've tried it. local_import does not work. the LOAD function
> signature
> > expects a controller name and function name (defaulting to the
> > request.application), as far as I know it is not possible to pass it a
> > function - at least supplying it a function object does not work.
> >
> > Miguel
> >
> >
> >
> > On Mon, Aug 2, 2010 at 2:51 PM, Bruno Rocha 
> wrote:
> > > Have you tried local_import()?
> > > I really dont know if that will work in your case, Give it a try
> >
> > >http://web2py.com/book/default/chapter/04?search=local_import
> >
> > > 2010/8/2 Miguel Lopes 
> >
> > > I have several functions returning forms in a module file, and started
> > >> experimenting with the LOAD function, but I can figure out how to use
> this
> > >> functions without moving them to the controller. I would prefer to
> keep
> > >> these functions in a module for code organization reasons. I wonder if
> it is
> > >> possible, and if not what solution do you use for code organization?
> >
> > >> Miguel
> >
> > > --
> >
> > >http://rochacbruno.com.br
>


Re: [web2py] Re: Getting Eclipse / Pydev running

2010-08-03 Thread Miguel Lopes
On Tue, Aug 3, 2010 at 2:41 AM, pabloest  wrote:

> Thank you for the extended description.
> This is almost exactly what I had been following.


You welcome. Interesting to know you came up with a similar solution.


> I had skipped the
> arguments partially because I think Eclipse is not taking them. When I
> enter the arguments and then go to the interpreter tab to "see
> resulting command line for the given parameters" (button), they do not
> appear. Other commands do appear, but not what I've entered into the
> arguments tab.  Do yours appear there?
>

Arguments do not appear in the interpreter tab, but they are applied. I you
enter something like   -p 8080 -a ""   in the arguments tab when
you run web2py.py the startup dialog box should not appear. Give it a try. I
find it very convenient not to have the pesky dialog.


>
> Aptana gave the same behavior as Eclipse, but I'm not surprised.
>
> I might try re-downloading web2py's source - perhaps something got
> corrupted.
>

I wouldn't expect this to be related to web2py.

>
> Pablo
>


Re: [web2py] code organization

2010-08-02 Thread Miguel Lopes
yes I've tried it. local_import does not work. the LOAD function signature
expects a controller name and function name (defaulting to the
request.application), as far as I know it is not possible to pass it a
function - at least supplying it a function object does not work.

Miguel

On Mon, Aug 2, 2010 at 2:51 PM, Bruno Rocha  wrote:

> Have you tried local_import()?
> I really dont know if that will work in your case, Give it a try
>
> http://web2py.com/book/default/chapter/04?search=local_import
>
> 2010/8/2 Miguel Lopes 
>
> I have several functions returning forms in a module file, and started
>> experimenting with the LOAD function, but I can figure out how to use this
>> functions without moving them to the controller. I would prefer to keep
>> these functions in a module for code organization reasons. I wonder if it is
>> possible, and if not what solution do you use for code organization?
>>
>> Miguel
>>
>
>
>
> --
>
> http://rochacbruno.com.br
>


[web2py] code organization

2010-08-02 Thread Miguel Lopes
I have several functions returning forms in a module file, and started
experimenting with the LOAD function, but I can figure out how to use this
functions without moving them to the controller. I would prefer to keep
these functions in a module for code organization reasons. I wonder if it is
possible, and if not what solution do you use for code organization?

Miguel


Re: [web2py] Re: Getting Eclipse / Pydev running

2010-08-02 Thread Miguel Lopes
Here's my naif setup - note that this should be exactly the same for Eclipse
or Aptana (Aptana is Eclipse + goodies):

1. Use web2py source.
2. Make sure you have PyDev installed in Eclipse/Aptana.
3. Create a project a PyDev project:
  * this will link to the web2py folder on the file system - so you will
have access to all projects and the web2py installation
  * I call this project "web2py_projects"
  * (if you know what a perspective is in Eclipse, you can use either Aptana
or PyDev perspectives - it's irrelevant).
4. Create a link to the web2py folder in the project: just create a folder
and use the "Advanced >>" button to link to the web2py folder in the file
system

Know you are ready to go!
In general I either duplicate an existing project directly from the file
view in the IDE or I use the web2py web interface to do it.
Note that if you change any web2py files from outside of Eclipse, then you
will have to refresh the project so that the file structure is re-read. This
can be done by selecting the project in the File View and pressing F5.

Debugging with PyDev:
Since we are in development I always run web2py in PyDev's debugging mode
1. Run we2py regularly, set an admin password and stop the server. This is
just so you have a password set in web2py for admin access
2. Open the web2py.py file
3. Select Debug | Debug configurations - under "Python Run" create a new
configuration, name it: "Run web2py" (or something useful):
   * In the Main tab: select the web2py_projects as the "Project" and select
the web2py.py file as the "Main Module"
   * Click "Apply"
   * In the "Arguments" tab type (without the curly braces):  {-p 8080 -a
""}  this will avoid the dialog for starting web2py and will run on
port 8080 with the last password used (you must have set an admin password
previously)
   * Some of the other tabs may be useful, e.g. setting the interpreter
4. When ready click "Debug", and presto web2py is running in PyDev's debug
mode
5. When you wish to debug some code just double click, or "right-click" on
the code editors left margin to set break points. PyDev will automatically
launch the debug perspective.

BTW If you search you can find some info on getting code completion to work
(I have not yet bothered).

HTH,
Miguel


On Mon, Aug 2, 2010 at 6:04 AM, pabloest  wrote:

> Thanks, Christopher and Miguel.
>
> I will try a different port.
> Actually on Wing I started to get a similar error about nothing
> listening (and then an exit). But this was after the web2py pop-up
> where I can enter the port.
> I had just read your replies so I tried port 8080 and that did it.
> Thank you!
>
> I tried again on Eclipse but it won't even get to the point of
> bringing up the web2py window where I can set the port.
>
> I will try Aptana - I believe I already downloaded it.
>
> Pablo
>
>


Re: [web2py] Getting Eclipse / Pydev running

2010-08-01 Thread Miguel Lopes
On Thu, Jul 29, 2010 at 2:38 PM, pabloest  wrote:

> Hi,
>
> I'm having some trouble simply getting started with Eclipse and Pydev
> for web2py development.
> I can't get into a debugging mode with web2py.py and the web server
> will not even start. When I right-click and select Debug As > Python
> Run, I get error messages that say:
> -unexpected error setting up the debugger: socket closed
>

Try a different port. I use Aptana (eclipse based) + PyDev. It seems that
eclipse is occupying the 8000 port, so web2py won't start. Just change the
defaualt web2py port to something like 8080. It should be fine.

HTH,
Miguel


Re: [web2py] load form by its name

2010-08-01 Thread Miguel Lopes
On Sun, Aug 1, 2010 at 9:20 AM, Neveen Adel  wrote:

> Hello,
>
> i have function for example
> def form_1():
>  form =  SQLFORM (_name='form_1')
>
> and i want inside a different function to load this form and insert
> element into it
>
> For example:
>
>  def another_fn(form_name):
>form = # load the form by form Name
>#and then do
>   form[0].element().insert() 
>
>
> Is that valid or not ?
>
> Yes. But you must return form is the creation function, such as:

def reusable_form(maybe_some_args, make_it_more, reusable=True):
form = SQLFORM(maybe_some_args, are_used_here)
# maybe other args can be used for some form manipulation (adding
buttons, changing layout)
return form # this is necessary

Then you can reuse the form at will.
By the way. You don't need to pass the form as an argument, because it will
be available in the context.

Then there is the question of where to store these pre-built forms. In
general I tend to create a model file exclusively  for reusable forms.

Miguel


[web2py] storing a token to identify a service user

2010-07-23 Thread Miguel Lopes
Hi,

How can a token be stored between service calls in order to know a service
is logged in?

Miguel


Re: [web2py] Re: Problem with response.files.append

2010-05-17 Thread Miguel Lopes
OK
WinXP (client and server - LAN)
client IE 6, server: web2py 1.78.2 with SSL - fails
client Firefox 3.6.3, server: web2py 1.78.2 with SSL - fails
client IE 6, server: web2py 1.77.3 no SSL - works
client Firefox 3.6.3, server: web2py 1.77.3 no SSL - works

OSX (client and server - localhost)
client Safari OSX, server: web2py 1.77.3 no SSL - fails
client Firefox 3.6.3 OSX, server: web2py 1.77.3 no SSL - fails
client Safari OSX, server: web2py 1.74.4 no SSL - works
client Firefox 3.6.3 OSX, server: web2py 1.74.4 no SSL - works

This is strange, but I doubled checked!

Miguel


On Mon, May 17, 2010 at 7:55 PM, mdipierro  wrote:

> Summarizing. It always works exept when you run 1.78.x over SSL on XP.
> Didd you check if 1.78.x works without SSL and if it works on other
> platform (Mac, Linux)? Did you check different browsers (although this
> does not look like a browser problem)?
>
> Massimo
>
> On May 17, 1:43 pm, Miguel Lopes  wrote:
> > The net effect is that response.files.append seems to be ignored.
> > The client receives the page but the appended files are missing.
> >
> > On Mon, May 17, 2010 at 7:38 PM, mdipierro 
> wrote:
> > > How does it fail?
> >
> > > On May 17, 1:29 pm, Miguel Lopes  wrote:
> > > > Correction and extra data:
> >
> > > > Fails on Windows XP with 1.78.2 with SSL enabled,
> > > > Works on the same setting with 1.77.3 SSL off.
> >
> > > > On Mon, May 17, 2010 at 7:12 PM, Miguel Lopes  >
> > > wrote:
> > > > > I have an app running smoothly on OSX that fails on Windows XP.
> > > > > I've traced the cause to the use of response.files.append(URL(...))
> in
> > > > > views that extend layout
> >
> > > > > In OSX this works with web2py 1.74.4:
> >
> > > > > {{response.files.append(URL(r=request, c='static/biz',
> > > f='common.js'))}}
> > > > > {{response.files.append(URL(r=request, c='static',
> > > f='dashboard.css'))}}
> > > > > {{response.files.append(URL(r=request,
> c='static/jquery-autocomplete',
> > > > > f='jquery.autocomplete.css'))}}
> > > > > {{response.files.append(URL(r=request,
> c='static/jquery-autocomplete',
> > > > > f='jquery.autocomplete.js'))}}
> >
> > > > > {{extend 'layout.html'}}
> >
> > > > > In Windows XP with both web2py 1.77 and 1.78.2 doesn't work!
> >
> > > > > Miguel
>


Re: [web2py] Re: Problem with response.files.append

2010-05-17 Thread Miguel Lopes
The net effect is that response.files.append seems to be ignored.
The client receives the page but the appended files are missing.


On Mon, May 17, 2010 at 7:38 PM, mdipierro  wrote:

> How does it fail?
>
> On May 17, 1:29 pm, Miguel Lopes  wrote:
> > Correction and extra data:
> >
> > Fails on Windows XP with 1.78.2 with SSL enabled,
> > Works on the same setting with 1.77.3 SSL off.
> >
> > On Mon, May 17, 2010 at 7:12 PM, Miguel Lopes 
> wrote:
> > > I have an app running smoothly on OSX that fails on Windows XP.
> > > I've traced the cause to the use of response.files.append(URL(...)) in
> > > views that extend layout
> >
> > > In OSX this works with web2py 1.74.4:
> >
> > > {{response.files.append(URL(r=request, c='static/biz',
> f='common.js'))}}
> > > {{response.files.append(URL(r=request, c='static',
> f='dashboard.css'))}}
> > > {{response.files.append(URL(r=request, c='static/jquery-autocomplete',
> > > f='jquery.autocomplete.css'))}}
> > > {{response.files.append(URL(r=request, c='static/jquery-autocomplete',
> > > f='jquery.autocomplete.js'))}}
> >
> > > {{extend 'layout.html'}}
> >
> > > In Windows XP with both web2py 1.77 and 1.78.2 doesn't work!
> >
> > > Miguel
>


[web2py] Re: Problem with response.files.append

2010-05-17 Thread Miguel Lopes
Correction and extra data:

Fails on Windows XP with 1.78.2 with SSL enabled,
Works on the same setting with 1.77.3 SSL off.


On Mon, May 17, 2010 at 7:12 PM, Miguel Lopes  wrote:

> I have an app running smoothly on OSX that fails on Windows XP.
> I've traced the cause to the use of response.files.append(URL(...)) in
> views that extend layout
>
> In OSX this works with web2py 1.74.4:
>
> {{response.files.append(URL(r=request, c='static/biz', f='common.js'))}}
> {{response.files.append(URL(r=request, c='static', f='dashboard.css'))}}
> {{response.files.append(URL(r=request, c='static/jquery-autocomplete',
> f='jquery.autocomplete.css'))}}
> {{response.files.append(URL(r=request, c='static/jquery-autocomplete',
> f='jquery.autocomplete.js'))}}
>
> {{extend 'layout.html'}}
>
> In Windows XP with both web2py 1.77 and 1.78.2 doesn't work!
>
> Miguel
>


[web2py] Problem with response.files.append

2010-05-17 Thread Miguel Lopes
I have an app running smoothly on OSX that fails on Windows XP.
I've traced the cause to the use of response.files.append(URL(...)) in views
that extend layout

In OSX this works with web2py 1.74.4:

{{response.files.append(URL(r=request, c='static/biz', f='common.js'))}}
{{response.files.append(URL(r=request, c='static', f='dashboard.css'))}}
{{response.files.append(URL(r=request, c='static/jquery-autocomplete',
f='jquery.autocomplete.css'))}}
{{response.files.append(URL(r=request, c='static/jquery-autocomplete',
f='jquery.autocomplete.js'))}}

{{extend 'layout.html'}}

In Windows XP with both web2py 1.77 and 1.78.2 doesn't work!

Miguel


Re: [web2py] Re: SSL Error on windows [SOLVED] [SOLVED]

2010-05-13 Thread Miguel Lopes
On Thu, May 13, 2010 at 9:02 PM, Timothy Farrell  wrote:

>  While Rocket supports listening on multiple sockets, web2py does not.  You
> will need to run two separate instances of web2py (one for SSL, one
> unencrypted) to do what you are asking.
>
> -tim
>
> Txs for the reply. Always nice to know the reason.
Keeping with Massimo's suggestion I added solved to the post!
LOL


>
> On 5/13/2010 1:40 PM, Miguel Lopes wrote:
>
>
>
> On Wed, May 12, 2010 at 7:45 PM, Timothy Farrell wrote:
>
>> This is the error that Jon Lundell's guys found already.  Note that it's
>> trying to connect to port 8000 as HTTP.  Connect as HTTPS and it should
>> work.
>>
>> Also try upgrading to trunk, that should issue a "400 Bad Request".
>>
>> -tim
>>
>>   Confirmed.
> Updated from trunk to 1.77.3 and if attempting to access the server in http
> (instead of https) server issues console warning like you said.
>
> Since I'm on a LAN I installed SSL as a learning experience and to access
> the admin interface anywhere on the LAN. However, now that I have web2py
> running with SSL, even the applications must be accessed via SSL. I expected
> that only the admin would require SSL. Is this also a matter of
> configuration or is there some other reason? I do have very little knowledge
> on networks and deployment in general. So I wonder what is the reason.
>
> Miguel
>
>
>


Re: [web2py] web2pyslices source code

2010-05-13 Thread Miguel Lopes
Thanks for sharing.
Miguel

On Thu, May 13, 2010 at 4:50 PM, mr.freeze  wrote:

> This has been updated for anyone interested:
> http://www.web2pyslices.com/main/static/share/web2py.app.web2pyslices.w2p
>
>


Re: [web2py] Re: SSL Error on windows [SOLVED]

2010-05-13 Thread Miguel Lopes
On Wed, May 12, 2010 at 7:45 PM, Timothy Farrell  wrote:

> This is the error that Jon Lundell's guys found already.  Note that it's
> trying to connect to port 8000 as HTTP.  Connect as HTTPS and it should
> work.
>
> Also try upgrading to trunk, that should issue a "400 Bad Request".
>
> -tim
>
> Confirmed.
Updated from trunk to 1.77.3 and if attempting to access the server in http
(instead of https) server issues console warning like you said.

Since I'm on a LAN I installed SSL as a learning experience and to access
the admin interface anywhere on the LAN. However, now that I have web2py
running with SSL, even the applications must be accessed via SSL. I expected
that only the admin would require SSL. Is this also a matter of
configuration or is there some other reason? I do have very little knowledge
on networks and deployment in general. So I wonder what is the reason.

Miguel


Re: [web2py] Re: SSL Error on windows

2010-05-12 Thread Miguel Lopes
On Tue, May 11, 2010 at 9:41 PM, mr.freeze  wrote:

> Do you have the win32 extension for Python installed?
> http://sourceforge.net/projects/pywin32/
>
> On May 11, 3:33 pm, Miguel Lopes  wrote:
>  > On Tue, May 11, 2010 at 7:54 PM, mdipierro 
> wrote:
> > > This is concerns me more:
> >
> > > WARNING:root:WEB2PY CRON: Disabled because no file locking
> >
> > > what os are you using?
> >
> > Windows XP I can check the flavour and service pack tomorrow.
>

I confirm that this error disapers when pywin32 extensions are installed. If
this is the case, then maybe pywin32 should be listed as a dependency.

Unfortunately the SSL problems are an independent issue. Now I get:

C:\Programas\web2py>C:\Python26\python web2py.py -L options
web2py Enterprise Web Framework
Created by Massimo Di Pierro, Copyright 2007-2010
Version 1.77.3 (2010-04-20 02:48:54)
Database drivers available: SQLite3, PostgreSQL
Starting hardcron...
please visit:
http://Tecnicon-s3:8000 <http://tecnicon-s3:8000/>
use "kill -SIGTERM 832" to shutdown the web2py server
ERROR:Rocket.Errors.ThreadPool:Traceback (most recent call last):
  File "C:\Programas\web2py\gluon\rocket.py", line 300, in start
self._threadpool.queue.put((l.accept(),
  File "C:\Python26\lib\ssl.py", line 326, in accept
suppress_ragged_eofs=self.suppress_ragged_eofs),
  File "C:\Python26\lib\ssl.py", line 118, in __init__
self.do_handshake()
  File "C:\Python26\lib\ssl.py", line 293, in do_handshake
self._sslobj.do_handshake()
SSLError: [Errno 1] _ssl.c:480: error:1407609C:SSL
routines:SSL23_GET_CLIENT_HEL
LO:http request
ERROR:Rocket.Errors.ThreadPool:Traceback (most recent call last):
  File "C:\Programas\web2py\gluon\rocket.py", line 300, in start
self._threadpool.queue.put((l.accept(),
  File "C:\Python26\lib\ssl.py", line 326, in accept
suppress_ragged_eofs=self.suppress_ragged_eofs),
  File "C:\Python26\lib\ssl.py", line 118, in __init__
self.do_handshake()
  File "C:\Python26\lib\ssl.py", line 293, in do_handshake
self._sslobj.do_handshake()
SSLError: [Errno 1] _ssl.c:480: error:1407609C:SSL
routines:SSL23_GET_CLIENT_HEL
LO:http request
ERROR:Rocket.Errors.ThreadPool:Traceback (most recent call last):
  File "C:\Programas\web2py\gluon\rocket.py", line 300, in start
self._threadpool.queue.put((l.accept(),
  File "C:\Python26\lib\ssl.py", line 326, in accept
suppress_ragged_eofs=self.suppress_ragged_eofs),
  File "C:\Python26\lib\ssl.py", line 118, in __init__
self.do_handshake()
  File "C:\Python26\lib\ssl.py", line 293, in do_handshake
self._sslobj.do_handshake()
SSLError: [Errno 1] _ssl.c:480: error:1407609C:SSL
routines:SSL23_GET_CLIENT_HEL
LO:http request

Perhaps I should try a CherryPy based release in order to exclude Rocket as
a possible cause.

Miguel


Re: [web2py] Looping in the browser?

2010-05-11 Thread Miguel Lopes
I suppose you want to return several positions that match (domain ==
session.target_domain) then you must not use return (as it escapes the loop
and exits the function scope). You should collect all your matches in a list
and the return the list in the end. Something like:

def check():
   result_list = []
   for target_keyword in session.keywords.split(','):
  ...
  ...
  ...
  for idx, res in enumerate(results):
 ...
 ...
 if domain == session.target_domain:
a_str = "Your google position is %d for keyword '%s' on domain
%s" \
% (idx+1, target_keyword,
session.target_domain)
result_list.append(a_str)

   # Now you can return the list
   return result_list

  HTH


On Wed, May 12, 2010 at 2:34 AM, Andrew Evans wrote:

> Hello I have a problem. I have code written for web2py that has two
> functions, the problem is in the looping of the second function. it
> only executes the loop once. Is there anyway I can continue looping
>
> def check():
>for target_keyword in session.keywords.split(','):
>gs = GoogleSearch(target_keyword)
>gs.results_per_page = int(session.results_per_page_num)
>results = gs.get_results()
>for idx, res in enumerate(results):
>parsed = urlparse(res.url)
>domain = mk_nice_domain(parsed.netloc)
>if domain == session.target_domain:
>return dict(search=build("Your google position is %d
> for keyword '%s' on domain %s" % (idx+1,
>target_keyword, session.target_domain)))
>
> Thanks if you can help
>
>


Re: [web2py] Re: jsonrpc call failure

2010-05-11 Thread Miguel Lopes
On Wed, May 12, 2010 at 1:48 AM, mdipierro  wrote:

> Can you describe what happens in the uncessful test? Do you see a new
> ticket file being generate in the errors/ folder? What does it say?
>
>
 Upps! Sorry false alarm. I was calling the remote server with the port and
this was causing the connection to be refused. Unfortunately I've been doing
variations on this for about 20 minutes or so!!!
Sorry for this and Txs for the help!
Miguel


[web2py] jsonrpc call failure

2010-05-11 Thread Miguel Lopes
I've managed to successfully call on a jsonrpc service using localhost.
However I cannot replicate this with a remote server.
For the client I'm using jsonrpc at the Python prompt:

>>> sv = ServiceProxy('http://127.0.0.1:8000/testapp/default/call/jsonrpc')
>>> sv.getRequests()
['json test']
>>>

The very standard controller is:
@service.jsonrpc
def getRequests():
return ["json test"]

def call():
session.forget()
return service()

Notably I'm running web2py 1.74.4 on OSX on the localhost - the successful
test
And web2py 1.65.5 on Debian on the remote server - the unsuccessful test

I believe 1.65.5 supports jsonrpc and that this is served by default on port
8000. Am I wrong? What am I missing?

Miguel


Re: [web2py] Re: SSL Error on windows

2010-05-11 Thread Miguel Lopes
On Tue, May 11, 2010 at 9:41 PM, mr.freeze  wrote:

> Do you have the win32 extension for Python installed?
> http://sourceforge.net/projects/pywin32/
>
>
No. Maybe that's he problem.
Tomorrow I'll re-test the thing with pywin32 installed.
Miguel


Re: [web2py] Re: SSL Error on windows

2010-05-11 Thread Miguel Lopes
On Tue, May 11, 2010 at 7:54 PM, mdipierro  wrote:

> This is concerns me more:
>
> WARNING:root:WEB2PY CRON: Disabled because no file locking
>
> what os are you using?
>
>
Windows XP I can check the flavour and service pack tomorrow.


Re: [web2py] Review my web2py app: Radbox.me

2010-05-11 Thread Miguel Lopes
Very cool.
Congratulations,
Miguel


Re: [web2py] Do you use web2py in your company?

2010-05-11 Thread Miguel Lopes
On Mon, May 10, 2010 at 10:09 PM, mdipierro  wrote:

> Anthony made some good points:
> http://groups.google.com/group/web2py/msg/a40b27807edc8603
>
> For now let's concentrate on one of them for now. If you have
> developed software in web2py that you use internally in your company
> but you cannot release it open source, would you let us know? Can you
> tell us what is the software for? Could you provide a screenshot? Can
> we quote the name of the company?
>
> Massimo
>

Presently I'm in the process of deploying a simple crm system in my company.
In terms of layout it's very much of a Highrise clone. But the functionality
is very very different since in an oportunity we track several would be
purchasers who are bidding for the same project. Currently we also cover
much less functionality as we are restricted to following opportunities,
contacts, and their interactions.
 I'm not sure if it is ok. But if it is I'll be happy to provide a
screenshoot - although I'm pretty sure there is better work out there!

Miguel


[web2py] SSL Error on windows

2010-05-11 Thread Miguel Lopes
I followed the www.web2py.com/AlterEgo/default/show/140 in order to generate
a self-certified ssl key using OpenSSL for windows(
http://www.slproweb.com/products/Win32OpenSSL.html)

The certificates are in the web2py folder

Running web2py I get this error:

C:\Programas\web2py>c:\python26\python web2py.py -c server.crt -k server.key
-a "" -i **.*.*.*** -p 8080
WARNING:root:no file locking
web2py Enterprise Web Framework
Created by Massimo Di Pierro, Copyright 2007-2010
Version 1.77.3 (2010-04-20 02:48:54)
Database drivers available: SQLite3, PostgreSQL
Starting hardcron...
WARNING:root:WEB2PY CRON: Disabled because no file locking
please visit:
http://**.*.*.***:8080
use "kill -SIGTERM 396" to shutdown the web2py server
WARNING:root:WEB2PY CRON: Disabled because no file locking
ERROR:Rocket.Errors.ThreadPool:Traceback (most recent call last):
  File "C:\Programas\web2py\gluon\rocket.py", line 300, in start
self._threadpool.queue.put((l.accept(),
  File "c:\python26\lib\ssl.py", line 326, in accept
suppress_ragged_eofs=self.suppress_ragged_eofs),
  File "c:\python26\lib\ssl.py", line 118, in __init__
self.do_handshake()
  File "c:\python26\lib\ssl.py", line 293, in do_handshake
self._sslobj.do_handshake()
SSLError: [Errno 1] _ssl.c:480: error:1407609C:SSL
routines:SSL23_GET_CLIENT_HEL
LO:http request

Any ideas?
Miguel


Re: [web2py] Re: New to web app development -- is web2py a good choice

2010-05-08 Thread Miguel Lopes
Yeah! shows how conservative I am :-)


On Fri, May 7, 2010 at 10:10 PM, mdipierro  wrote:

> > Massimo already answered this. But I've been using web2py from the
> > beginning, have a site running on it with absolutely no problems.
> Upgrading
> > to a new release is as simple as (well just import you old app in a new
> > release) -
>
> No. It is simpler. There is a button in admin on the right [upgrade
> now]. you do not need to download or unzip anything any more.
>


Re: [web2py] Re: Custom widgets and form errors

2010-05-07 Thread Miguel Lopes
On Fri, May 7, 2010 at 3:42 PM, Miguel Lopes  wrote:

>
>
> On Fri, May 7, 2010 at 3:29 PM, mdipierro  wrote:
>
>> Errors in form.errors (which is a Storage object and extends a dict).
>> Perhaps they can be displayed somewhere else?
>>
>>
> Yes of course. But the point is that if the extension mechanism for widgets
> could perhaps be polished so that it is not limited to the set of elements
> that the framework expects. Given the benefit of encapsulating code in the
> widget I believe this is worthwhile.
>
> Also, this means that once a widget that breaks this functionality is
> included then if we want to preserve look and feel across the app we must
> change all form error displaying functionality everywhere!
>

It also breaks the validation system (except if the validator is declared in
the requires argument of the inner widget).

>
> Miguel
>
>
>
>
>> On May 7, 7:26 am, Miguel Lopes  wrote:
>> > Encapsulating javascript code within some widgets is a good solution
>> when
>> > the functionality is generic. This widgets act like drop-in components.
>> >
>> > Two examples by mr.freeze are (txs for the nice concept mr.freeze):
>> http://www.web2pyslices.com/main/slices/take_slice/24http://www.web2pyslices.com/main/slices/take_slice/66
>> >
>> > However, the solution proposed by mr.freeze breaks the form mechanism
>> for
>> > displaying errors, since it encapsulates the script and input elements
>> in a
>> > div element. The problem is that form validation is expecting some an
>> input
>> > type widget (input, select, checkbox, ...) and not a div element. The
>> > consequence is that although the field is validated, errors are not
>> > displayed.
>> >
>> > I'm not familiar enough with web2py's code base. Perhaps someone as a
>> > solution for this. If there is no solution, I suppose some solution
>> could be
>> > devised that allows for encapsulating scripting within the widget.
>> Perhaps
>> > inheriting from the standard div tag and creating an extended div that
>> knows
>> > how to deal with errors?
>> >
>> > Miguel
>>
>
>


Re: [web2py] Idea/question

2010-05-07 Thread Miguel Lopes
On Fri, May 7, 2010 at 4:06 PM, blackthorne  wrote:

> Is it possible to customize the order by which models are loaded/
> imported in a web2py application?
> Are they loaded by alphabetical order?
>
>
Yes. They are loaded alphabetically.


> It comes to my mind an idea of an interface for this based on dragging
> options like this http://tool-man.org/examples/sorting.html .
>
> Thanks,
> Best Regards
>


Re: [web2py] Re: Custom widgets and form errors

2010-05-07 Thread Miguel Lopes
On Fri, May 7, 2010 at 3:29 PM, mdipierro  wrote:

> Errors in form.errors (which is a Storage object and extends a dict).
> Perhaps they can be displayed somewhere else?
>
>
Yes of course. But the point is that if the extension mechanism for widgets
could perhaps be polished so that it is not limited to the set of elements
that the framework expects. Given the benefit of encapsulating code in the
widget I believe this is worthwhile.

Also, this means that once a widget that breaks this functionality is
included then if we want to preserve look and feel across the app we must
change all form error displaying functionality everywhere!

Miguel




> On May 7, 7:26 am, Miguel Lopes  wrote:
> > Encapsulating javascript code within some widgets is a good solution when
> > the functionality is generic. This widgets act like drop-in components.
> >
> > Two examples by mr.freeze are (txs for the nice concept mr.freeze):
> http://www.web2pyslices.com/main/slices/take_slice/24http://www.web2pyslices.com/main/slices/take_slice/66
> >
> > However, the solution proposed by mr.freeze breaks the form mechanism for
> > displaying errors, since it encapsulates the script and input elements in
> a
> > div element. The problem is that form validation is expecting some an
> input
> > type widget (input, select, checkbox, ...) and not a div element. The
> > consequence is that although the field is validated, errors are not
> > displayed.
> >
> > I'm not familiar enough with web2py's code base. Perhaps someone as a
> > solution for this. If there is no solution, I suppose some solution could
> be
> > devised that allows for encapsulating scripting within the widget.
> Perhaps
> > inheriting from the standard div tag and creating an extended div that
> knows
> > how to deal with errors?
> >
> > Miguel
>


Re: [web2py] New to web app development -- is web2py a good choice

2010-05-07 Thread Miguel Lopes
On Thu, May 6, 2010 at 6:37 AM, Anthony  wrote:

> I am brand new to web application development, and I'm looking for a
> good web framework to learn in order to build a new web application
> (sort of a personal task/project management system). I want it to look
> (and act) like a serious, polished, state-of-the-art Web 2.0 site/app
> (i.e., not amateurish or out-dated). I've got some experience with
> website building, HTML, CSS, and a little javascript. I don't have any
> experience with server-side coding, but I do have general programming
> experience (i.e., not web/internet related) as well as some experience
> with relational databases and SQL.
>

Server side code in web2py is all Python. This makes it very easy to learn
and use. The DAL (Database Abstraction Layer) is very easy to use (but you
must read about it, www.web2py.com/book is more than enough to get up to
speed. The templating code is also pure Python (with very few little
twists). Note that you can use other ORMs or templating engines, if you
which (loosing some benefits though).


>
> I'm looking for a framework that will be relatively easy to learn,
> though I'm just as concerned with how easy it is to go through the
> learning process (i.e., find well-organized documentation, tutorials,
> examples, community support, etc.) as with the conceptual simplicity/
> easiness of the framework itself (i.e., I don't mind learning
> something hard if I've got good learning resources).
>

Web2py makes as easy as py!
There have been some issues about spread documentation in the past. But
since the book went online (the same book that is published) everyone got a
premier resource for most questions. Other relevant sources are:

http://www.web2py.com/book
http://wiki.web2py.com/Home
http://www.web2py.com/examples/default/examples
http://www.web2py.com/AlterEgo/
http://www.web2pyslices.com/
http://web2py.com/appliances/
http://web2py.com/plugins/
http://www.web2py.com/examples/static/epydoc/

Don't forget this list :-)
If you google you also find other peoples sites and blogs that are sometimes
useful.



>
> Also, rather than creating everything from scratch, I'm hoping to rely
> as much as possible on existing libraries, plug-ins, applications,
> examples, etc. So, a framework that's compatible with as large a
> universe as possible of existing solutions would be ideal. I'm also
> planning to link to various web service API's (e.g., Google Calendar).
>

web2py comes with jQuery bundled in. But you can easily replace it for
another ajax framework. But you can take advantage of other solutions. You
can integrate Pyjamas, Flex, YUI, etc... Most of these have some example
(most likely in one or more of the links supplied above).


> From what I've read, web2py sounds like a great framework --
> comprehensive, well-integrated, easy to set up, learn, and deploy,
> etc.


A nice thing is that it is pretty easy and simple to make something with
existing resources and then extend these as you upgrade or polish up your
solution. For example, Validators will solve most of your database and Form
validation demands, but it is very example to come up with your own
validator for, per example, validating an autocomplete widget (which you can
develop or use from an existing library).


> However, although it sounds good on paper, I haven't yet found a
> single site built with web2py that looks all that impressive (at least
> superficially). It's easy to find quite a number of sophisticated and
> impressive looking sites/apps built with Ruby on Rails and Django, but
> I haven't seen anything remotely comparable based on web2py. I'm
> wondering why the disparity. Is it simply that web2py is a relative
> newcomer and has a small user base, or does web2py have some inherent
> limitations that make it less than ideal for building polished, larger
> scale web apps? In other words, could a site like Basecamp
> (www.basecamphq.com) be built just as easily with web2py as with ROR,
> or is web2py not really suited for that level of development?
>

Yes, definitively. I'm in the process of finishing something similar for an
intranet.
Regarding scalability, evidence suggests that web2py is more scalable than
most solutions.


>
> I'm also wondering about the long term viability of web2py. I don't
> want to adopt a framework that ends up fizzling out in a couple years.
> Is web2py on an upward trajectory, or is its future uncertain? For
> example, I notice that the web2py-developers group has only about one
> tenth as many members as even the Pylons and TurboGears developer
> groups (and one one hundreth as many as ROR and Django). Is web2py too
> dependent on just one or two key developers who may lose interest over
> time?
>

Massimo already answered this. But I've been using web2py from the
beginning, have a site running on it with absolutely no problems. Upgrading
to a new release is as simple as (well just import you old app in a new
release) - you cannot over estimate the v

Re: [web2py] Top 3 web2py features

2010-05-07 Thread Miguel Lopes
+1 * (Works out of the box) All in one packages with no dependencies and no
config files
+1 * Backward compatibility
* Very easy to extend (like Python fits my brain)

Miguel



On Thu, May 6, 2010 at 4:18 PM, Álvaro Justen [Turicas] <
alvarojus...@gmail.com> wrote:

> Hi folks,
> I'm writing an article to a brazillian technology magazine about
> web2py but I have limited space, so I need to write what are the most
> important and kill-features of the framework.
> I've opened this thread to listen to you, users, what do you think
> that are the better features, the features you really like or use so
> much in web2py.
> So, please, each of you, prioritize your list and show me the top 3
> features you like.
>
> Thanks,
> --
> Álvaro Justen - Turicas
>  http://blog.justen.eng.br/
>  21 9898-0141
>


[web2py] Custom widgets and form errors

2010-05-07 Thread Miguel Lopes
Encapsulating javascript code within some widgets is a good solution when
the functionality is generic. This widgets act like drop-in components.

Two examples by mr.freeze are (txs for the nice concept mr.freeze):
http://www.web2pyslices.com/main/slices/take_slice/24
http://www.web2pyslices.com/main/slices/take_slice/66

However, the solution proposed by mr.freeze breaks the form mechanism for
displaying errors, since it encapsulates the script and input elements in a
div element. The problem is that form validation is expecting some an input
type widget (input, select, checkbox, ...) and not a div element. The
consequence is that although the field is validated, errors are not
displayed.

I'm not familiar enough with web2py's code base. Perhaps someone as a
solution for this. If there is no solution, I suppose some solution could be
devised that allows for encapsulating scripting within the widget. Perhaps
inheriting from the standard div tag and creating an extended div that knows
how to deal with errors?

Miguel


Re: [web2py] Re: Previous location

2010-05-03 Thread Miguel Lopes
On Mon, May 3, 2010 at 11:08 PM, Jonathan Lundell wrote:

> web2py probably isn't setting referer on a redirect, and if it did, you'd
> have to interpret the URL.


No. If I have no redirect and call a location with no args the referer is
not set when I arrive at web2py's default "Internal error" page. Which is
okay because the standard says referer is optionally set by the client.


> How about putting the previous location in session before you redirect?
>

That works on some instances, but not for controlling for the wrong number
or the wrong parameters. A concrete example:

1. Currently in www.domain.com/a/c/f/arg1
2. User edits address bar and presses enter (removed arg1):
www.domain.com/a/c/f/ 
3. The called action:

def f():
if not request.args:
redirect(request.last_location) # including args

Perhaps someone knows of an alternative way to accomplish the same?

Miguel


Re: [web2py] Re: Previous location

2010-05-03 Thread Miguel Lopes
request.env.http_referer is not working for me.
I checked (http://www.w3.org/Protocols/HTTP/HTRQ_Headers.html#z14) and the
referer is optionally set by the client. So we can not take it for granted.

Miguel

On Mon, May 3, 2010 at 10:45 PM, mr.freeze  wrote:

> I'm not sure if it's reliable or safe but request.env.http_referer
> might be what you're looking for.
>
> On May 3, 4:39 pm, Miguel Lopes  wrote:
> > Is there a way to find the previous location / address in an action?
> >
> > For example:
> > Currently inwww.domain.com/a/c/f/arg1
> > Follow some link to action_x
> >
> > def action_x:
> >   if something_is_wrong:
> > redirect(request.last_location) # including args
> >   ...
> >
> > My goal is to send the user to the page is comming from in case he calls
> an
> > action with a incorrect or the wrong parameters.
> >
> > Txs,
> > Miguel
>


[web2py] Previous location

2010-05-03 Thread Miguel Lopes
Is there a way to find the previous location / address in an action?

For example:
Currently in www.domain.com/a/c/f/arg1
Follow some link to action_x

def action_x:
  if something_is_wrong:
redirect(request.last_location) # including args
  ...

My goal is to send the user to the page is comming from in case he calls an
action with a incorrect or the wrong parameters.

Txs,
Miguel


Re: [web2py] Question about web2py license

2010-02-22 Thread Miguel Lopes
On Mon, Feb 22, 2010 at 7:06 PM, Thadeus Burgess wrote:

> This has come up in the past, the topics on this subject are in the
> google group if the search would actually work I would share the links
> to the posts.
>

I've searched too, but what I've found in the group was, in my opinion,
unclear regarding leasing application usage.
...

>
> You can use your app as a SaaS... your not distributing web2py your
> using web2py.
>

This clarifies it for me. It seems that is really the idea I was missing
(usage).
Thanks Thadeus for the clarification.

Miguel

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



Re: [web2py] Question about web2py license

2010-02-22 Thread Miguel Lopes
On Mon, Feb 22, 2010 at 9:46 AM, Kuba Kucharski wrote:

> I think short answer is this is allowed.
>
> http://osdir.com/ml/web2py/2009-09/msg01859.html
>
> --
> Kuba
>
>
You are right. But I still have doubts.
The way I see it if company X is selling access to some SaaS application.
Let's say an on-line personal finance manager, and changes nothing in the
web2py code:
* it is not redistributing anything (web2py or app)
* It is not claiming to have built web2py
* It is charging money for usage of the personal finance functionality.

Is it clear to the user it's not charging money for the framework? I think
so. Because, from the user's point of view, it seems irrelevant which is the
underlying framework.

Let's say that company X contracted someone (me? :-) to develop their app.
For company X it's clear that web2py is GPL'ed that they are only paying for
the app code.

I'm not a lawyer and I suppose most of you are not too, but what is your
view on this.

Also, I would like to mention that I addressed this post to Massimo because,
being the original author, I suppose he his in a good position to clarify
this question. But I think, this could be a relevant subject to other people
in the community.

Miguel

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



[web2py] Question about web2py license

2010-02-22 Thread Miguel Lopes
Hello Massimo,

I wonder if web2py's license would allow for a SaaS kind of application?

By SaaS I mean access to the site (web app) would be paid for. In practice
end users would pay a fee for accessing the site functionality. This seems
very, very borderline to me. I know you are not laywers. But would this be
possible?

br,
Miguel

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



Re: [web2py] New site in web2py

2010-01-29 Thread Miguel Lopes
There's some problem with the "noticia" view since the html of the news body
is rendering as text.

Congratulations on the site. Nice icon set. Is it opensource / free?

Miguel

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



Re: [web2py] Re: Using XMLRPC to update data via AJAX call?

2010-01-20 Thread Miguel Lopes
On Wed, Jan 20, 2010 at 4:57 PM, Stefan wrote:

> Thanks for the heads up!
>
> On Jan 20, 10:09 am, mdipierro  wrote:
> > The way the web normally works is that requests are initiated by the
> > client, not by the server.
> >
> > To have the server trigger and action in the client without some kind
> > of timed keepalive signal from the client requires having a web server
> > embedded in the javascript of the page or using something called Comet
> > (http://en.wikipedia.org/wiki/Comet_%28programming%29)
> >
> > None of these solutions is too easy.  think a JS keepalive is the
> > simpler solution.
> >
>

Hi Stefan,

What you are looking for is definitively a push to the client (a.k.a. comet,
HTTP server push, etc.). But in the end it really boils down to how strong
is your requisite of having the data pushed to the client.

In my opinion there's some hipe associated with this. It also really
impresses people :-) But, either realtime is really critical (which is not
very common with web-based apps), or if it isn't, then it can be delegated
to the user the responsability of fetching new data. This again depends on
the app. Actually not even most desktop apps have records updated when
someone other client changes a record(s) on the server. This also poses
questions about record locking and data integrity.

Are decisions being made at the second, or is it necessary to make sure that
the latest data is also a part of the analysis? This second criteria is not
really asking for Comet. Also, are users leaving the page open for a long
time or are they querying the server when they need the data? Are there many
users changing the same data at the same time? Is there a period of time
that can be established for the validity of client data? That is when does
client data become sour? If you can establish such a period, then you can
have the page periodically check the server, or even simpler, just
displaying a pop-up with a button when the period expires.

Perhaps you can get along without comet, or perhaps you really need it.
Anyway, if someone comes up with some general comet like solution to web2py,
then it would be a nice plug-in or something.
HTH,
Miguel
-- 

You received this message because you are subscribed to the Google Groups "web2py-users" group.

To post to this group, send email to web...@googlegroups.com.

To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/web2py?hl=en.



Re: [web2py] Re: boolean field not updated

2010-01-19 Thread Miguel Lopes
On Mon, Jan 18, 2010 at 7:46 AM, mdipierro  wrote:

> By custom you mean {{=form.custom.widget.field}} or something else?
>
> That's what I mean.
if I replace the custom form with a regular form everything works fine.

Miguel
-- 

You received this message because you are subscribed to the Google Groups "web2py-users" group.

To post to this group, send email to web...@googlegroups.com.

To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/web2py?hl=en.



[web2py] boolean field not updated

2010-01-17 Thread Miguel Lopes
With crud when using a custom form boolean fields are not being updated.
If using the default form booleans get updated.

Leopard
web2py source 1.74.4
db SQLite
MacPython 2.5.4

Miguel
-- 

You received this message because you are subscribed to the Google Groups "web2py-users" group.

To post to this group, send email to web...@googlegroups.com.

To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/web2py?hl=en.



  1   2   >