[web2py] Re: new plugin - web2py Form Wizard - PowerFormWizard

2011-06-30 Thread mart
very cool!!! :)

On Jun 30, 2:41 am, niknok  wrote:
> In the validation example,  I entered a single character in the Bio
> and was allowed to proceed to the next field despite the
> db.person.bio.requires = IS_LENGTH(minsize=5, maxsize=200). You  made
> a note about "Client side validation is not supposed to validate
> everything!", is this included in that exception?
>
> A few suggestions:
> * How about using "description" or "details" instead of the "legend"
> keyword at it seems to be more appropriate for said function.
>
> • As default behavior, instead of the default "X" errorImage beside
> the step title, how about using an exclamation point icon to indicate
> that this step needs attention and then in the specific field with an
> error use the "X" icon instead.
>
> The other day you answered my query re modal windows with a reference
> to easyframework.com + web2py.
>
> I pray that you have plans of adding that feature to your
> PowerFormWizard Plugin (or perhaps turning this into a "PowerForms"
> plugin to truly enable feature-full forms in Web2py?
>
> Cheers and many thanks for your many contributions to the web2py
> community.
>
> /r
> Nik
>
> On Jun 29, 10:33 pm, Bruno Rocha  wrote:
>
>
>
>
>
>
>
> > Hi,
>
> > I just created a new plugin for stepped form wizards.
>
> > I made it last night, so it is not tested very well, I would like your help
> > to test it.
>
> > web2py PowerFormWizard Plugin - based on Jquery Stepy
>
> > - Steps
> > - Customizable titles
> > - Server side validation
> > - Client side validation (with jquery validate)
> > - Custom css
> > - JS Callbaks
> > - Error images
>
> > Take a look:http://labs.blouweb.com/powerformwizard
>
> > This plugin is the second plugin of blouweb PowerPlugins, I am now starting
> > the third one which I hope to have the first version soon.
>
> >http://labs.blouweb.com
>
> > Suggestions, testers, issues, contributions etc on 
> > bitbucket:https://bitbucket.org/rochacbruno/powerformwizard
>
> > Hope it helps someone!
>
> > Thanks.
>
> > --
> > Bruno Rocha
> > [ About me:http://zerp.ly/rochacbruno]
> > [ Aprenda Python: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] Invalid view in 1.97.1

2011-06-30 Thread Gary Herron

On 06/29/2011 10:51 PM, pbreit wrote:

Or this if you can get by with them only being available on "localhost":

# by default give a view/generic.extension to all actions from localhost
# none otherwise. a pattern can be 'controller/function.extension'
response.generic_patterns = ['*'] if request.is_local else []


I see.  This is a nice solution.  Thanks.

I'm curious to know what is the security risk being avoided here.  I 
vaguely remember it being discussed here -- time to search the archives 
I guess.


--
Gary Herron, PhD.
Department of Computer Science
DigiPen Institute of Technology
(425) 895-4418



[web2py] Re: new plugin - web2py Form Wizard - PowerFormWizard

2011-06-30 Thread niknok
Clarification regarding the bio field with requires. It does let me
proceed to the next step, but will not be allowed to submit the data
after validation unless i meet the requires statement.

A bit confusing since some fields will allow me to move to next step.

One more thing, is there going to be an equivalent for
SQLFORM.factory?



On Jun 30, 2:41 pm, niknok  wrote:
> In the validation example,  I entered a single character in the Bio
> and was allowed to proceed to the next field despite the
> db.person.bio.requires = IS_LENGTH(minsize=5, maxsize=200). You  made
> a note about "Client side validation is not supposed to validate
> everything!", is this included in that exception?
>
> A few suggestions:
> * How about using "description" or "details" instead of the "legend"
> keyword at it seems to be more appropriate for said function.
>
> • As default behavior, instead of the default "X" errorImage beside
> the step title, how about using an exclamation point icon to indicate
> that this step needs attention and then in the specific field with an
> error use the "X" icon instead.
>
> The other day you answered my query re modal windows with a reference
> to easyframework.com + web2py.
>
> I pray that you have plans of adding that feature to your
> PowerFormWizard Plugin (or perhaps turning this into a "PowerForms"
> plugin to truly enable feature-full forms in Web2py?
>
> Cheers and many thanks for your many contributions to the web2py
> community.
>
> /r
> Nik
>
> On Jun 29, 10:33 pm, Bruno Rocha  wrote:
>
>
>
>
>
>
>
> > Hi,
>
> > I just created a new plugin for stepped form wizards.
>
> > I made it last night, so it is not tested very well, I would like your help
> > to test it.
>
> > web2py PowerFormWizard Plugin - based on Jquery Stepy
>
> > - Steps
> > - Customizable titles
> > - Server side validation
> > - Client side validation (with jquery validate)
> > - Custom css
> > - JS Callbaks
> > - Error images
>
> > Take a look:http://labs.blouweb.com/powerformwizard
>
> > This plugin is the second plugin of blouweb PowerPlugins, I am now starting
> > the third one which I hope to have the first version soon.
>
> >http://labs.blouweb.com
>
> > Suggestions, testers, issues, contributions etc on 
> > bitbucket:https://bitbucket.org/rochacbruno/powerformwizard
>
> > Hope it helps someone!
>
> > Thanks.
>
> > --
> > Bruno Rocha
> > [ About me:http://zerp.ly/rochacbruno]
> > [ Aprenda Python:http://CursoDePython.com.br]
> > [ O seu aliado nos cuidados com os animais:http://AnimalSystem.com.br]
> > [ Consultoria em desenvolvimento web:http://www.blouweb.com]


[web2py] plugins and languages

2011-06-30 Thread szimszon
Hello All!

See I right that the plugin system can't handle language files for the 
plugins or I miss something?

It could be good to be able to have the language files for plugins...


Re: [web2py] plugins and languages

2011-06-30 Thread Manuele Pesenti

On 30/06/2011 10:07, szimszon wrote:

Hello All!

See I right that the plugin system can't handle language files for the
plugins or I miss something?

It could be good to be able to have the language files for plugins...


have you seen 
http://www.web2py.com/book/default/chapter/13?search=plugin#Plugins


have you tried to create under languages file called:

plugin_myplugin_en-en.py or something similar?

I've never tried but it seems possible.

My 2¢

Manuele


[web2py] web2py license

2011-06-30 Thread elffikk
here is an interesting article about source code licenses
http://gskinner.com/blog/archives/2008/07/source_code_lic_1.html

the author in summary says

"I would strongly encourage developers to release shared code under
the MIT license."
and
"I would also encourage developers to petition the owners of their
favourite shared libraries to change their licensing to MIT, if they
haven’t already."

so my question: why not releasing under MIT license or under dual
license (as jquery) ?


Re: [web2py] Using request.env.http_referrer to link to previous page

2011-06-30 Thread Richard Arts
On Thu, Jun 30, 2011 at 2:55 AM, Jonathan Lundell  wrote:
> On Jun 29, 2011, at 1:18 PM, Richard Arts wrote:
>>
>> Can somebody point out to me how to use the request.env.http_referrer
>> to link to the previous page?
>>
>> So far I have tried the following in the template file:
>> {{=A('Back', _href=URL(request.env.http_referrer))}}
>> but it links to the current page.
>>
>> Trying to supply the http_referrer through a dict does not work either.
>>
>> I'm certain I must be overlooking something...
>>
>> Using 1.97.1.
>
> It's not your problem, but it's 'http_referer'; it got misspelled somewhere 
> back in the mists of Internet time.
>
> It's an absolute URL, so URL() won't do anything useful with it. You'll need 
> something more like _href=request.env.http_referer.
>
> Alternatively, you can parse it and pull out the bits that you need to pass 
> to URL() (assuming that the referring page is in your app).
>
> Generally speaking, I think you're better off tracking the referral chain 
> internally, rather than relying on http_referer.

Thank you Jonathan. I will try this out tonight, and take your point
about avoiding the referer into consideration.

Regards,
Richard


Re: [web2py] plugins and languages

2011-06-30 Thread szimszon
Did not work. And admin did not recognize it too...


[web2py] web2py license

2011-06-30 Thread pbreit
While I think frameworks are best under BSD/MIT, this article seems mostly 
about flash and is not very compelling. As well as old.


Re: [web2py] Invalid view in 1.97.1

2011-06-30 Thread pbreit
If you pass, for example, an auth_user record to a view, you can view all the 
fields of that record by changing the extension. If you're passin locals() you 
can view even more. This is because the generics are designed to display 
everything that they can. Helpful during development but not appropriate for 
production.


[web2py] Multiple Languages for application

2011-06-30 Thread stargate
Does web2py support Multiple Languages.  So lets say I create a system
that is all in English, How would i translate it into french Italian
Spanish.



Re: [web2py] Multiple Languages for application

2011-06-30 Thread Albert Abril
Yes, if you read the book, you've seen about i18n here:
http://www.web2py.com/book/default/chapter/04#T-and-Internationalization



2011/6/30 stargate 

> Does web2py support Multiple Languages.  So lets say I create a system
> that is all in English, How would i translate it into french Italian
> Spanish.
>
>


Re: [web2py] SECOND TRY TO GET IT ON THE LIST how redirect without propagate the .load extension?

2011-06-30 Thread Richard Vézina
Still nop!

I also try to put it in the if table == like this :

if table == 'ref_fnaregistry':
#redirect(URL(request.application,c='default',f='index.html'))
form.update(_class='no_trap',
_action=URL('default','creation.html'),args=1)
return dict(form=form)
#URL(request.application,c='default', f='creation.html',args=1)

I don't think changing the action for 'create_fvte.html' is logic... I mean
my create_fvte is a component function and it serves to load all the 2
components ref_fnaregistry and ref_vregistry...

Maybe I should drop this function and create 2 functions one for each
component or form...

Anyway using your line of code directly give a empty page theres is no shell
for the component I mean no Tabs plugin and no code at all in the
create_fvte.hml view...

Richard

On Wed, Jun 29, 2011 at 11:38 PM, Anthony  wrote:

> OK, I forgot the underscore before 'action' (I also forgot to include
> request.args in the form action URL) -- I think this should do it:
>
> form.update(_class='no_trap',
> _action=URL('default','create_fvte.html',args=request.args))
>
>
> Note, adding the .html extension to create_fvte above ensures that when the
> form is submitted back to this function, the extension will be .html, which
> is the extension that will be passed to the redirects.
>
> Also, you should remove the following from create_fvte:
>
> else:
> response.flash = T('please fill out the form')
>
>
> The problem with that is that when you redirect to the /creation URL, it
> reloads your components, and the response.flash from the components
> overrides the session.flash that was passed to the /creation page. Instead,
> put the following in the creation() function:
>
> if not request.args:
> response.flash = T('please fill out the form')
>
>
> That will flash 'please fill out the form' when the /creation page is
> loaded without any arguments, but not otherwise.
>
> With those small changes, I believe it all works as you want now.
>
> Anthony
>
>
> On Wednesday, June 29, 2011 9:57:09 PM UTC-4, Richard wrote:
>
>> It clear validator if they trigger and don't know why the redirection
>> don't works neither...
>>
>> Maybe pbreit is right and I should just forget about redirection... It's
>> probably what I will do for now, cause I can't spend any longer on this
>> picky stuff for now. It's part of the 20% percent stuff...
>>
>> Thanks anyway, I really appreciate your help.
>>
>> ;-)
>>
>> Richard
>>
>>
>> On Wed, Jun 29, 2011 at 6:54 PM, Anthony  wrote:
>>
>>> Sorry, the **dict() isn't really needed -- you can just do:
>>>
>>> form.element('form').update(**_**class='no_trap',
>>> action=URL('default','create_**f**vte'))
>>>
>>>
>>> Actually, in the URL() call above, you might be better off doing
>>> 'create_fvte.html' to ensure it doesn't use the .load extension, which would
>>> then propagate to the redirect (unless you explicitly specify .hmtl in the
>>> redirect).
>>>
>>> Anthony
>>>
>>> On Wednesday, June 29, 2011 6:02:42 PM UTC-4, Anthony wrote:
>>>
 Try this:

 form = crud.create(db[table])
 form.element('form').update(**dict(_class='no_trap',
 action=URL('default','create_**f**vte')))


 The _class='no_trap' should turn off the trapping of the form, and the
 action=URL('default','create_**f**vte') should ensure that the
 untrapped form gets submitted back to the create_fvte function rather than
 the parent page (i.e., the index function). Because the form will not be
 submitted via ajax, the redirect should work as usual and reload the entire
 page.

 Anthony

>>>
>>


Re: [web2py] Re: new plugin - web2py Form Wizard - PowerFormWizard

2011-06-30 Thread Bruno Rocha
Even without client side validation, the server side will perform at the end
of submission.

The client-side validation, for now, just check if a field is required, i
did not implemented yet the other kind of client validation.

I guess you can use factory in the normal way, PowerFormWizard.factory, as
PowerFormWizard is a subclass of SQLFORM. - But I did not tested yet.

I just found some issues, I will wait for people to raise more issues and I
will update.

Thank you all for testing..

On Thu, Jun 30, 2011 at 4:49 AM, niknok  wrote:

> Clarification regarding the bio field with requires. It does let me
> proceed to the next step, but will not be allowed to submit the data
> after validation unless i meet the requires statement.
>
> A bit confusing since some fields will allow me to move to next step.
>
> One more thing, is there going to be an equivalent for
> SQLFORM.factory?
>
>
>
> On Jun 30, 2:41 pm, niknok  wrote:
> > In the validation example,  I entered a single character in the Bio
> > and was allowed to proceed to the next field despite the
> > db.person.bio.requires = IS_LENGTH(minsize=5, maxsize=200). You  made
> > a note about "Client side validation is not supposed to validate
> > everything!", is this included in that exception?
> >
> > A few suggestions:
> > * How about using "description" or "details" instead of the "legend"
> > keyword at it seems to be more appropriate for said function.
> >
> > • As default behavior, instead of the default "X" errorImage beside
> > the step title, how about using an exclamation point icon to indicate
> > that this step needs attention and then in the specific field with an
> > error use the "X" icon instead.
> >
> > The other day you answered my query re modal windows with a reference
> > to easyframework.com + web2py.
> >
> > I pray that you have plans of adding that feature to your
> > PowerFormWizard Plugin (or perhaps turning this into a "PowerForms"
> > plugin to truly enable feature-full forms in Web2py?
> >
> > Cheers and many thanks for your many contributions to the web2py
> > community.
> >
> > /r
> > Nik
> >
> > On Jun 29, 10:33 pm, Bruno Rocha  wrote:
> >
> >
> >
> >
> >
> >
> >
> > > Hi,
> >
> > > I just created a new plugin for stepped form wizards.
> >
> > > I made it last night, so it is not tested very well, I would like your
> help
> > > to test it.
> >
> > > web2py PowerFormWizard Plugin - based on Jquery Stepy
> >
> > > - Steps
> > > - Customizable titles
> > > - Server side validation
> > > - Client side validation (with jquery validate)
> > > - Custom css
> > > - JS Callbaks
> > > - Error images
> >
> > > Take a look:http://labs.blouweb.com/powerformwizard
> >
> > > This plugin is the second plugin of blouweb PowerPlugins, I am now
> starting
> > > the third one which I hope to have the first version soon.
> >
> > >http://labs.blouweb.com
> >
> > > Suggestions, testers, issues, contributions etc on bitbucket:
> https://bitbucket.org/rochacbruno/powerformwizard
> >
> > > Hope it helps someone!
> >
> > > Thanks.
> >
> > > --
> > > Bruno Rocha
> > > [ About me:http://zerp.ly/rochacbruno]
> > > [ Aprenda Python:http://CursoDePython.com.br]
> > > [ O seu aliado nos cuidados com os animais:http://AnimalSystem.com.br]
> > > [ Consultoria em desenvolvimento web:http://www.blouweb.com]
>



-- 



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


[web2py] Re: I created a little app to be able to share some files over the net without authentication

2011-06-30 Thread szimszon
Minor update:

110630

display the number of the uploadable and the uploaded files on upload group 
list

110628

the upload and downloaed links of the upload groups has now a title='...' 
with the best before date
And *Like* button on https://trac.oregpreshaz.eu/linux/wiki/ul

Could we have a download count on *appliances* page?


[web2py] Re: Localising decimal values in form fields

2011-06-30 Thread tomtom5
Thanks for this hint, but that doesn't seem to work.
If I apply this to the field in either model or controller, i get
following error:
  
  File "gluon/sqlhtml.py", line 782, in __init__
  File "gluon/dal.py", line 5247, in formatter
  File "gluon/validators.py", line 807, in formatter
TypeError: expected a character buffer object

If I use fixed value (eg .. requires=IS_DECIMAL_IN_RANGE(dot=",") ...)
the conversion seems to work.

On 29 Jun., 17:46, Massimo Di Pierro 
wrote:
> IS_DECIMAL_IN_RANGE and IS_FLOAT take a an attribute called dot="."
> which you can internationalize
>
> IS_DECIMAL_IN_RANGE(dot=T("."))
>
> On Jun 29, 5:39 am, tomtom5  wrote:
>
>
>
>
>
>
>
> > I'm currently diving into web2py and got a problem localising input/
> > output ofDecimal/Doubleformfields according to the users (browsers)
> > locale. I understand the mechanism of internationalising messages with
> > T(..), but that doesn't seem to help me further. What I need is, that
> > for example a german user may input adecimalvalue as 123.456,78
> > while an american user will use 123 456.78 as input/output format. I
> > found methods to define thedecimalseparator char in the constructor
> > of the IS_DECIMAL_IN_RANGE validator, but this is very rudimentary and
> > will not be user-locale aware. Is there a way to solve the problem out
> > of the box or should I create new validators or widgets for such a
> > task?
> > Thanks for advise


Re: [web2py] Re: I created a little app to be able to share some files over the net without authentication

2011-06-30 Thread Bruno Rocha
On Thu, Jun 30, 2011 at 9:50 AM, szimszon  wrote:

> Could we have a download count on *appliances* page?
>

Not yet, I am working on web2yslices2.0, which will probably work as an
appliance directory, this will be included...

Now, I host my projects in bitbucket, and I link ethe download to there,
because of the counter
https://bitbucket.org/rochacbruno/powerformwizard/downloads

-- 



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


[web2py] Re: Disabling Input Validation/Output Incoding

2011-06-30 Thread Ross Peoples
I did something similar to demonstrate common vulnerabilities, such as SQL 
injection and changing hidden values in forms before submission. It was 
really tough to make this app with web2py, as I had to skirt around most of 
the framework to make it happen. This is a GOOD THING though. I learned a 
lot about the extent that web2py goes to in order to keep apps secure.

You have to wrap everything in XML(), like Anthony mentions, you also have 
to use db.executesql() and define and handle your own forms manually, 
without using FORM or SQLFORM.


[web2py] Re: how to pass flag to database backend

2011-06-30 Thread Plumo
I added an unindexed string type like this:

from google.appengine.ext import db as gae
db._adapter.types['noindex'] = (lambda: gae.StringProperty(multiline=True, 
indexed=False))


Is there a better way?


Re: [web2py] SECOND TRY TO GET IT ON THE LIST how redirect without propagate the .load extension?

2011-06-30 Thread Anthony
No, the code should look like this:
 
def create_fvte():
table = request.args(0)
crud.settings.formstyle='divs'
form = crud.create(db[table])
form.update(_class='no_trap', 
_action=URL('default','create_fvte.html',args=request.args))
if form.accepts(request.vars, session):
session.flash = T('form accepted')
if table == 'ref_fnaregistry':
redirect(URL(request.application,c='default',f='index'))
elif table == 'ref_vregistry':
redirect(URL(request.application,c='default', 
f='creation',args=2))
elif table == 'ref_tregistry':
redirect(URL(request.application,c='default', 
f='creation',args=3))
elif form.errors:
response.flash = T('form has errors')
return dict(form=form)
 
The above works fine for me, but there's still one problem -- if the form 
has errors, it isn't able to re-display the form with error messages 
(because it submits to create_fvte, which loads at the top level instead of 
within the creation page). We might be able to handle that by putting things 
in the session, but that's starting to get a bit too complicated. So 
instead, let's try redirecting from the client side via javascript. Try 
this:
 
def create_fvte():
table = request.args(0)
crud.settings.formstyle='divs'
form = crud.create(db[table])
if form.accepts(request.vars, session):
if table == 'ref_fnaregistry':
next = URL('default', 'index', extension=False, host=True)
elif table == 'ref_vregistry':
next = URL('default', 'creation', args=2, extension=False, 
host=True)
elif table == 'ref_tregistry':
next = URL('default', 'creation', args=3, extension=False, 
host=True)
session.flash = T('form accepted')
response.js = 'window.location.replace("%s")' % next
elif form.errors:
response.flash = T('form has errors')
return dict(form=form)
 
 
Instead of redirecting on the server side, the above sends a javascript 
command back to the client that redirects to the appropriate URL. In this 
case, because the redirect happens on the client side after the returned 
page loads, you will briefly see the original page with a blank form before 
the redirect happens.
 
Anthony
 

On Thursday, June 30, 2011 8:32:01 AM UTC-4, Richard wrote:

> Still nop! 
>
> I also try to put it in the if table == like this :
>
>  if table == 'ref_fnaregistry':
> #redirect(URL(request.application,c='default',f='index.html'))
> form.update(_class='no_trap', 
> _action=URL('default','creation.html'),args=1)
> return dict(form=form)
> #URL(request.application,c='default', f='creation.html',args=1)
>
> I don't think changing the action for 'create_fvte.html' is logic... I mean 
> my create_fvte is a component function and it serves to load all the 2 
> components ref_fnaregistry and ref_vregistry...
>
> Maybe I should drop this function and create 2 functions one for each 
> component or form...
>
> Anyway using your line of code directly give a empty page theres is no 
> shell for the component I mean no Tabs plugin and no code at all in the 
> create_fvte.hml view...
>
> Richard
>
> On Wed, Jun 29, 2011 at 11:38 PM, Anthony  wrote:
>
>> OK, I forgot the underscore before 'action' (I also forgot to include 
>> request.args in the form action URL) -- I think this should do it:
>>  
>> form.update(_class='no_trap', 
>> _action=URL('default','create_fvte.html',args=request.args))
>>  
>>  
>> Note, adding the .html extension to create_fvte above ensures that when 
>> the form is submitted back to this function, the extension will be .html, 
>> which is the extension that will be passed to the redirects.
>>  
>> Also, you should remove the following from create_fvte:
>>  
>> else:
>> response.flash = T('please fill out the form')
>>  
>>  
>> The problem with that is that when you redirect to the /creation URL, it 
>> reloads your components, and the response.flash from the components 
>> overrides the session.flash that was passed to the /creation page. Instead, 
>> put the following in the creation() function:
>>  
>> if not request.args:
>> response.flash = T('please fill out the form')
>>  
>>  
>> That will flash 'please fill out the form' when the /creation page is 
>> loaded without any arguments, but not otherwise.
>>  
>> With those small changes, I believe it all works as you want now.
>>  
>> Anthony
>>   
>>
>> On Wednesday, June 29, 2011 9:57:09 PM UTC-4, Richard wrote:
>>
>>> It clear validator if they trigger and don't know why the redirection 
>>> don't works neither... 
>>>
>>> Maybe pbreit is right and I should just forget about redirection... It's 
>>> probably what I will do for now, cause I can't spend any longer on this 
>>> picky stuff for now. It's part of the 20% percent stuff...
>>>
>>> Thanks anyway, I really appreciate your help.
>>>
>>> ;-)
>>>
>>> Richard 
>>>
>>>
>>> On Wed

Re: [web2py] SECOND TRY TO GET IT ON THE LIST how redirect without propagate the .load extension?

2011-06-30 Thread Richard Vézina
Now it works!!!

I had try what you explained... I didn't just not explain everything
completly maybe...

There is only an artefact. The next solution that you propose breaks the
normal workflow of navigation... The user can't go back with the nav
backward arrow... Maybe we could use "javascript:void(history.go(-1))"
somewhere ;-)

Thank you Anthony for your help...

Richard

On Thu, Jun 30, 2011 at 10:26 AM, Anthony  wrote:

> No, the code should look like this:
>
> def create_fvte():
> table = request.args(0)
> crud.settings.formstyle='divs'
>
> form = crud.create(db[table])
> form.update(_class='no_trap',
> _action=URL('default','create_fvte.html',args=request.args))
> if form.accepts(request.vars, session):
> session.flash = T('form accepted')
> if table == 'ref_fnaregistry':
> redirect(URL(request.application,c='default',f='index'))
>
> elif table == 'ref_vregistry':
> redirect(URL(request.application,c='default',
> f='creation',args=2))
> elif table == 'ref_tregistry':
> redirect(URL(request.application,c='default',
> f='creation',args=3))
> elif form.errors:
> response.flash = T('form has errors')
> return dict(form=form)
>
> The above works fine for me, but there's still one problem -- if the form
> has errors, it isn't able to re-display the form with error messages
> (because it submits to create_fvte, which loads at the top level instead of
> within the creation page). We might be able to handle that by putting things
> in the session, but that's starting to get a bit too complicated. So
> instead, let's try redirecting from the client side via javascript. Try
> this:
>
> def create_fvte():
> table = request.args(0)
> crud.settings.formstyle='divs'
>
> form = crud.create(db[table])
> if form.accepts(request.vars, session):
> if table == 'ref_fnaregistry':
> next = URL('default', 'index', extension=False, host=True)
> elif table == 'ref_vregistry':
> next = URL('default', 'creation', args=2, extension=False,
> host=True)
> elif table == 'ref_tregistry':
> next = URL('default', 'creation', args=3, extension=False,
> host=True)
>
> session.flash = T('form accepted')
> response.js = 'window.location.replace("%s")' % next
> elif form.errors:
> response.flash = T('form has errors')
> return dict(form=form)
>
>
> Instead of redirecting on the server side, the above sends a javascript
> command back to the client that redirects to the appropriate URL. In this
> case, because the redirect happens on the client side after the returned
> page loads, you will briefly see the original page with a blank form before
> the redirect happens.
>
> Anthony
>
>
> On Thursday, June 30, 2011 8:32:01 AM UTC-4, Richard wrote:
>
>> Still nop!
>>
>> I also try to put it in the if table == like this :
>>
>>  if table == 'ref_fnaregistry':
>> #redirect(URL(request.**application,c='default',f='**
>> index.html'))
>> form.update(_class='no_trap', _action=URL('default','**
>> creation.html'),args=1)
>> return dict(form=form)
>> #URL(request.application,c='**default',
>> f='creation.html',args=1)
>>
>> I don't think changing the action for 'create_fvte.html' is logic... I
>> mean my create_fvte is a component function and it serves to load all the 2
>> components ref_fnaregistry and ref_vregistry...
>>
>> Maybe I should drop this function and create 2 functions one for each
>> component or form...
>>
>> Anyway using your line of code directly give a empty page theres is no
>> shell for the component I mean no Tabs plugin and no code at all in the
>> create_fvte.hml view...
>>
>> Richard
>>
>> On Wed, Jun 29, 2011 at 11:38 PM, Anthony  wrote:
>>
>>> OK, I forgot the underscore before 'action' (I also forgot to include
>>> request.args in the form action URL) -- I think this should do it:
>>>
>>> form.update(_class='no_trap', _action=URL('default','create_**
>>> fvte.html',args=request.args))
>>>
>>>
>>> Note, adding the .html extension to create_fvte above ensures that when
>>> the form is submitted back to this function, the extension will be .html,
>>> which is the extension that will be passed to the redirects.
>>>
>>> Also, you should remove the following from create_fvte:
>>>
>>> else:
>>> response.flash = T('please fill out the form')
>>>
>>>
>>> The problem with that is that when you redirect to the /creation URL, it
>>> reloads your components, and the response.flash from the components
>>> overrides the session.flash that was passed to the /creation page. Instead,
>>> put the following in the creation() function:
>>>
>>> if not request.args:
>>> response.flash = T('please fill out the form')
>>>
>>>
>>> That will flash 'please fill out the form' when the /creation page is
>>> loaded without any arguments, but not otherwise.
>>>
>>> With those small 

[web2py] Re: web2py license

2011-06-30 Thread Anthony
We had a long discussion about this several months ago, and as a result, the 
license was changed from GPL (with commercial exception) to LGPL. I think 
the idea was that LGPL should allow usage of the framework along with apps 
and libraries of any license type while prohibiting any closed 
source/commercial forks of web2py (which MIT would allow).
 
Anthony

On Thursday, June 30, 2011 5:52:12 AM UTC-4, elffikk wrote:

> here is an interesting article about source code licenses 
> http://gskinner.com/blog/archives/2008/07/source_code_lic_1.html 
>
> the author in summary says 
>
> "I would strongly encourage developers to release shared code under 
> the MIT license." 
> and 
> "I would also encourage developers to petition the owners of their 
> favourite shared libraries to change their licensing to MIT, if they 
> haven’t already." 
>
> so my question: why not releasing under MIT license or under dual 
> license (as jquery) ?



Re: [web2py] SECOND TRY TO GET IT ON THE LIST how redirect without propagate the .load extension?

2011-06-30 Thread Anthony
You're welcome.
 
Yeah, you might have to play around with the JS a bit, but hopefully this 
points you in the right direction.
 
The problem with the server side redirect is that the jQuery ajax function 
receives the redirect response and then makes the redirect request via ajax 
again, and then it receives the new response and uses it to fill the 
component div. So, it's not really a server-side issue with web2py. There 
may be a way to tell jQuery not to respond to redirects via ajax -- I'll 
look into that.
 
Anthony

On Thursday, June 30, 2011 10:55:22 AM UTC-4, Richard wrote:

> Now it works!!! 
>
>  I had try what you explained... I didn't just not explain everything 
> completly maybe...
>
> There is only an artefact. The next solution that you propose breaks the 
> normal workflow of navigation... The user can't go back with the nav 
> backward arrow... Maybe we could use "javascript:void(history.go(-1))" 
> somewhere ;-)
>
> Thank you Anthony for your help...
>
> Richard
>
> On Thu, Jun 30, 2011 at 10:26 AM, Anthony  wrote:
>
>> No, the code should look like this:
>>  
>> def create_fvte():
>> table = request.args(0)
>> crud.settings.formstyle='divs' 
>>
>> form = crud.create(db[table])
>> form.update(_class='no_trap', 
>> _action=URL('default','create_fvte.html',args=request.args))
>> if form.accepts(request.vars, session):
>> session.flash = T('form accepted')
>> if table == 'ref_fnaregistry':
>> redirect(URL(request.application,c='default',f='index')) 
>>
>> elif table == 'ref_vregistry':
>> redirect(URL(request.application,c='default', 
>> f='creation',args=2))
>> elif table == 'ref_tregistry':
>> redirect(URL(request.application,c='default', 
>> f='creation',args=3))
>> elif form.errors:
>> response.flash = T('form has errors')
>> return dict(form=form)
>>  
>> The above works fine for me, but there's still one problem -- if the form 
>> has errors, it isn't able to re-display the form with error messages 
>> (because it submits to create_fvte, which loads at the top level instead of 
>> within the creation page). We might be able to handle that by putting things 
>> in the session, but that's starting to get a bit too complicated. So 
>> instead, let's try redirecting from the client side via javascript. Try 
>> this:
>>  
>> def create_fvte():
>> table = request.args(0)
>> crud.settings.formstyle='divs' 
>>
>> form = crud.create(db[table])
>> if form.accepts(request.vars, session):
>> if table == 'ref_fnaregistry':
>> next = URL('default', 'index', extension=False, host=True)
>> elif table == 'ref_vregistry':
>> next = URL('default', 'creation', args=2, extension=False, 
>> host=True)
>> elif table == 'ref_tregistry':
>> next = URL('default', 'creation', args=3, extension=False, 
>> host=True) 
>>
>> session.flash = T('form accepted')
>> response.js = 'window.location.replace("%s")' % next
>> elif form.errors:
>> response.flash = T('form has errors')
>> return dict(form=form)
>>  
>>  
>> Instead of redirecting on the server side, the above sends a javascript 
>> command back to the client that redirects to the appropriate URL. In this 
>> case, because the redirect happens on the client side after the returned 
>> page loads, you will briefly see the original page with a blank form before 
>> the redirect happens.
>>  
>> Anthony
>>   
>>
>> On Thursday, June 30, 2011 8:32:01 AM UTC-4, Richard wrote:
>>
>>> Still nop! 
>>>
>>> I also try to put it in the if table == like this :
>>>
>>>  if table == 'ref_fnaregistry':
>>> #redirect(URL(request.**application,c='default',f='**
>>> index.html'))
>>> form.update(_class='no_trap', _action=URL('default','**
>>> creation.html'),args=1)
>>> return dict(form=form)
>>> #URL(request.application,c='**default', 
>>> f='creation.html',args=1)
>>>
>>> I don't think changing the action for 'create_fvte.html' is logic... I 
>>> mean my create_fvte is a component function and it serves to load all the 2 
>>> components ref_fnaregistry and ref_vregistry...
>>>
>>> Maybe I should drop this function and create 2 functions one for each 
>>> component or form...
>>>
>>> Anyway using your line of code directly give a empty page theres is no 
>>> shell for the component I mean no Tabs plugin and no code at all in the 
>>> create_fvte.hml view...
>>>
>>> Richard
>>>
>>>  On Wed, Jun 29, 2011 at 11:38 PM, Anthony  wrote:
>>>
  OK, I forgot the underscore before 'action' (I also forgot to include 
 request.args in the form action URL) -- I think this should do it:
  
 form.update(_class='no_trap', _action=URL('default','create_**
 fvte.html',args=request.args))
  
  
 Note, adding the .html extension to create_fvte above ensures that when 
 the form is submitted back 

[web2py] Re: Disabling Input Validation/Output Incoding

2011-06-30 Thread David Schoenheit
Thank you both for the help and advice, things are working perfectly
now.

On Jun 30, 9:25 am, Ross Peoples  wrote:
> I did something similar to demonstrate common vulnerabilities, such as SQL
> injection and changing hidden values in forms before submission. It was
> really tough to make this app with web2py, as I had to skirt around most of
> the framework to make it happen. This is a GOOD THING though. I learned a
> lot about the extent that web2py goes to in order to keep apps secure.
>
> You have to wrap everything in XML(), like Anthony mentions, you also have
> to use db.executesql() and define and handle your own forms manually,
> without using FORM or SQLFORM.


[web2py] response.js="web2py_component('action','target')" : no refresh

2011-06-30 Thread Richard Vézina
Hello,

I am having hard time to refresh component I don't know if it is my
response.js or my setup or 1.97.1 issue :

response.js="web2py_component(URL(c='ref',f='creation'),'two')"

CONTROLLER

def creation():
if not request.args:
response.flash = T('please fill out the form')
a = None
return dict(a=a)

def create_fvte():
table = request.args(0)
crud.settings.formstyle='divs'
form = crud.create(db[table])
if form.accepts(request.vars, session):
session.flash = T('form accepted')
response.js="web2py_component(URL(c='ref',
f='create_fvte.load',args='ref_vregistry'),'two')"
elif form.errors:
response.flash = T('form has errors')
return dict(form=form)

VIEWS :

CREATION =
{{extend 'layout_form.html'}}


@import
"{{=URL('static','plugin_added/jquery-ui-1.8.14.custom/development-bundle/themes/base/jquery.ui.all.css')}}";








{{=T('folder').capitalize()}}
{{=T('volume').capitalize()}}
{{=T('tome').capitalize()}}
{{=T('report').capitalize()}}



{{=LOAD(c='ref', f='create_fvte', args='ref_fnaregistry',
extension='load', ajax=True, target='one')}}



{{=LOAD(c='ref', f='create_fvte', args='ref_vregistry',
extension='load', ajax=True, target='two')}}



{{=LOAD(c='ref', f='create_fvte', args='ref_tregistry',
extension='load', ajax=True, target='three')}}



{{=LOAD(c='ref', f='create_fvte', args='ref_eregistry',
extension='load', ajax=True, target='four')}}












$(function() {
var $tabs = $( "#tabs" ).tabs();
$tabs.tabs('select',  {{=request.args(0)}});
return false;
});


CREATE_FVTE = EMPTY


Re: [web2py] Re: web2py license

2011-06-30 Thread Vasile Ermicioi
>
> I think frameworks are best under BSD/MIT

so you agree :)
the fact that it is written by a flash developer a few years ago doesn't
mean that this is not relevant information


prohibiting any closed source/commercial forks of web2py


DAL and template system can be used standalone
what if I want to use them with bottle (MIT) or flask(BSD) and make a hybrid
framework and distribute them (in commercial projects too)?

for some of my projects there is no reason to use a full stack framework -
just 3 files: bottle, dal, and template
or for some desktop (offline) applications I need 4:
rocket+bottle+dal+template


Re: [web2py] Re: web2py license

2011-06-30 Thread Bruno Rocha
On Thu, Jun 30, 2011 at 1:52 PM, Vasile Ermicioi  wrote:

> DAL and template system can be used standalone
> what if I want to use them with bottle (MIT) or flask(BSD) and make a
> hybrid framework and distribute them (in commercial projects too)?
>


I guess you can create a comercial product, but not a comercial framework.

-- 



--
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] Re: web2py license

2011-06-30 Thread Vasile Ermicioi
>
> I guess you can create a comercial product, but not a comercial framework.


what about an opensource framework :) e.g. ( bottle+dal+template+rocket) ?

anyway, I think another license change (to MIT) will be welcome


Re: [web2py] Re: web2py license

2011-06-30 Thread Bruno Rocha
On Thu, Jun 30, 2011 at 2:05 PM, Vasile Ermicioi  wrote:

> what about an opensource framework :) e.g. ( bottle+dal+template+rocket) ?


Martin Mulone started a project for that
https://bitbucket.org/mulonemartin/web2tools/overview




-- 



--
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] response.js="web2py_component('action','target')" : no refresh

2011-06-30 Thread Anthony
On Thursday, June 30, 2011 12:39:53 PM UTC-4, Richard wrote: 
>
> Hello, 
>
> I am having hard time to refresh component I don't know if it is my 
> response.js or my setup or 1.97.1 issue :
>
> response.js="web2py_component(URL(c='ref',f='creation'),'two')"
>
 
You can't put a call to the URL() function inside a string -- it's a web2py 
Python function that has to be run on the server side -- as is, you're 
sending it as javascript code. You might also need to put it in quotes. 
Maybe something like this:
 
response.js="web2py_component('%s','two')" % URL('ref','creation')
 
 
Anthony


Re: [web2py] Re: web2py license

2011-06-30 Thread Vasile Ermicioi
great, as always, I thought and it is already done :)

so forks are allowed, or... ?


Re: [web2py] Re: web2py license

2011-06-30 Thread Anthony
On Thursday, June 30, 2011 1:05:47 PM UTC-4, elffikk wrote: 
>
> I guess you can create a comercial product, but not a comercial framework.
>
>  
> what about an opensource framework :) e.g. ( bottle+dal+template+rocket) ?
>
 
I think you can do that, but I don't think you could make the entire 
framework MIT because that would violate the DAL's LGPL license (i.e., the 
DAL would have to stay LGPL).
 
Anthony


Re: [web2py] Re: web2py license

2011-06-30 Thread Anthony
On Thursday, June 30, 2011 12:52:06 PM UTC-4, elffikk wrote: 
>
> I think frameworks are best under BSD/MIT
>
> so you agree :) 
> the fact that it is written by a flash developer a few years ago doesn't 
> mean that this is not relevant information
>  
>
> prohibiting any closed source/commercial forks of web2py
>
>  
> DAL and template system can be used standalone  
> what if I want to use them with bottle (MIT) or flask(BSD) and make a 
> hybrid framework and distribute them (in commercial projects too)?
>
 
I think it depends exactly what you want to do. The DAL part of your project 
would have to stay open source, but I think you can use it as a 
library/module within a closed source project. You just can't make changes 
to it, and then close source the changed version.
 
Anthony


Re: [web2py] response.js="web2py_component('action','target')" : no refresh

2011-06-30 Thread Richard Vézina
Ok, it works now but I get None in place of the reloaded component... I
thought it could be the Tabs plugin so I remove the initiation script but
still get None...

Any idea?

On Thu, Jun 30, 2011 at 1:13 PM, Anthony  wrote:

> On Thursday, June 30, 2011 12:39:53 PM UTC-4, Richard wrote:
>>
>> Hello,
>>
>> I am having hard time to refresh component I don't know if it is my
>> response.js or my setup or 1.97.1 issue :
>>
>> response.js="web2py_component(**URL(c='ref',f='creation'),'**two')"
>>
>
> You can't put a call to the URL() function inside a string -- it's a web2py
> Python function that has to be run on the server side -- as is, you're
> sending it as javascript code. You might also need to put it in quotes.
> Maybe something like this:
>
> response.js="web2py_component('%s'**,'**two')" % URL('ref','creation')
>
>
> Anthony
>


[web2py] Re: Documenting a file with sphinx, that has local_import in it

2011-06-30 Thread Dan
I'm having the same issue. Where do I have to include all this? Is
there some other workaround for this? It would be great if we could
use Sphinx for documenting out Web2Py apps.

Thanks for any help.



On May 28, 5:18 pm, Massimo Di Pierro 
wrote:
> controllers and models in web2py are written in python but are not
> python modules. They use objects
> (request,response,...,local_import,...) that are not imported.
>
> Sphinx does not understand this.
>
> I am sure there is a way around (for example add to your models and
> controllers:
>
> if 1:
>     from gluon import *
>     request,response,session,cache,T = \
>        current.request,current.response,
>        current.session,current.cache,current.T
>     from gluon.compileapp import local_import_aux as local_import
>
> ) but I cannot say for sure without details about what you are trying
> to do.
>
> On May 28, 3:47 am, Vasil Petkov  wrote:
>
>
>
>
>
>
>
> > Hello!
>
> > I use web2py 1.94 on Ubuntu with Python 2.7 and Sphinx 1.0.7. For the
> > documentation purposes, i have created a 'doc'-directory inside my
> > web2py-application. My web2py project has the following structure:
>
> > web2py
> >    |_ server
> >    |      |_ applications
> >    |            |_ init
> >    |            |     |_ controllers
> >    |            |           |_ myapp.py
> >   ...         ...
> >    |            |_ modules
> >    |                  |_ xml2obj.py
> >   ...
> >    |_ doc
>
> > When i try to generate documentation for the myapp.py-file with
> > sphinx, i get the following warning:
>
> >  Traceback (most recent call
> > last):
> >   File "/usr/local/lib/python2.7/dist-packages/Sphinx-1.0.7-py2.7.egg/
> > sphinx/ext/autodoc.py", line 329, in import_object
> >     __import__(self.modname)
> >   File "/home/vpetkov/Documents/web2py/server/applications/init/
> > controllers/myapp.py", line 16, in 
> >     xml2obj = local_import('xml2obj', reload=False)
> > NameError: name 'local_import' is not defined
>
> > /home/vpetkov/Documents/web2py/server/doc/myapp.rst:7: (WARNING/2)
> > autodoc can't import/find module 'myapp', it reported error: "name
> > 'local_import' is not defined", please check your spelling and
> > sys.path
>
> > Additionally. in conf.py Sphinx file, i added
> > sys.path.append(os.path.abspath('../applications/init/modules/'))


Re: [web2py] response.js="web2py_component('action','target')" : no refresh

2011-06-30 Thread Richard Vézina
Like this it pass, but it takes time and it load the entire site before
finally return the updated component...

response.js="web2py_component(URL(c='ref',f='creation#tabs-2'),'two')"


Richard
On Thu, Jun 30, 2011 at 1:25 PM, Richard Vézina  wrote:

> Ok, it works now but I get None in place of the reloaded component... I
> thought it could be the Tabs plugin so I remove the initiation script but
> still get None...
>
> Any idea?
>
>
> On Thu, Jun 30, 2011 at 1:13 PM, Anthony  wrote:
>
>> On Thursday, June 30, 2011 12:39:53 PM UTC-4, Richard wrote:
>>>
>>> Hello,
>>>
>>> I am having hard time to refresh component I don't know if it is my
>>> response.js or my setup or 1.97.1 issue :
>>>
>>> response.js="web2py_component(**URL(c='ref',f='creation'),'**two')"
>>>
>>
>> You can't put a call to the URL() function inside a string -- it's a
>> web2py Python function that has to be run on the server side -- as is,
>> you're sending it as javascript code. You might also need to put it in
>> quotes. Maybe something like this:
>>
>> response.js="web2py_component('%s'**,'**two')" % URL('ref','creation')
>>
>>
>> Anthony
>>
>
>


Re: [web2py] response.js="web2py_component('action','target')" : no refresh

2011-06-30 Thread Anthony
Not sure. Isn't that the wrong URL for your component? Shouldn't it be 
f='create_ftve', plus args=[tablename]?

On Thursday, June 30, 2011 1:25:13 PM UTC-4, Richard wrote:

> Ok, it works now but I get None in place of the reloaded component... I 
> thought it could be the Tabs plugin so I remove the initiation script but 
> still get None... 
>
> Any idea?
>
> On Thu, Jun 30, 2011 at 1:13 PM, Anthony  wrote:
>
>> On Thursday, June 30, 2011 12:39:53 PM UTC-4, Richard wrote: 
>>>
>>> Hello, 
>>>
>>> I am having hard time to refresh component I don't know if it is my 
>>> response.js or my setup or 1.97.1 issue :
>>>
>>> response.js="web2py_component(**URL(c='ref',f='creation'),'**two')"
>>>
>>  
>> You can't put a call to the URL() function inside a string -- it's a 
>> web2py Python function that has to be run on the server side -- as is, 
>> you're sending it as javascript code. You might also need to put it in 
>> quotes. Maybe something like this:
>>  
>> response.js="web2py_component('%s'**,'**two')" % URL('ref','creation')
>>  
>>  
>> Anthony
>>
>
>

Re: [web2py] response.js="web2py_component('action','target')" : no refresh

2011-06-30 Thread Richard Vézina
Kind of the exact same problem we already solve...

The propagation has pretty problematic behavior in this peculiar case

Richard

On Thu, Jun 30, 2011 at 1:32 PM, Richard Vézina  wrote:

> Like this it pass, but it takes time and it load the entire site before
> finally return the updated component...
>
> response.js="web2py_component(URL(c='ref',f='creation#tabs-2'),'two')"
>
>
> Richard
>
> On Thu, Jun 30, 2011 at 1:25 PM, Richard Vézina <
> ml.richard.vez...@gmail.com> wrote:
>
>> Ok, it works now but I get None in place of the reloaded component... I
>> thought it could be the Tabs plugin so I remove the initiation script but
>> still get None...
>>
>> Any idea?
>>
>>
>> On Thu, Jun 30, 2011 at 1:13 PM, Anthony  wrote:
>>
>>> On Thursday, June 30, 2011 12:39:53 PM UTC-4, Richard wrote:

 Hello,

 I am having hard time to refresh component I don't know if it is my
 response.js or my setup or 1.97.1 issue :

 response.js="web2py_component(**URL(c='ref',f='creation'),'**two')"

>>>
>>> You can't put a call to the URL() function inside a string -- it's a
>>> web2py Python function that has to be run on the server side -- as is,
>>> you're sending it as javascript code. You might also need to put it in
>>> quotes. Maybe something like this:
>>>
>>> response.js="web2py_component('%s'**,'**two')" % URL('ref','creation')
>>>
>>>
>>> Anthony
>>>
>>
>>
>


Re: [web2py] response.js="web2py_component('action','target')" : no refresh

2011-06-30 Thread Richard Vézina
Ok, my mistake... I had try with create_fvte before but with the URL in the
js call so I thought it were not working with it.

Richard

On Thu, Jun 30, 2011 at 1:34 PM, Anthony  wrote:

> Not sure. Isn't that the wrong URL for your component? Shouldn't it be
> f='create_ftve', plus args=[tablename]?
>
> On Thursday, June 30, 2011 1:25:13 PM UTC-4, Richard wrote:
>
>> Ok, it works now but I get None in place of the reloaded component... I
>> thought it could be the Tabs plugin so I remove the initiation script but
>> still get None...
>>
>> Any idea?
>>
>>
>> On Thu, Jun 30, 2011 at 1:13 PM, Anthony  wrote:
>>
>>> On Thursday, June 30, 2011 12:39:53 PM UTC-4, Richard wrote:

 Hello,

 I am having hard time to refresh component I don't know if it is my
 response.js or my setup or 1.97.1 issue :

 response.js="web2py_component(URL(c='ref',f='creation'),'**two**')"

>>>
>>> You can't put a call to the URL() function inside a string -- it's a
>>> web2py Python function that has to be run on the server side -- as is,
>>> you're sending it as javascript code. You might also need to put it in
>>> quotes. Maybe something like this:
>>>
>>> response.js="web2py_component(**'%s'**,'**two')" % URL('ref','creation')
>>>
>>>
>>> Anthony
>>>
>>
>>


Re: [web2py] Re: Documenting a file with sphinx, that has local_import in it

2011-06-30 Thread Richard Vézina
Interresting too in the fix to use Sphynx to document app...

Richard

On Thu, Jun 30, 2011 at 1:29 PM, Dan  wrote:

> I'm having the same issue. Where do I have to include all this? Is
> there some other workaround for this? It would be great if we could
> use Sphinx for documenting out Web2Py apps.
>
> Thanks for any help.
>
>
>
> On May 28, 5:18 pm, Massimo Di Pierro 
> wrote:
> > controllers and models in web2py are written in python but are not
> > python modules. They use objects
> > (request,response,...,local_import,...) that are not imported.
> >
> > Sphinx does not understand this.
> >
> > I am sure there is a way around (for example add to your models and
> > controllers:
> >
> > if 1:
> > from gluon import *
> > request,response,session,cache,T = \
> >current.request,current.response,
> >current.session,current.cache,current.T
> > from gluon.compileapp import local_import_aux as local_import
> >
> > ) but I cannot say for sure without details about what you are trying
> > to do.
> >
> > On May 28, 3:47 am, Vasil Petkov  wrote:
> >
> >
> >
> >
> >
> >
> >
> > > Hello!
> >
> > > I use web2py 1.94 on Ubuntu with Python 2.7 and Sphinx 1.0.7. For the
> > > documentation purposes, i have created a 'doc'-directory inside my
> > > web2py-application. My web2py project has the following structure:
> >
> > > web2py
> > >|_ server
> > >|  |_ applications
> > >||_ init
> > >|| |_ controllers
> > >||   |_ myapp.py
> > >   ... ...
> > >||_ modules
> > >|  |_ xml2obj.py
> > >   ...
> > >|_ doc
> >
> > > When i try to generate documentation for the myapp.py-file with
> > > sphinx, i get the following warning:
> >
> > >  Traceback (most recent call
> > > last):
> > >   File "/usr/local/lib/python2.7/dist-packages/Sphinx-1.0.7-py2.7.egg/
> > > sphinx/ext/autodoc.py", line 329, in import_object
> > > __import__(self.modname)
> > >   File "/home/vpetkov/Documents/web2py/server/applications/init/
> > > controllers/myapp.py", line 16, in 
> > > xml2obj = local_import('xml2obj', reload=False)
> > > NameError: name 'local_import' is not defined
> >
> > > /home/vpetkov/Documents/web2py/server/doc/myapp.rst:7: (WARNING/2)
> > > autodoc can't import/find module 'myapp', it reported error: "name
> > > 'local_import' is not defined", please check your spelling and
> > > sys.path
> >
> > > Additionally. in conf.py Sphinx file, i added
> > > sys.path.append(os.path.abspath('../applications/init/modules/'))
>


Re: [web2py] Re: web2py license

2011-06-30 Thread Vasile Ermicioi
Martin did something great, but I would include template too,
because I prefer web2py's template system


[web2py] Problem with 1.97.1??

2011-06-30 Thread Jim Steil

Hi

I have an app I've been working on and upgraded my system to 1.97.1 
today.  Since then I'm getting the following with an AJAX call for json 
data:


Traceback(most recent call last):
  File"gluon/restricted.py",line192,inrestricted
  File"C:/dev/web2py/applications/InfoCenter/controllers/administration.py"  
,line862,in
  File"gluon/globals.py",line137,in
  File"C:/dev/web2py/applications/InfoCenter/controllers/administration.py"  
,line17,incall
  File"gluon/tools.py",line3918,in__call__
  File"gluon/tools.py",line3734,inserve_json
  File"gluon/tools.py",line3404,inuniversal_caller
TypeError:object of type'NoneType'has no len()


My call from my template looks like this:

jQuery(document).ready(function(){
  jQuery("#list").jqGrid({
url:'/InfoCenter/administration/call/json/userList',
datatype: 'json',
postData:{'searchText':$("#searchText").val()},
colModel :[ {
name:'id',
index:'id',
label:'ID',
hidden:true,
},
{
name:'lastFirst',
index:'lastFirst',
width:'50%',
label:'Name',
},
{
name:'email',
index:'email',
width:'50%',
label:'Email',
},

],
pager: '#pager',
rowNum:20,
sortname: "lastFirst",
sortorder: 'asc',
width: 875,
height: "100%",
ondblClickRow: function(){
var row_id = $("#list").getGridParam('selrow');
window.location.href = "/InfoCenter/administration/user/" + row_id;
return true;
},
caption:'',
  });
  jQuery("#list").navGrid("#pager",
  {edit:false,add:false,del:true,search:false},
  {},
  {},
  {msg:"Delete selected row(s)",
  bSubmit:"Delete",
  bCancel:"Cancel",
  url:"/InfoCenter/administration/userDelete",
  reloadAfterSubmit:true}
  );
});

This works in the 1.96.x branches by not 1.97.1.  And, it never gets to 
the method in the controller.  Line in administration.py is the last 
line of the call() method:


and line 862 doesn't exist in the controller, it ends at 861:


Any thoughts?  I'm stumped (but also pretty new to web2py).

-Jim
<><>

[web2py] Re: Error on LOAD() in trunk

2011-06-30 Thread pbreit
Any ideas on this one? Has anyone else had problems with LOAD(ajax=False) in 
trunk? I tried switching it to deepcopy and got same error. I also tried 
putting it in a try/except but could not find anything. Could my request 
have something funky in it?

Re: [web2py] Re: Error on LOAD() in trunk

2011-06-30 Thread Richard Vézina
You answer your own post... So many may consider you find your own answer...

Maybe start a other thread could help.

Richard

On Thu, Jun 30, 2011 at 3:10 PM, pbreit  wrote:

> Any ideas on this one? Has anyone else had problems with LOAD(ajax=False)
> in trunk? I tried switching it to deepcopy and got same error. I also tried
> putting it in a try/except but could not find anything. Could my request
> have something funky in it?


Re: [web2py] Re: [OFF] Protect the web2py app of DDoS atack in GAE

2011-06-30 Thread Bruno Barbosa
Thanks!

I take a look, then return here =)

# ---
# Bruno Barbosa
# Web Developer - Linux user and Free Software Enthusiast
# http://algoritmizando.com
# http://twitter.com/bruninbsb
# ---


2011/6/30 pbreit 

> Check out CloudFlare which caches all your static files, prevents threats
> and more. All for free with a simple setup.
>
> Info on GAE:
> http://blog.cloudflare.com/zone-apex-naked-domain-root-domain-cname-supp
>


[web2py] requires and T()

2011-06-30 Thread Martin Weissenboeck
Hi,

I want to use a SQLFORM with a checkbox. I have tried

... Field('my_question',

requires=[IS_IN_SET([T('Yes'),T('No')]),],

widget=SQLFORM.widgets.checkboxes.widget,

default=T('No'),

),...

I got a nice form with the German translations 'Ja' and 'Nein'.
But now I did not get the English version.

A SELECT like

... SELECT(
  OPTION(T('Yes'), _value='Y'),
  OPTION(T('No'), _value='N'),
  ) ...


works depending on the T-language, but I don't know how to put a "_values"
into the SQLFORM.

Any hints?
Regards, Martin


[web2py] id not starting with 1?

2011-06-30 Thread Martin Weissenboeck
Hi,

is it possible to create a new table with an id-field not starting with 1.
I think it would be better to have numbers of equal length.

And - if it's possible - does it reduce efficiency?

Regards., Martin


Re: [web2py] requires and T()

2011-06-30 Thread Bruno Rocha
IS_IN_SET( [ ('Y',T('Yes')), ('N',T('No')) ] )

Is in set, can receive a list of tuples, where first element is value,
second is text.

On Thu, Jun 30, 2011 at 4:31 PM, Martin Weissenboeck wrote:

> Hi,
>
> I want to use a SQLFORM with a checkbox. I have tried
>
> ... Field('my_question',
>
> requires=[IS_IN_SET([T('Yes'),T('No')]),],
>
> widget=SQLFORM.widgets.checkboxes.widget,
>
> default=T('No'),
>
> ),...
>
> I got a nice form with the German translations 'Ja' and 'Nein'.
> But now I did not get the English version.
>
> A SELECT like
>
> ... SELECT(
>   OPTION(T('Yes'), _value='Y'),
>   OPTION(T('No'), _value='N'),
>   ) ...
>
>
> works depending on the T-language, but I don't know how to put a "_values"
> into the SQLFORM.
>
> Any hints?
> Regards, Martin
>



-- 



--
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] id not starting with 1?

2011-06-30 Thread Richard Vézina
I think it will depend of your database backend and how you setup your
sequence generating... Web2py by default will create a basic sequence then
you should go in your database management software (ex.: pgAdmin for
postgres) to setup the proper caracteristic of your sequence...

Your may override the name of you sequence
with sequence_name='YOURSEQUENCENAME' in your model...

Richard

On Thu, Jun 30, 2011 at 3:34 PM, Martin Weissenboeck wrote:

> Hi,
>
> is it possible to create a new table with an id-field not starting with 1.
> I think it would be better to have numbers of equal length.
>
> And - if it's possible - does it reduce efficiency?
>
> Regards., Martin
>
>
>


Re: [web2py] requires and T()

2011-06-30 Thread Martin Weissenboeck
Great, thank you - it solves the "_value"-problem.

But the other problem is not solved: I get only the translated version
(German), not dependig on the selected language.
I have tried it with T.force('fr-fr') [there is no French translation]. I
have expected 'Yes' and 'No', but I got again 'Ja' and 'Nein'.

And: how to set the default value?


2011/6/30 Bruno Rocha 

> IS_IN_SET( [ ('Y',T('Yes')), ('N',T('No')) ] )
>
> Is in set, can receive a list of tuples, where first element is value,
> second is text.
>
>
> On Thu, Jun 30, 2011 at 4:31 PM, Martin Weissenboeck 
> wrote:
>
>> Hi,
>>
>> I want to use a SQLFORM with a checkbox. I have tried
>>
>> ... Field('my_question',
>>
>> requires=[IS_IN_SET([T('Yes'),T('No')]),],
>>
>> widget=SQLFORM.widgets.checkboxes.widget,
>>
>> default=T('No'),
>>
>> ),...
>>
>> I got a nice form with the German translations 'Ja' and 'Nein'.
>> But now I did not get the English version.
>>
>> A SELECT like
>>
>> ... SELECT(
>>   OPTION(T('Yes'), _value='Y'),
>>   OPTION(T('No'), _value='N'),
>>   ) ...
>>
>>
>> works depending on the T-language, but I don't know how to put a "_values"
>> into the SQLFORM.
>>
>> Any hints?
>> Regards, Martin
>>
>
>
>
> --
>
>
>
> --
> 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 ]
>
>


[web2py] SQL UNIQUE IN WEB2PY : CONSTRAINT unique_test UNIQUE (num_part1, num_part2, num_part3, title)

2011-06-30 Thread Richard Vézina
Hello,

Is it possible to declare UNIQUE constraint over many fields and how...

Does using IS_NOT_IN_DB() on the differents fields will work?

...num_part1.requires=IS_NOT_IN_DB(db((db.ref_fnaregistry.num_part1==request.vars.num_part1)
&
(db.ref_fnaregistry.num_part2==request.vars.num_part2) &
(db.ref_fnaregistry.num_part3==request.vars.num_part3) &

(db.ref_fnaregistry.title==request.vars.title)),db.ref_fnaregistry.num_part1)

etc.

But I think i need to concatenate...

If there is no way I think I know how I will do it.

Richard


Re: [web2py] requires and T()

2011-06-30 Thread Richard Vézina
http://web2py.com/book/default/chapter/04?search=default+language#T-and-Internationalization

Look at default language in this page...

Also default depend of you browser setting...

Richard

On Thu, Jun 30, 2011 at 3:55 PM, Martin Weissenboeck wrote:

> Great, thank you - it solves the "_value"-problem.
>
> But the other problem is not solved: I get only the translated version
> (German), not dependig on the selected language.
> I have tried it with T.force('fr-fr') [there is no French translation]. I
> have expected 'Yes' and 'No', but I got again 'Ja' and 'Nein'.
>
> And: how to set the default value?
>
>
> 2011/6/30 Bruno Rocha 
>
>> IS_IN_SET( [ ('Y',T('Yes')), ('N',T('No')) ] )
>>
>> Is in set, can receive a list of tuples, where first element is value,
>> second is text.
>>
>>
>> On Thu, Jun 30, 2011 at 4:31 PM, Martin Weissenboeck 
>> wrote:
>>
>>> Hi,
>>>
>>> I want to use a SQLFORM with a checkbox. I have tried
>>>
>>> ... Field('my_question',
>>>
>>> requires=[IS_IN_SET([T('Yes'),T('No')]),],
>>>
>>> widget=SQLFORM.widgets.checkboxes.widget,
>>>
>>> default=T('No'),
>>>
>>> ),...
>>>
>>> I got a nice form with the German translations 'Ja' and 'Nein'.
>>> But now I did not get the English version.
>>>
>>> A SELECT like
>>>
>>> ... SELECT(
>>>   OPTION(T('Yes'), _value='Y'),
>>>   OPTION(T('No'), _value='N'),
>>>   ) ...
>>>
>>>
>>> works depending on the T-language, but I don't know how to put a
>>> "_values" into the SQLFORM.
>>>
>>> Any hints?
>>> Regards, Martin
>>>
>>
>>
>>
>> --
>>
>>
>>
>> --
>> 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] requires and T()

2011-06-30 Thread Bruno Rocha
I just tested it and works perfectly.

Are you sure do you have the string translated in language file?

My test:

T.force('pt-br')
print T.accepted_language # printed ok pt-br in terminal

myset = [ ('Y', T('Yes')), ('N', T('No')) ]

db.define_table('question',
Field('my_question',
  requires = [IS_IN_SET(myset)],
  widget = SQLFORM.widgets.checkboxes.widget,
  default = T('No'),
  )
)


I got "Sim" , "Não" in portuguese.

But I needed to update my language files.

On Thu, Jun 30, 2011 at 4:55 PM, Martin Weissenboeck wrote:

> Great, thank you - it solves the "_value"-problem.
>
> But the other problem is not solved: I get only the translated version
> (German), not dependig on the selected language.
> I have tried it with T.force('fr-fr') [there is no French translation]. I
> have expected 'Yes' and 'No', but I got again 'Ja' and 'Nein'.
>
> And: how to set the default value?
>
>
> 2011/6/30 Bruno Rocha 
>
>> IS_IN_SET( [ ('Y',T('Yes')), ('N',T('No')) ] )
>>
>> Is in set, can receive a list of tuples, where first element is value,
>> second is text.
>>
>>
>> On Thu, Jun 30, 2011 at 4:31 PM, Martin Weissenboeck 
>> wrote:
>>
>>> Hi,
>>>
>>> I want to use a SQLFORM with a checkbox. I have tried
>>>
>>> ... Field('my_question',
>>>
>>> requires=[IS_IN_SET([T('Yes'),T('No')]),],
>>>
>>> widget=SQLFORM.widgets.checkboxes.widget,
>>>
>>> default=T('No'),
>>>
>>> ),...
>>>
>>> I got a nice form with the German translations 'Ja' and 'Nein'.
>>> But now I did not get the English version.
>>>
>>> A SELECT like
>>>
>>> ... SELECT(
>>>   OPTION(T('Yes'), _value='Y'),
>>>   OPTION(T('No'), _value='N'),
>>>   ) ...
>>>
>>>
>>> works depending on the T-language, but I don't know how to put a
>>> "_values" into the SQLFORM.
>>>
>>> Any hints?
>>> Regards, Martin
>>>
>>
>>
>>
>> --
>>
>>
>>
>> --
>> 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 ]
>>
>>
>
>


-- 



--
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] Re: reponse.js Update 2 Targets.

2011-06-30 Thread Richard Vézina
Reminder :

When 2 components have to be refresh with on this schema :
"web2py_component('%s',target)" % URL()

response.js="web2py_component('%s','two');" %
URL('ref','create_fvte',args='ref_vregistry')
response.js+="web2py_component('%s','three');" %
URL('ref','create_fvte',args='ref_tregistry')


Richard

On Wed, May 25, 2011 at 8:20 AM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> No your syntax is correct. Can you email me a minimalist app so I can
> try it quickly?
>
> On May 24, 11:05 pm, "David J."  wrote:
> > I am using Trunk;
> >
> > Is my syntax correct?
> >
> > should it be a ',' instead of a ';'
> >
> > response.js =
> > 'web2py_component(url,target),web2py_component(other_url,other_target);'
> >
> > On 5/24/11 11:40 PM, Massimo Di Pierro wrote:
> >
> >
> >
> >
> >
> >
> >
> > > There is no reason why it should not work. Are you using trunk? There
> > > was in bug in stable about response.js.
> >
> > > On May 24, 8:25 pm, "David J."  wrote:
> > >> I was wondering how I can update 2 targets with reponse.js?
> >
> > >> I tried this
> >
> > >> response.js =
> > >>
> 'web2py_component(url,target);web2py_component(other_url,other_target);'
> >
> > >> Seems only the first updated.
> >
> > >> Any ideas?
>


Re: [web2py] slices and generic.load

2011-06-30 Thread Brian M
Thanks for pointing this out Anthony - I'll try to find time to update my 
slice & demo app soon.

~Brian


Re: [web2py] requires and T()

2011-06-30 Thread Martin Weissenboeck
Yes, I have tried it too and the translation works very fine. But my problem
is: how to get the original strings 'Yes' and 'No'
I have forced a language with no translation (in my example
T.force('fr-fr')) and I thought, this would give the original strings. But I
got again the German strings. T.accepted-language is really 'fr-fr'.

2011/6/30 Bruno Rocha 

> I just tested it and works perfectly.
>
> Are you sure do you have the string translated in language file?
>
> My test:
>
> T.force('pt-br')
> print T.accepted_language # printed ok pt-br in terminal
>
> myset = [ ('Y', T('Yes')), ('N', T('No')) ]
>
> db.define_table('question',
> Field('my_question',
>   requires = [IS_IN_SET(myset)],
>   widget = SQLFORM.widgets.checkboxes.widget,
>   default = T('No'),
>   )
> )
>
>
> I got "Sim" , "Não" in portuguese.
>
> But I needed to update my language files.
>
> On Thu, Jun 30, 2011 at 4:55 PM, Martin Weissenboeck 
> wrote:
>
>> Great, thank you - it solves the "_value"-problem.
>>
>> But the other problem is not solved: I get only the translated version
>> (German), not dependig on the selected language.
>> I have tried it with T.force('fr-fr') [there is no French translation]. I
>> have expected 'Yes' and 'No', but I got again 'Ja' and 'Nein'.
>>
>> And: how to set the default value?
>>
>>
>> 2011/6/30 Bruno Rocha 
>>
>>> IS_IN_SET( [ ('Y',T('Yes')), ('N',T('No')) ] )
>>>
>>> Is in set, can receive a list of tuples, where first element is value,
>>> second is text.
>>>
>>>
>>> On Thu, Jun 30, 2011 at 4:31 PM, Martin Weissenboeck >> > wrote:
>>>
 Hi,

 I want to use a SQLFORM with a checkbox. I have tried

 ... Field('my_question',

 requires=[IS_IN_SET([T('Yes'),T('No')]),],

 widget=SQLFORM.widgets.checkboxes.widget,

 default=T('No'),

 ),...

 I got a nice form with the German translations 'Ja' and 'Nein'.
 But now I did not get the English version.

 A SELECT like

 ... SELECT(
   OPTION(T('Yes'), _value='Y'),
   OPTION(T('No'), _value='N'),
   ) ...


 works depending on the T-language, but I don't know how to put a
 "_values" into the SQLFORM.

 Any hints?
 Regards, Martin

>>>
>>>
>>>
>>> --
>>>
>>>
>>>
>>> --
>>> 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 ]
>>>
>>>
>>
>>
>
>
> --
>
>
>
> --
> 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] id not starting with 1?

2011-06-30 Thread Martin Weissenboeck
Thank you for your answer.
I am using the built-in database, sqlite3. Where can I find the "sequence"?

2011/6/30 Richard Vézina 

> I think it will depend of your database backend and how you setup your
> sequence generating... Web2py by default will create a basic sequence then
> you should go in your database management software (ex.: pgAdmin for
> postgres) to setup the proper caracteristic of your sequence...
>
> Your may override the name of you sequence
> with sequence_name='YOURSEQUENCENAME' in your model...
>
> Richard
>
>
> On Thu, Jun 30, 2011 at 3:34 PM, Martin Weissenboeck 
> wrote:
>
>> Hi,
>>
>> is it possible to create a new table with an id-field not starting with 1.
>> I think it would be better to have numbers of equal length.
>>
>> And - if it's possible - does it reduce efficiency?
>>
>> Regards., Martin
>>
>>
>>


[web2py] Re: id not starting with 1?

2011-06-30 Thread GoldenTiger
Well, length of  an integer field is always the same...
but I understand what you want to mean, because I am on the same
situation

I guess you are looking for an ID to identify records, but It's not
convenient that the ID indicates the order of creation

In my case, is the affiliate ID, and I've been asked generating an 3
or 4 digits number automatically,
also I need multiple database syncronization, so I am thinking on
creating an auxiliar table with indexes

Anyone has a simpler solution?


On Jun 30, 9:34 pm, Martin Weissenboeck  wrote:
> Hi,
>
> is it possible to create a new table with an id-field not starting with 1.
> I think it would be better to have numbers of equal length.
>
> And - if it's possible - does it reduce efficiency?
>
> Regards., Martin


[web2py] Re: Image upload filenames too long

2011-06-30 Thread Rowdy

pbreit wrote:
The filename that Web2py is giving my uploaded images is too long. Is it 
possible to make it shorter?


For example (i need them to be under 150 chars):
item.image.8651e61b27b66998.6974656d2e696d6167652e396363373962663466616535313834392e3533353434313566333233323331333432653461353034375f646973706c61792e6a706567.jpeg


Greetings,

I encountered something similar a while ago, and Massimo was good enough 
to implement a small change.


In dal.py there is a line that truncates long filenames:

class Field(Expression):

def store(...):

newfilename = newfilename[:200] + '.' + extension

I suspect you would be able to replace 200 with 150 (or slightly less if 
your 150 characters needs to include the dot and extension).


Rowdy



[web2py] Re: Image upload filenames too long

2011-06-30 Thread pbreit
Yeah, I did find your original thread after some searching. And wondered if 
it might be worth either shortening outright or making it configurable. I've 
implemented 50 chars which seems like plenty to me.

[web2py] Re: id not starting with 1?

2011-06-30 Thread pbreit
By far the easiest is to use id and not worry about it.

If it's that important, I would suggest leaving id as-is and either adding a 
new field or using a virtual field that does a simple hash. I've seen hashes 
as simple as multiplying by a small prime number like 1007.

So:
Field('bigid', 'integer')
db.mytable.bigid.default = lambda r: r.id * 1007

And then always use bigid.


Re: [web2py] SQL UNIQUE IN WEB2PY : CONSTRAINT unique_test UNIQUE (num_part1, num_part2, num_part3, title)

2011-06-30 Thread pbreit
UNIQUE applies at the database level. IS_NOT_IN_DB applies during form 
validation.

I'm not sure that's going to work. Maybe a custom validator?
http://web2py.com/book/default/chapter/07#Custom-Validators




Re: [web2py] SQL UNIQUE IN WEB2PY : CONSTRAINT unique_test UNIQUE (num_part1, num_part2, num_part3, title)

2011-06-30 Thread Anthony
IS_NOT_IN_DB does take a DAL Set object as the first argument, so you can 
limit the records checked to a particular set within the table (see 
http://web2py.com/book/default/chapter/07#Database-Validators). However, I'm 
not quite sure what you're trying to do here.

On Thursday, June 30, 2011 4:27:56 PM UTC-4, Richard wrote:

> Hello, 
>
> Is it possible to declare UNIQUE constraint over many fields and how...
>
> Does using IS_NOT_IN_DB() on the differents fields will work?
>
>  
> ...num_part1.requires=IS_NOT_IN_DB(db((db.ref_fnaregistry.num_part1==request.vars.num_part1)
>  
> & 
> (db.ref_fnaregistry.num_part2==request.vars.num_part2) & 
> (db.ref_fnaregistry.num_part3==request.vars.num_part3) & 
> 
> (db.ref_fnaregistry.title==request.vars.title)),db.ref_fnaregistry.num_part1)
>
> etc.
>
> But I think i need to concatenate...
>
> If there is no way I think I know how I will do it.
>
> Richard
>


[web2py] Unable to edit records in appadmin due to fk constraint

2011-06-30 Thread pbreit
I'm still having trouble editing records in appadmin due to a foreign key 
constraint. Even though I'm logged in as auth_user.id=5, it's trying to set 
modified_by=0. This was in trying to update a custom auth_user table which 
has an auth.signature.


Traceback (most recent call last):
  File "/opt/web2py/gluon/restricted.py", line 192, in restricted
exec ccode in environment
  File "/opt/web2py/applications/init/controllers/appadmin.py", line 410, in 

  File "/opt/web2py/gluon/globals.py", line 137, in 
self._caller = lambda f: f()
  File "/opt/web2py/applications/init/controllers/appadmin.py", line 277, in 
update
if form.accepts(request.vars, session):
  File "/opt/web2py/gluon/sqlhtml.py", line 1203, in accepts
self.table._db(self.table._id == self.record.id).update(**fields)
  File "/opt/web2py/gluon/dal.py", line 5407, in update
return self.db._adapter.update(tablename,self.query,fields)
  File "/opt/web2py/gluon/dal.py", line 1002, in update
self.execute(sql)
  File "/opt/web2py/gluon/dal.py", line 1251, in execute
return self.log_execute(*a, **b)
  File "/opt/web2py/gluon/dal.py", line 1246, in log_execute
ret = self.cursor.execute(*a,**b)
IntegrityError: insert or update on table "auth_user" violates foreign key 
constraint "auth_user_modified_by_fkey"
DETAIL:  Key (modified_by)=(0) is not present in table "auth_user".


[web2py] Dropdown field not being accepted

2011-06-30 Thread Happy Rob
Hi
I'm looking at doing a neural net 20 questions type program at some
stage, but still having difficulty with the basics.
Currently if I do a dropdown field, it won't let me enter the data
unless the question on the NEXT screen is the same as this one.
I know it's something to do with the fact that I'm deliberately
relooping through the same page with different data, but it shouldn't
reloop BEFORE it's verified and entered the data, should it?
After all, it has to use X just to do the dropdown, and the x hasn't
changed before you enter the data.

def l():
 from random import randint
 row = 1
 f1=db().select(db.questions.ALL,orderby=db.questions.id)
 f2=db().select(db.answers.ALL,orderby=db.answers.id)
 f3=db().select(db.big.ALL,orderby=db.big.id)
 f4=db(db.big.id == row).select() #This is last row, the stuff
currently being entered

#QUESTION_AND_ANSWER

 x=randint(1,3)
 question_asking = db(db.questions.q_number == x).select()[0].q_para01
 your_answer = SQLFORM.factory(Field('reply',requires =
IS_IN_DB(db(db.answers.q_number == x),"answers.id",'%
(a_options)s')))

#fill in correct row
 if your_answer.accepts(request.vars,session):
  put_in_big = db(db.answers.number == your_answer.vars.reply).select()
[0].a_options
  if x == 1:
   db(db.big.number == row).update(col01=put_in_big)
  if x == 2:
   db(db.big.number == row).update(col02=put_in_big)
  if x == 3:
   db(db.big.number == row).update(col03=put_in_big)
  redirect(URL('l'))

 return
dict(f1=f1,f2=f2,f3=f3,f4=f4,x=x,question_asking=question_asking,your_answer=your_answer,row=row)


(These been imported)
TABLE questions
questions.id,questions.q_number,questions.q_para01
1,1,'Q1 Where are you?'
2,2,'Q2 Are you a tiger?'
3,3,'Q3 Are you a shark?'


TABLE answers
answers.id,answers.q_number,answers.a_options,answers.a_value
1,1,'Land',1
2,1,'Sea',1
3,2,'Yes',1
4,2,'No',2
5,3,'Yes',1
6,3,'No',2

I would really appreciate figuring this out - I've been stuck for a
couple of weeks on this.


[web2py] Hiding submit button on Crud forms

2011-06-30 Thread mr.freeze
Hello! I've been away for a while but am diving back into web2py for a
new project.  I want to host my Crud forms in jqueryui dialogs so I
need to hide the submit button. I know I can do it using
form.element("input",_type="submit")["_style"] = "display:none;"
trickery but I want to avoid extra processing like this. With SQLFORM
you can pass buttons=[] but not so much with Crud. Am I just missing
it?


Re: [web2py] slices and generic.load

2011-06-30 Thread Brian M
Both slice & bitbucket repo should be fixed to work with web2py 1.97.1 now - 
Thanks Richard for pointing this out and Anthony for helping to explain the 
problem.  Let me know if there are more issues.

~Brian


Re: [web2py] SQL UNIQUE IN WEB2PY : CONSTRAINT unique_test UNIQUE (num_part1, num_part2, num_part3, title)

2011-06-30 Thread Nick Arnett
On Thu, Jun 30, 2011 at 4:15 PM, Anthony  wrote:

> IS_NOT_IN_DB does take a DAL Set object as the first argument, so you can
> limit the records checked to a particular set within the table (see
> http://web2py.com/book/default/chapter/07#Database-Validators). However,
> I'm not quite sure what you're trying to do here.
>
> I think what he wants is the equivalent of Django's "unique together",
which I'm also trying to figure out.  IS_NOT_IN_DB seems to accomplish it,
but is that going to create a unique index on the combined fields?
 Otherwise, it will be expensive to do inserts.

Nick


Re: [web2py] SQL UNIQUE IN WEB2PY : CONSTRAINT unique_test UNIQUE (num_part1, num_part2, num_part3, title)

2011-06-30 Thread Anthony
On Thursday, June 30, 2011 9:43:39 PM UTC-4, Nick Arnett wrote: 
>
>
>
> On Thu, Jun 30, 2011 at 4:15 PM, Anthony  wrote:
>
>> IS_NOT_IN_DB does take a DAL Set object as the first argument, so you can 
>> limit the records checked to a particular set within the table (see 
>> http://web2py.com/book/default/chapter/07#Database-Validators). However, 
>> I'm not quite sure what you're trying to do here.
>>   
>> I think what he wants is the equivalent of Django's "unique together", 
> which I'm also trying to figure out.  IS_NOT_IN_DB seems to accomplish it, 
> but is that going to create a unique index on the combined fields? 
>  Otherwise, it will be expensive to do inserts.
>
 
I don't think web2py automatically creates any indexes -- see 
http://web2py.com/book/default/chapter/06#Indexes.
 


Re: [web2py] SQL UNIQUE IN WEB2PY : CONSTRAINT unique_test UNIQUE (num_part1, num_part2, num_part3, title)

2011-06-30 Thread Nick Arnett
On Thu, Jun 30, 2011 at 6:43 PM, Nick Arnett  wrote:

>
>
> On Thu, Jun 30, 2011 at 4:15 PM, Anthony  wrote:
>
>> IS_NOT_IN_DB does take a DAL Set object as the first argument, so you can
>> limit the records checked to a particular set within the table (see
>> http://web2py.com/book/default/chapter/07#Database-Validators). However,
>> I'm not quite sure what you're trying to do here.
>>
>> I think what he wants is the equivalent of Django's "unique together",
> which I'm also trying to figure out.  IS_NOT_IN_DB seems to accomplish it,
> but is that going to create a unique index on the combined fields?
>  Otherwise, it will be expensive to do inserts.
>

Actually, I don't see how NOT_IN_DB can accomplish this, since it is
associated with a single field.  Do I have to create an extra concatenated
field and make it unique?  Seems silly, given that's what a database unique
index is.

In other words, for table foo, if I want fields A, B and C to be unique
together, do I have to do this?

db.define_table('foo', Field('A'), Field('B'), Field('C'),
Field('ABC_unique', unique=True))

And remember to concat A, B, and C into that last field every time I do an
insert?

I'm missing something here, since this is so simple elsewhere.

Nick


Re: [web2py] SQL UNIQUE IN WEB2PY : CONSTRAINT unique_test UNIQUE (num_part1, num_part2, num_part3, title)

2011-06-30 Thread Nick Arnett
On Thu, Jun 30, 2011 at 7:00 PM, Anthony  wrote:
>
>
> I don't think web2py automatically creates any indexes -- see
> http://web2py.com/book/default/chapter/06#Indexes.
>
>

It has to!  Can't have primary keys without them.  But I see what you mean,
looking at the docs.

I guess I will just use that approach to create a multi-column unique
index but at this point I was really hoping to avoid raw SQL.

Nick


[web2py] Re: slices and generic.load

2011-06-30 Thread Massimo Di Pierro
about the slices... some of us are writing a book on recipes and I we
are using some ideas from the slices. I am finding a lot of good ideas
but some of the slices are old and can be improved a lot using new
syntax. I cannot share the text of the book for copyright issue but I
will share the code examples when done so the slices can be improved
and new code checked for errors.

Massimo


Re: [web2py] SQL UNIQUE IN WEB2PY : CONSTRAINT unique_test UNIQUE (num_part1, num_part2, num_part3, title)

2011-06-30 Thread pbreit
Custom Validator still seems like the best option:
http://web2py.com/book/default/chapter/07#Custom-Validators

Although I think unique_together is implemented via db constraints.

That seems like a very remote scenario so probably not outlandish that it 
takes a little code.

Postgres, at least, automatically creates the index for primary keys. 
Otherwise, Web2py does not create any indexes. Validators, by the way, are 
enforced at the form level and have no direct effect on the db.


[web2py] Re: slices and generic.load

2011-06-30 Thread pbreit
Does that mean anything that goes in the book cannot be posted and modified 
elsewhere? I'd much rather see a more permissive resource. The copyright and 
licensing issues in this community are unfortunate to say the least.

[web2py] Re: Dropdown field not being accepted

2011-06-30 Thread pbreit
Everything above the "if form.accepts()" is run each time the submit button 
is pressed.

I can't think of the best way to implement this off-hand. It does seem like 
you could do it all in one controller.

There's a pretty old survey app which might give you some ideas:
http://www.web2py.com/appliances/default/show/66


[web2py] Re: Unable to edit records in appadmin due to fk constraint

2011-06-30 Thread pbreit
Does anyone here edit records in /appadmin on a postgres db? It should work, 
right?

Re: [web2py] Re: slices and generic.load

2011-06-30 Thread Bruno Rocha
On Thu, Jun 30, 2011 at 11:46 PM, pbreit  wrote:

> Does that mean anything that goes in the book cannot be posted and modified
> elsewhere? I'd much rather see a more permissive resource. The copyright and
> licensing issues in this community are unfortunate to say the least.


Massimo is not referring the "web2py official book" , he is talking about
another book.

-- 



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


[web2py] looks familiar, could be useful

2011-06-30 Thread Massimo Di Pierro
https://github.com/MisterRager/DOMination


Re: [web2py] Re: slices and generic.load

2011-06-30 Thread pbreit
Yes, I was concerned with the other book. But it'd also be nice if the Book 
content could be used in different ways, too.

Re: [web2py] Problem with 1.97.1??

2011-06-30 Thread José Luis Redrejo Rodríguez
Yor're facing to a reported bug. In the bug report you can find a workaround
to continue working: http://code.google.com/p/web2py/issues/detail?id=319


2011/6/30 Jim Steil 

>  Hi
>
> I have an app I've been working on and upgraded my system to 1.97.1 today.
> Since then I'm getting the following with an AJAX call for json data:
>
> Traceback (most recent call last):
>   File "gluon/restricted.py", line 192, in restricted
>   File "C:/dev/web2py/applications/InfoCenter/controllers/administration.py" 
> ,
>  line 862, in 
>   File "gluon/globals.py", line 137, in 
>   File "C:/dev/web2py/applications/InfoCenter/controllers/administration.py" 
> ,
>  line 17, in call
>   File "gluon/tools.py", line 3918, in __call__
>   File "gluon/tools.py", line 3734, in serve_json
>   File "gluon/tools.py", line 3404, in universal_caller
> TypeError: object of type 'NoneType' has no len()
>
>
> My call from my template looks like this:
>
> jQuery(document).ready(function(){
>   jQuery("#list").jqGrid({
> url:'/InfoCenter/administration/call/json/userList',
> datatype: 'json',
> postData:{'searchText':$("#searchText").val()},
> colModel :[ {
> name:'id',
> index:'id',
> label:'ID',
> hidden:true,
> },
> {
> name:'lastFirst',
> index:'lastFirst',
> width:'50%',
> label:'Name',
> },
> {
> name:'email',
> index:'email',
> width:'50%',
> label:'Email',
> },
>
> ],
> pager: '#pager',
> rowNum:20,
> sortname: "lastFirst",
> sortorder: 'asc',
> width: 875,
> height: "100%",
> ondblClickRow: function(){
> var row_id = $("#list").getGridParam('selrow');
> window.location.href = "/InfoCenter/administration/user/" + row_id;
> return true;
> },
> caption:'',
>   });
>   jQuery("#list").navGrid("#pager",
>   {edit:false,add:false,del:true,search:false},
>   {},
>   {},
>   {msg:"Delete selected row(s)",
>   bSubmit:"Delete",
>   bCancel:"Cancel",
>   url:"/InfoCenter/administration/userDelete",
>   reloadAfterSubmit:true}
>   );
> });
>
> This works in the 1.96.x branches by not 1.97.1.  And, it never gets to the
> method in the controller.  Line in administration.py is the last line of the
> call() method:
>
> and line 862 doesn't exist in the controller, it ends at 861:
>
>
> Any thoughts?  I'm stumped (but also pretty new to web2py).
>
> -Jim
>
<><>