[web2py] Re: Detecting test vs. production environments

2011-02-02 Thread ron_m
I put all my production vs developer settings in an if else block and use my 
own variable PRODUCTION. This is in the model directory and named 
0_customization.py in my case. This allows you to set the migrate, 
local_import reload parameter and anything else you want. Then I just need 
to remember to set the flag True or False depending on the situation.

RMMV

Ron


[web2py] Re: Detecting test vs. production environments

2011-02-02 Thread Dane
I'm doing something similar for configuration, but I'd really like to
find a way to detect this setting automatically instead of setting a
flag which just adds needless complexity to my git deployments. All I
really need is a way to reliably check the full url of my app as the
client sees it, and I need it to be available when the first models
are being exec'd.

On Feb 2, 3:01 am, ron_m  wrote:
> I put all my production vs developer settings in an if else block and use my
> own variable PRODUCTION. This is in the model directory and named
> 0_customization.py in my case. This allows you to set the migrate,
> local_import reload parameter and anything else you want. Then I just need
> to remember to set the flag True or False depending on the situation.
>
> RMMV
>
> Ron


[web2py] Re: execfile

2011-02-02 Thread Tom Atkins
See Massimo's response here:

https://groups.google.com/forum/#!topic/web2py/dmN54cpMuXo


[web2py] Re: web2py exec in the new again

2011-02-02 Thread desfrenes
On 1 fév, 21:16, Massimo Di Pierro  wrote:

> In web2py you cannot store instances of objects into session. While
> Armin makes it tool like this is a web2py problem this is more complex
> and general than that. In Python if you pickle and object that is
> instance of a class defined in /path1/mymodule.py and then you
> unpickle on a different installation where the class is defined in /
> path2/mymodule.py you may run into problems. Because web2py does not
> require installation (it is a feature) and has hot plug and play of
> apps (another feature) we cannot pickle instances (the price we pay
> for those features). To me it is worth it.

I know for experience that storing instances in session is usually a
bad application design idea.


[web2py] Re: execfile

2011-02-02 Thread desfrenes
Yes, I read it.

Anyway, thank you Massimo for keeping python web development out of
the wannabe-java & everything-should-be-made-standard syndroms.

And the statement about web2py being harmful to the python community
is just shit. Web2py was the one framework that got me interested in
python web development and I have yet to see another platform with
such ease of use.


On 2 fév, 09:56, Tom Atkins  wrote:
> See Massimo's response here:
>
> https://groups.google.com/forum/#!topic/web2py/dmN54cpMuXo


[web2py] Mac OSX server startup files

2011-02-02 Thread rif
I made web2py autostart on a mac osx server conforming to 
tutorial
.

Install web2py in /Applications folder.
The StartupParameters.plist must be placed in the /Library/StartupItems/ (if 
you don't have one already).
Then create a directory named web2py in the same location 
(/Library/StartupItems/) and place the web2py shell file in it.
Make web2py file executable like this: chmod 
+x /Library/StartupItems/web2py/web2py

You can use the following command now:

sudo /Library/StartupItems/web2py/web2py start
sudo /Library/StartupItems/web2py/web2py restart
sudo /Library/StartupItems/web2py/web2py stop

The autostart feature is not tested as I created them on a production server 
and I cannot restart it.

StartupParameters.plist:

Description web2py 
Provides  web2py  
Requires  Network  
OrderPreference Late  

web2py:
#!/bin/sh . /etc/rc.common StartService( ) { ConsoleMessage "Starting 
web2py" /Applications/web2py.app/Contents/MacOS/web2py -a "" -i 
0.0.0.0 -p 8000 -d /var/run/web2py.pid & } StopService( ) { ConsoleMessage 
"Stopping web2py" kill `cat /var/run/web2py.pid` } RestartService( ) { 
ConsoleMessage "Restarting web2py" StopService StartService } RunService 
"$1"


[web2py] Defualt values with DAL and define_table

2011-02-02 Thread vortex
Is it possible to make the default value of one column the
mathematical result of two other columns?


[web2py] Re: Defualt values with DAL and define_table

2011-02-02 Thread Jose


On 2 feb, 07:43, vortex  wrote:
> Is it possible to make the default value of one column the
> mathematical result of two other columns?

Yes you can, please look at [1]

Regards,
Jose


[1] http://www.web2py.com/book/default/chapter/06#Computed-Fields


Re: [web2py] jQuery 1.5 released

2011-02-02 Thread Plumo
For a while now I have been running my apps off the latest version on 
Google's CDN and haven't noticed any problems.

http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js


Re: [web2py] jQuery 1.5 released

2011-02-02 Thread rif
Google is still on 1.4.4 (including your link).

[web2py] upload an excel sheet to be added to the system

2011-02-02 Thread Neveen Adel
Hello,

Is there a  library that can be used to import an excel file that
insert records in a specific  table ?

If there is no a library how can i do that ?

Thanks in Advance


Re: [web2py] jQuery 1.5 released

2011-02-02 Thread w2padawan
I second why massimo said. worth to wait a while to include 1.5 in
web2py officials

2011/2/2 rif :
> Google is still on 1.4.4 (including your link).


Re: [web2py] jQuery 1.5 released

2011-02-02 Thread w2padawan
2011/2/2 w2padawan :
> I second why massimo said. worth to wait a while to include 1.5 in
> web2py officials
>
fe de errata:
I second *what* massimo said. worth to wait a while to include 1.5 in
web2py officials


Re: [web2py] upload an excel sheet to be added to the system

2011-02-02 Thread Kenneth Lundström
I know you can import/export CSV-files and export XLS files. But I don´t 
know if there is a way to import XLS files directly.



Kenneth


Hello,

Is there a  library that can be used to import an excel file that
insert records in a specific  table ?

If there is no a library how can i do that ?

Thanks in Advance




[web2py] Re: upload an excel sheet to be added to the system

2011-02-02 Thread Neveen Adel
Hello Kenneth,

 Thanks for your reply:)

It is ok about import/export CSV files, How can i do this into my
application ?

On Feb 2, 3:39 pm, Kenneth Lundström 
wrote:
> I know you can import/export CSV-files and export XLS files. But I don t
> know if there is a way to import XLS files directly.
>
> Kenneth
>
> > Hello,
>
> > Is there a  library that can be used to import an excel file that
> > insert records in a specific  table ?
>
> > If there is no a library how can i do that ?
>
> > Thanks in Advance
>
>


[web2py] Re: Deployment Confusion

2011-02-02 Thread Gary Bee
Just to follow up on my troubles so far...
I have deployed my site using google app engine, just to get it out
there. I have adjusted the setting as described in the app engine
documentation to get my domain forwarded (is that the right term) to
google app engine.
I had no succes when trying 
http://www.web2pyslices.com/main/slices/take_slice/76
via SSH, I think because of the limitations godaddy has on its shared
hosts.
I have it in mind for the future to use an alternative hosting
provider or to upgrade my hosting on godaddy to a dedicated linux
server.

On Jan 30, 7:35 pm, "g...@rtplanb.com"  wrote:
> Thank you all for your help so far.
> I will try your suggestions. I can get SSH access to my host.
> It runs Python 2.4.3
> and Linux distro is quoted as: Linux
> n1nlftpg005.shr.prod.ams1.secureserver.net 2.6.18-194.26.1.el5PAE #1
> SMP Tue Nov 9 13:34:42 EST 2010 i686 i686 i386 GNU/Linux
>
> On Jan 30, 4:46 pm, Bruno Rocha  wrote:
>
>
>
> > AS I said,I know only two host options where you can simply put the files
> > there and everything runs without the need of configuration. ['Google App
> > Engine', 'webfaction']
>
> > In other shared hosts you need to follow some deployment instruction:
>
> > I guess this slice works for 
> > godaddyhttp://www.web2pyslices.com/main/slices/take_slice/76
>
> > or if you have a VPS you can use deployment script on /scripts folder, or
> > follow this slices (deppending on your VM 
> > setup)http://web2pyslices.com/main/slices/take_slice/110http://web2pyslices...
>
> > Here in Brazil, we have a shared host (kinghost.com.br) that has 'One Click
> > Install for web2py' in control panel, but I dont know any other.
>
> > In the bookhttp://web2py.com/book/default/chapter/11youcan find
> > information needed to setup web2py with wsgi, mod_wsgi and mod_python.
>
> > Python web apps (indepent of teh framework you are using) works in a
> > different way of PHP or ASP applications.
>
> > Do you know exactly what is the setup provided by GoDaddy? Python Version,
> > Linux Distro?- Hide quoted text -
>
> - Show quoted text -


Re: [web2py] Re: migration from 1.88.2 to 1.91.6 problem

2011-02-02 Thread Richard Vézina
True

Richard

On Wed, Feb 2, 2011 at 12:20 AM, Marin Pranjic wrote:

> ### this happens because FROM has no knowledge of writable
> ### and thinks that a missing boolean field is a None
> if self.table[fieldname].type == 'boolean' and
> self.vars[fieldname]==None:
> del self.vars[fieldname]
>
> these are in red
>
> On Wed, Feb 2, 2011 at 12:19 AM, Massimo Di Pierro <
> massimo.dipie...@gmail.com> wrote:
>
>> Which ones are in red?
>>
>> On Feb 1, 1:13 pm, Richard Vézina  wrote:
>> > Hello,
>> >
>> > If I change erase those line (in red) in /gluon/sqlhtml.py
>> >
>> >  if not self.ignore_rw and not self.table[fieldname].writable:
>> > ### this happens because FROM has no knowledge of
>> writable
>> > ### and thinks that a missing boolean field is a None
>> > if self.table[fieldname].type == 'boolean' and
>> > self.vars[fieldname]==None:
>> > del self.vars[fieldname]
>> > continue
>> >
>> > It solves the problem... But I don't have clue of what the impacts are
>> on
>> > web2py.
>> >
>> > I use Postgres as backend...
>> >
>> > I will try to write a demo app to reproduce de problem...
>> >
>> > Richard
>> >
>> > On Tue, Feb 1, 2011 at 12:49 PM, Richard Vézina <
>> ml.richard.vez...@gmail.com
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > > wrote:
>> > > Hello,
>> >
>> > > I am not sure where it comes from the problem I face, but for sure it
>> comes
>> > > from 1.91.6 because I dont have the probleme with the exact same app
>> under
>> > > 1.88.2.
>> >
>> > >  1.
>> > > 2.
>> > > 3.
>> > > 4.
>> > > 5.
>> > > 6.
>> > > 7.
>> > > 8.
>> > > 9.
>> > > 10.
>> > > 11.
>> > > 12.
>> > > 13.
>> > > 14.
>> >
>> > > Traceback (most recent call last):
>> >
>> > >   File "/home/www-data/web2py/gluon/restricted.py", line 188, in
>> restricted
>> >
>> > > exec ccode in environment
>> >
>> > >   File "/home/www-data/web2py/applications/init/controllers/test.py",
>> line 855, in 
>> >
>> > >   File "/home/www-data/web2py/gluon/globals.py", line 95, in 
>> >
>> > > self._caller = lambda f: f()
>> >
>> > >   File "/home/www-data/web2py/gluon/tools.py", line 2297, in f
>> >
>> > > return action(*a, **b)
>> >
>> > >   File "/home/www-data/web2py/applications/init/controllers/test.py",
>> line 410, in update
>> >
>> > > if form.accepts(request.vars, session):
>> >
>> > >   File "/home/www-data/web2py/gluon/sqlhtml.py", line 1091, in accepts
>> >
>> > > if self.table[fieldname].type == 'boolean' and
>> self.vars[fieldname]==None:
>> > > KeyError: 'valid'
>> >
>> > > I have a field name "valid" in my models... May be it conflict with
>> the new
>> > > DAL??
>> >
>> > > Thanks
>> >
>> > > Richard
>>
>
>


[web2py] Multiple users on computer and authorization with Janrian (RPX)

2011-02-02 Thread devGS
Hi,
I found the following problem while with Janrain's authorization, and
would like to know if there is a way to fix it within web2py:
While testing RPX logging-in in my app, I tried to login, logged out
and passed the computer to my mate who logged in to my app with his
own account. At first, there was a minor problem: even though I logged
out from my account, he could login into my account, unless he pressed
"It's not me". So there is no a "Forget me" option.
Than came the major problem(s): my mate logged out from my app. In
order to disallow me to login with his account into the different
services where Janrain is being used, I logged in the with my account
to my app using Janrain and the "It's not me" option. I went to a
different site (with RPX) that I tend to use, tried to login and the
mate's account pooped up. So far I'd gotten enough bugs, but it didn't
stop here: I logged in with my account to that website, logged out
from my account in my app and tried to login again. Mate's account
popped up at this point, my mate was near me so I tried to log in with
his account into my web2py app. When I logged in with his account, the
app recognized my account.

Question: is it possible to fix at least the last issue within web2py?
Thanks.


Re: [web2py] Re: upload an excel sheet to be added to the system

2011-02-02 Thread Bruno Rocha
Take a look at this pack:http://www.python-excel.org/

Bruno Rocha
http://about.me/rochacbruno/bio


Conceptual web2py (was Re: [web2py] Re: Kudos for web2py!)

2011-02-02 Thread Offray Vladimir Luna Cárdenas
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi,

El 01/02/11 19:58, mikech escribió:
> Ok a link would be useful: 
> http://smalltalkzen.wordpress.com/2011/02/01/a-secret-passion-and-your-choice-of-web-framework/
> 

Thanks for the link and the quote from it. It touch my experience in
some kind of special way. I think that Squeak/Smalltalk and web2py share
as a key feature the idea of being designed with learning in mind. In
fact my background teaching "Informatics" (not "computer science") in
this part of the world deals with learning using computers as cognitive
devices to create and make explicit models in your head. That's why I
have being using Scheme, Python and Squeak/Scratch to freshmen in their
"introduction to informatics" courses. My biggest interest is not
programming per se, but instead modeling and we see this in a richer
context that includes social correlates on informatics (piracy,
copyright, copyleft, creative commons and so on), so we never go deep in
programming and I don't consider myself a programmer but more like an
eternal newbie.

Coming from my experience with Smalltalk/Squeak and having to deal with
making models in my mind explicit in a web environment, I consider
Seaside for a while, but choose finally web2py for the reasons tell in
the article you reference that to me are an expression of the key
features of web2py: self-contained, minimalist, complete, extensible and
learning-oriented. I think that is the only one web framework that is
designed taking into account the digital divide, as introduction says
and this is not a minor feature, but a major concern about how
technology can make lives better, no matter where you live.

One of the things that I have being thinking is about the future of
web2py, even more now that Massimo is thinking in the "py" part of it
and this is related with another piece of the article you refer:

- --->
"Then what am I doing here? Why isn’t this blog called “web2py Zen”?
Because, I believe that the features that make web2py fantastic (like
comprehensive documentation, out-of-the-box authentication and user
management, ease of use and diversity of persistence options, amazing
error logging capabilities, etc) can be added to Seaside – with some
effort, but it’s not impossible. Whereas the key features of Seaside
(the continuations, the reuse and embedding of components, Halos and the
debugging process) cannot be easily (or at all) added to web2py.
Smalltalk (and Seaside) is fundamentally “upstream” to Python, in the
sense that Paul Graham writes about"
<---

I would like to have some kind of philosophical discussion on this
issues. Maybe the real future of computing is more related with things
like COLA (Collaborative Object Lambda Architecture)[1][2][3] and what
you could build on them, without sacrifice for example the syntax and
semantics you know but without being limited by them and even trying to
build "one language to rule them all" instead of having to learn python,
CSS, HTML, Javascript, databases as in the web programming world of today.

One of the things that surprise me more is on one hand the physics
background of Massimo and in the other the friendly character of this
community, so I think that this kind of conceptual discussions are not
away of this list even if newbies like me don't understand the technical
details of the day to day talks about databases and programming.

Thanks,

Offray

[1] Getting The Message Steps Toward The Reinvention of Programming A
Compact And Practical Model of Personal Computing As A
Self-Exploratorium By Alan Kay, Dan Ingalls, Yoshiki Ohshima, Ian
Piumarta, Andreas Raab. http://irbseminars.intel-research.net/AlanKayNSF.pdf

[2] An evolving whitepaper about the "combined object-lambda
abstractions" http://piumarta.com/papers/colas-whitepaper.pdf

[3] Ian Piumarta Slides Pdf
http://piumarta.com/papers/EE380-2007-slides.pdf
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJNSXTgAAoJEGiex2828ICwB/oH/0i3Jqb8XmZgooNc8E2Lpd8S
ynpwPp69AeE1XhuvSqW8TC6mhotIY3DTJh2X8hSrJKw5QK2WQrsiBChSJjSEuqlh
10jOJAc/SSnUj5qO0sV/4Q1OwhIy41KCbawFiuLy+JtGPmkctLrIorquZNU1++77
6Kn+FK5KPcLiFd6D1HGKzQs4MGBK8JeJzpWACHxmRdHxuZZzJUYc11HfvGbOxLp+
kwMfIJhnxkYpgSKZs3+BhO/W3ItWZWpyyalTL7P+rupvPvgud7zUWh7+8uG64swf
2v83hacrfLzqlGilXoysiiAGrAOCPMYtNxJm7z+h7tnWGvoyMwtO1MxxPMcktAE=
=T0wz
-END PGP SIGNATURE-


Re: [web2py] Re: Important Pycon 2011

2011-02-02 Thread James Hancock
I want to go so bad!

I am making it to the conference, but to poor to get there two days early...
I am Staying for the sprints afterword, and will be hacking on
https://launchpad.net/pybookbuilder.

Any plans for web2py work?

I would love to participate if there is, especially if there is something
with writing tests or documentation(sphinx anyone?).

Once I get back to the US I plan on hitting web2py in a big way, both for
personal and professional projects. No better way to start than at pycon. :)

Cheers,
James Hancock


On Sat, Jan 29, 2011 at 10:12 AM, Anthony  wrote:

> Massimo offered to reimburse $70 of the registration fee to the first 5
> people to sign up. I'm not sure if I'm in the first 5 (registered on Jan.
> 16), but if I am, I offer my $70 reimbursement to whoever signs up next. : )
>
> I hope they don't cancel it -- I'm looking forward to meeting some other
> web2py users in person.
>
> See you in Atlanta.
>
> Anthony
>
>
> On Friday, January 28, 2011 4:20:18 PM UTC-5, Massimo Di Pierro wrote:
>
>> The web2py Python tutorial has 8 registered participants. That is not
>> god enough. There is still a possibility it may be cancelled.
>>
>> I am told web2py is easy and perhaps people do not need a tutorial but
>> I promise I will do my best to cover things you probably do not know
>> and make it worthwhile.
>>
>> So if you are planning to attend PyCon 2011, I encourage to register
>> for the web2py tutorial "web2py secrets" and some of the other
>> excellent tutorials.
>>
>> Massimo
>>
>


[web2py] Mixing/supporting CMS with Web2py

2011-02-02 Thread Carl
has anyone direct experience of using Wordpress, SquareSpace or
similar solution alongside Web2py?

These solutions appeal for their maturity and I'd like to use one to
do the "donkey" work and fall back to Web2py to do my site's specific
functionality.

Without them I feel like I'm reinventing needlessly.


Re: [web2py] Re: Detecting test vs. production environments

2011-02-02 Thread Vinicius Assef
Try to check the REMOTE_HOST.

If it is "localhost", it is local.



On Wed, Feb 2, 2011 at 6:09 AM, Dane  wrote:
> I'm doing something similar for configuration, but I'd really like to
> find a way to detect this setting automatically instead of setting a
> flag which just adds needless complexity to my git deployments. All I
> really need is a way to reliably check the full url of my app as the
> client sees it, and I need it to be available when the first models
> are being exec'd.
>
> On Feb 2, 3:01 am, ron_m  wrote:
>> I put all my production vs developer settings in an if else block and use my
>> own variable PRODUCTION. This is in the model directory and named
>> 0_customization.py in my case. This allows you to set the migrate,
>> local_import reload parameter and anything else you want. Then I just need
>> to remember to set the flag True or False depending on the situation.
>>
>> RMMV
>>
>> Ron


[web2py] onaccept after user registers;

2011-02-02 Thread David J.

Is there an example of using "onaccept" after a user registers?




Re: [web2py] Re: Testing the new router

2011-02-02 Thread Tom Atkins
Thanks for your work on the new routers Jonathan - it makes life much
easier.

Quick question, say I have:

routers = dict(
  BASE  = dict(
  domains = {
  'domain1.com' : 'app1',
  'domain2.com' : 'app2',
  }
  ),
)

But would also like www.domain1.com to map to app1 but also change the URL
to domain1.com (stripping the www part) what is the best way to achieve
that?

Ideally I'd like it to work the same way as this .htaccess:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

This silently redirects to the non www domain and sends a 301 to any search
engines to make it clear that the only site is at domain1.com (nothing at
www.domain1.com).

Thanks in advance.


[web2py] Router and Routes

2011-02-02 Thread Arun K.Rajeevan
I'm sure that I missed something.

What's that router.py in addition to earlier routes.py.

Should I be able to see a documentation on this topic somewhere?


Re: [web2py] Mixing/supporting CMS with Web2py

2011-02-02 Thread contatogilson...@gmail.com
Instant Press - http://code.google.com/p/instant-press/
_
*Gilson Filho*
*Web Developer
http://gilsondev.com*



2011/2/2 Carl 

> has anyone direct experience of using Wordpress, SquareSpace or
> similar solution alongside Web2py?
>
> These solutions appeal for their maturity and I'd like to use one to
> do the "donkey" work and fall back to Web2py to do my site's specific
> functionality.
>
> Without them I feel like I'm reinventing needlessly.


Re: [web2py] Re: Detecting test vs. production environments

2011-02-02 Thread Jonathan Lundell
On Feb 2, 2011, at 12:09 AM, Dane wrote:
> 
> I'm doing something similar for configuration, but I'd really like to
> find a way to detect this setting automatically instead of setting a
> flag which just adds needless complexity to my git deployments. All I
> really need is a way to reliably check the full url of my app as the
> client sees it, and I need it to be available when the first models
> are being exec'd.

If the two environments are on different machines, see if there isn't something 
in os.environ that you can key off.

> 
> On Feb 2, 3:01 am, ron_m  wrote:
>> I put all my production vs developer settings in an if else block and use my
>> own variable PRODUCTION. This is in the model directory and named
>> 0_customization.py in my case. This allows you to set the migrate,
>> local_import reload parameter and anything else you want. Then I just need
>> to remember to set the flag True or False depending on the situation.
> 




Re: [web2py] Re: Important Pycon 2011

2011-02-02 Thread Richard Vézina
Could it be retransmit into live webminar

That way I can get in.

Richard

On Wed, Feb 2, 2011 at 4:29 AM, James Hancock  wrote:

> I want to go so bad!
>
> I am making it to the conference, but to poor to get there two days
> early... I am Staying for the sprints afterword, and will be hacking on
> https://launchpad.net/pybookbuilder.
>
> Any plans for web2py work?
>
> I would love to participate if there is, especially if there is something
> with writing tests or documentation(sphinx anyone?).
>
> Once I get back to the US I plan on hitting web2py in a big way, both for
> personal and professional projects. No better way to start than at pycon. :)
>
> Cheers,
> James Hancock
>
>
>
> On Sat, Jan 29, 2011 at 10:12 AM, Anthony  wrote:
>
>> Massimo offered to reimburse $70 of the registration fee to the first 5
>> people to sign up. I'm not sure if I'm in the first 5 (registered on Jan.
>> 16), but if I am, I offer my $70 reimbursement to whoever signs up next. : )
>>
>> I hope they don't cancel it -- I'm looking forward to meeting some other
>> web2py users in person.
>>
>> See you in Atlanta.
>>
>> Anthony
>>
>>
>> On Friday, January 28, 2011 4:20:18 PM UTC-5, Massimo Di Pierro wrote:
>>
>>> The web2py Python tutorial has 8 registered participants. That is not
>>> god enough. There is still a possibility it may be cancelled.
>>>
>>> I am told web2py is easy and perhaps people do not need a tutorial but
>>> I promise I will do my best to cover things you probably do not know
>>> and make it worthwhile.
>>>
>>> So if you are planning to attend PyCon 2011, I encourage to register
>>> for the web2py tutorial "web2py secrets" and some of the other
>>> excellent tutorials.
>>>
>>> Massimo
>>>
>>
>


[web2py] Re: upload an excel sheet to be added to the system

2011-02-02 Thread mart
sticking purely to text, is there a difference between an excel file
and csv? if formatted properly, it should be the same thing. Extension
names are only incidental, if web2py has the extension hard coded in
its look up, then you should be able to simply rename the file...

On Feb 2, 9:58 am, Bruno Rocha  wrote:
> Take a look at this pack:http://www.python-excel.org/
>
> Bruno Rochahttp://about.me/rochacbruno/bio


Re: [web2py] jQuery 1.5 released

2011-02-02 Thread ron_m
I wouldn't rush into it either but the testing I did shows a very compatible 
release when comparing 1.4.4 vs 1.5 including jQueryUI and another plugin I 
use.
I am impressed with their quality and their strong adherence to backwards 
compatibility.


Re: [web2py] Re: Testing the new router

2011-02-02 Thread Jonathan Lundell
On Feb 2, 2011, at 7:52 AM, Tom Atkins wrote:
> Thanks for your work on the new routers Jonathan - it makes life much easier.
> 
> Quick question, say I have:
> 
> routers = dict(
>   BASE  = dict(
>   domains = {
>   'domain1.com' : 'app1',
>   'domain2.com' : 'app2',
>   }
>   ),
> )
> 
> But would also like www.domain1.com to map to app1 but also change the URL to 
> domain1.com (stripping the www part) what is the best way to achieve that?
> 
> Ideally I'd like it to work the same way as this .htaccess:
> 
> RewriteEngine On
> RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
> RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
> 
> This silently redirects to the non www domain and sends a 301 to any search 
> engines to make it clear that the only site is at domain1.com (nothing at 
> www.domain1.com).
> 

If possible, it's better to do the redirection through .htaccess. It's more 
efficient, since web2py never has to run.

This should also work, if you don't really need the redirect, so it's also 
efficient:

routers = dict(
  BASE  = dict(
  domains = {
  'domain1.com' : 'app1',
  'www.domain1.com' : 'app1',
  'domain2.com' : 'app2',
  }
  ),
)

My impression is that search engines (Google anyway) are fairly smart about 
encountering the same content at related domains, and IIRC Google has a 
protocol for telling them which address is preferred.


If you still want to do it through web2py, I think I'd do the rewrite as above 
(for both domain1 and www.domain1) and in models/0redirect.py (or at any rate, 
before any other application code runs), something like:

if request.env.http_host == 'www.domain1.com':
redirect("http://domain1.com%s"; % request.env.request_uri, 301)

or more generally:

redirects = {
'www.domain1.com' : 'domain1.com',
...
}

if request.env.http_host in redirects:
scheme = request.env.get('wsgi_url_scheme', 'http').lower()
uri = "%s://%s%s" % (scheme, redirects[request.env.http_host], 
request.env.request_uri)
redirect(uri, 301)

None of that is tested, and you'd want to check it all, including appropriate 
escaping (if it's not done already). But you get the idea. It also doesn't take 
port overrides into consideration.



Re: [web2py] Router and Routes

2011-02-02 Thread Jonathan Lundell
On Feb 2, 2011, at 7:57 AM, Arun K.Rajeevan wrote:
> I'm sure that I missed something.
> 
> What's that router.py in addition to earlier routes.py.
> 
> Should I be able to see a documentation on this topic somewhere?

It's still routes.py. See the comments in router.example.py for documentation, 
keeping in mind that in most cases, the result should be very simple.

Once it's in a stable release, I'll try to get something added to the rewrite 
section of the web2py book.

[web2py] Re: Multiple users on computer and authorization with Janrian (RPX)

2011-02-02 Thread ron_m
I put this chunk of code in models/menu.py just after the index item and 
before the rest of the menu because I didn't want the other menu items 
exposed if not logged in. Your case may vary but the code should be the 
same, just placement.

if auth.user:
#print 'menu: ', auth.user_id, auth.user.username, session.saved_user_id
if (not session.saved_user_id) or (session.saved_user_id != 
auth.user_id):
clean_session()
session.saved_user_id = auth.user_id

In a nutshell, 
if logged in
Test for a copy of auth.user_id saved in session.saved_user_id and if not 
saved or the login id is now different
run clean_session()
and save the now current auth.user_id in the session.saved_user_id.

I am not using Janrain, just regular web2py authentication but the session 
file was getting reused in that case too giving the next user to use the 
client browser the permissions in the application of the previous user.

The clean_session() function must be kept current and all it does is scrub 
every session variable that could have been created by the application. I 
suppose I could just walk the collection, not sure what else might be in 
there, will have to look one day.

You are victim of the same machine, web browser, browser window, browser tab 
all see the same session file. If you logged in on the client workstation 
machine with a different account the browser would use a different cookie 
set and you probably would not have the problem. It is not a web2py 
deficiency.


Re: [web2py] Re: migration from 1.88.2 to 1.91.6 problem

2011-02-02 Thread Richard Vézina
Can I just remove the added line in sqlhtml.py in the web2py 1.91.6?

Is it safe to do so?

I have crud.update form where I have some field that are boolean type that
are set to writable false then I use a .represent= for them...

Ex.:
db.table1.valid.represent=\
lambda value: value==True and T('valid').capitalize() or T('not
valid').capitalize()

They got caught by the if and remove from the update form on submit as far
as I understand.

Richard



On Wed, Feb 2, 2011 at 9:10 AM, Richard Vézina
wrote:

> True
>
> Richard
>
>
> On Wed, Feb 2, 2011 at 12:20 AM, Marin Pranjic wrote:
>
>> ### this happens because FROM has no knowledge of
>> writable
>> ### and thinks that a missing boolean field is a None
>> if self.table[fieldname].type == 'boolean' and
>> self.vars[fieldname]==None:
>> del self.vars[fieldname]
>>
>> these are in red
>>
>> On Wed, Feb 2, 2011 at 12:19 AM, Massimo Di Pierro <
>> massimo.dipie...@gmail.com> wrote:
>>
>>> Which ones are in red?
>>>
>>> On Feb 1, 1:13 pm, Richard Vézina  wrote:
>>> > Hello,
>>> >
>>> > If I change erase those line (in red) in /gluon/sqlhtml.py
>>> >
>>> >  if not self.ignore_rw and not self.table[fieldname].writable:
>>> > ### this happens because FROM has no knowledge of
>>> writable
>>> > ### and thinks that a missing boolean field is a None
>>> > if self.table[fieldname].type == 'boolean' and
>>> > self.vars[fieldname]==None:
>>> > del self.vars[fieldname]
>>> > continue
>>> >
>>> > It solves the problem... But I don't have clue of what the impacts are
>>> on
>>> > web2py.
>>> >
>>> > I use Postgres as backend...
>>> >
>>> > I will try to write a demo app to reproduce de problem...
>>> >
>>> > Richard
>>> >
>>> > On Tue, Feb 1, 2011 at 12:49 PM, Richard Vézina <
>>> ml.richard.vez...@gmail.com
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> > > wrote:
>>> > > Hello,
>>> >
>>> > > I am not sure where it comes from the problem I face, but for sure it
>>> comes
>>> > > from 1.91.6 because I dont have the probleme with the exact same app
>>> under
>>> > > 1.88.2.
>>> >
>>> > >  1.
>>> > > 2.
>>> > > 3.
>>> > > 4.
>>> > > 5.
>>> > > 6.
>>> > > 7.
>>> > > 8.
>>> > > 9.
>>> > > 10.
>>> > > 11.
>>> > > 12.
>>> > > 13.
>>> > > 14.
>>> >
>>> > > Traceback (most recent call last):
>>> >
>>> > >   File "/home/www-data/web2py/gluon/restricted.py", line 188, in
>>> restricted
>>> >
>>> > > exec ccode in environment
>>> >
>>> > >   File "/home/www-data/web2py/applications/init/controllers/test.py",
>>> line 855, in 
>>> >
>>> > >   File "/home/www-data/web2py/gluon/globals.py", line 95, in 
>>> >
>>> > > self._caller = lambda f: f()
>>> >
>>> > >   File "/home/www-data/web2py/gluon/tools.py", line 2297, in f
>>> >
>>> > > return action(*a, **b)
>>> >
>>> > >   File "/home/www-data/web2py/applications/init/controllers/test.py",
>>> line 410, in update
>>> >
>>> > > if form.accepts(request.vars, session):
>>> >
>>> > >   File "/home/www-data/web2py/gluon/sqlhtml.py", line 1091, in
>>> accepts
>>> >
>>> > > if self.table[fieldname].type == 'boolean' and
>>> self.vars[fieldname]==None:
>>> > > KeyError: 'valid'
>>> >
>>> > > I have a field name "valid" in my models... May be it conflict with
>>> the new
>>> > > DAL??
>>> >
>>> > > Thanks
>>> >
>>> > > Richard
>>>
>>
>>
>


[web2py] Re: IS_IN_SET texts

2011-02-02 Thread Mirek Zvolský
For me works following syntax too:
IS_IN_SET((("yes",T("yes")), ("no",T("no"
IS_IN_SET(((1,T("yes")), (0,T("no"


On 27 led, 21:33, DenesL  wrote:
> You can use
> requires=IS_IN_SET({1:'Fixed yesterday', 2:'to be fixed today', ...})


Re: [web2py] Re: Testing the new router

2011-02-02 Thread Tom Atkins
Thanks for the quick reply! Your suggestion works fine.  Perfect for my low
traffic server with lots of small sites.  I'll look into getting Apache to
manage redirects if (when!) it gets busier.

The redirect is useful as if a user comes to the www. version of the site
and then to the no www version they lose their session as the cookies don't
match.  With your suggestion the session is maintained regardless of the URL
entered.

On 2 February 2011 16:43, Jonathan Lundell  wrote:

> On Feb 2, 2011, at 7:52 AM, Tom Atkins wrote:
> > Thanks for your work on the new routers Jonathan - it makes life much
> easier.
> >
> > Quick question, say I have:
> >
> > routers = dict(
> >   BASE  = dict(
> >   domains = {
> >   'domain1.com' : 'app1',
> >   'domain2.com' : 'app2',
> >   }
> >   ),
> > )
> >
> > But would also like www.domain1.com to map to app1 but also change the
> URL to domain1.com (stripping the www part) what is the best way to
> achieve that?
> >
> > Ideally I'd like it to work the same way as this .htaccess:
> >
> > RewriteEngine On
> > RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
> > RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
> >
> > This silently redirects to the non www domain and sends a 301 to any
> search engines to make it clear that the only site is at domain1.com(nothing 
> at
> www.domain1.com).
> >
>
> If possible, it's better to do the redirection through .htaccess. It's more
> efficient, since web2py never has to run.
>
> This should also work, if you don't really need the redirect, so it's also
> efficient:
>
> routers = dict(
>  BASE  = dict(
>  domains = {
>  'domain1.com' : 'app1',
>   'www.domain1.com' : 'app1',
>  'domain2.com' : 'app2',
>  }
>  ),
> )
>
> My impression is that search engines (Google anyway) are fairly smart about
> encountering the same content at related domains, and IIRC Google has a
> protocol for telling them which address is preferred.
>
>
> If you still want to do it through web2py, I think I'd do the rewrite as
> above (for both domain1 and www.domain1) and in models/0redirect.py (or at
> any rate, before any other application code runs), something like:
>
> if request.env.http_host == 'www.domain1.com':
>redirect("http://domain1.com%s"; % request.env.request_uri, 301)
>
> or more generally:
>
> redirects = {
>'www.domain1.com' : 'domain1.com',
>...
> }
>
> if request.env.http_host in redirects:
>scheme = request.env.get('wsgi_url_scheme', 'http').lower()
>uri = "%s://%s%s" % (scheme, redirects[request.env.http_host],
> request.env.request_uri)
>redirect(uri, 301)
>
> None of that is tested, and you'd want to check it all, including
> appropriate escaping (if it's not done already). But you get the idea. It
> also doesn't take port overrides into consideration.
>
>


Re: [web2py] Re: Testing the new router

2011-02-02 Thread Jonathan Lundell
On Feb 2, 2011, at 9:17 AM, Tom Atkins wrote:
> Thanks for the quick reply! Your suggestion works fine.  Perfect for my low 
> traffic server with lots of small sites.  I'll look into getting Apache to 
> manage redirects if (when!) it gets busier.
> 
> The redirect is useful as if a user comes to the www. version of the site and 
> then to the no www version they lose their session as the cookies don't 
> match.  With your suggestion the session is maintained regardless of the URL 
> entered.

I'm glad to here it. Did you use the short version or the long version?

If you used the short version, would you mind trying out the long version and 
letting us know how it works? I'd like to include the technique in the 
documentation.

BTW, this technique (or something very like it) should work fine with the 
regex-based rewrite logic; the request.env values that we're using are 
basically http request header items, slightly cleaned up.

> 
> On 2 February 2011 16:43, Jonathan Lundell  wrote:
> On Feb 2, 2011, at 7:52 AM, Tom Atkins wrote:
> > Thanks for your work on the new routers Jonathan - it makes life much 
> > easier.
> >
> > Quick question, say I have:
> >
> > routers = dict(
> >   BASE  = dict(
> >   domains = {
> >   'domain1.com' : 'app1',
> >   'domain2.com' : 'app2',
> >   }
> >   ),
> > )
> >
> > But would also like www.domain1.com to map to app1 but also change the URL 
> > to domain1.com (stripping the www part) what is the best way to achieve 
> > that?
> >
> > Ideally I'd like it to work the same way as this .htaccess:
> >
> > RewriteEngine On
> > RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
> > RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
> >
> > This silently redirects to the non www domain and sends a 301 to any search 
> > engines to make it clear that the only site is at domain1.com (nothing at 
> > www.domain1.com).
> >
> 
> If possible, it's better to do the redirection through .htaccess. It's more 
> efficient, since web2py never has to run.
> 
> This should also work, if you don't really need the redirect, so it's also 
> efficient:
> 
> routers = dict(
>  BASE  = dict(
>  domains = {
>  'domain1.com' : 'app1',
>  'www.domain1.com' : 'app1',
>  'domain2.com' : 'app2',
>  }
>  ),
> )
> 
> My impression is that search engines (Google anyway) are fairly smart about 
> encountering the same content at related domains, and IIRC Google has a 
> protocol for telling them which address is preferred.
> 
> 
> If you still want to do it through web2py, I think I'd do the rewrite as 
> above (for both domain1 and www.domain1) and in models/0redirect.py (or at 
> any rate, before any other application code runs), something like:
> 
> if request.env.http_host == 'www.domain1.com':
>redirect("http://domain1.com%s"; % request.env.request_uri, 301)
> 
> or more generally:
> 
> redirects = {
>'www.domain1.com' : 'domain1.com',
>...
> }
> 
> if request.env.http_host in redirects:
>scheme = request.env.get('wsgi_url_scheme', 'http').lower()
>uri = "%s://%s%s" % (scheme, redirects[request.env.http_host], 
> request.env.request_uri)
>redirect(uri, 301)
> 
> None of that is tested, and you'd want to check it all, including appropriate 
> escaping (if it's not done already). But you get the idea. It also doesn't 
> take port overrides into consideration.
> 
> 




[web2py] new URL router use cases

2011-02-02 Thread Jonathan Lundell
[I'm reposting this message from a couple of weeks ago. It describes some 
simple use cases for the new URL router (trunk-only at the moment).]


Suppose you've written an app, named it 'myapp', and want to make it the 
default, with its name always removed. Your default controller is still 
'default', and you want to remove its name from user-visible URLs as well. 
Here's what you put in routes.py:

routers = dict(
   BASE  = dict( default_application='myapp' ),
)

That's it. And it's smart enough to know how to do the right thing with URLs 
like:

http://domain.com/myapp/default/myapp
or  http://domain.com/myapp/myapp/index

...where normal shortening would be ambiguous.


If you have two applications, myapp and myapp2, you'll get the same effect, and 
additionally myapp2's default controller will be stripped from the URL whenever 
it's safe (which is mostly all the time).



Another case. Suppose you want to support URL-based languages, where your URLs 
look like this:

http://myapp/en/some/path

or (rewritten)

http://en/some/path

Here's how:

routers = dict(
   BASE  = dict( default_application='myapp' ),
   myapp = dict( languages=['en', 'it', 'jp'], default_language='en' ),
)

Now an incoming URL like this:

http:/domain.com/it/some/path

will be routed to /myapp/some/path, and request.uri_language will be set to 
'it', so you can force the translation. You can also have language-specific 
static files.

http://domain.com/it/static/filename

will be mapped to:

applications/myapp/static/it/filename

...if that file exists. If it doesn't, then URLs like:

http://domain.com/it/static/base.css

...will still map to:

applications/myapp/static/base.css

(because there is no static/it/base.css)

So you can now have language-specific static files, including images, if you 
need to.


Domain mapping is supported as well.

routers = dict(
   BASE  = dict(
   domains = {
   'domain1.com' : 'app1',
   'domain2.com' : 'app2',
   }
   ),
)

does what you'd expect.

routers = dict(
   BASE  = dict(
   domains = {
   'domain.com:80'  : 'app/insecure',
   'domain.com:443' : 'app/secure',
   }
   ),
)

...maps http://domain.com accesses to app's controller named 'insecure', while 
https accesses go to the 'secure' controller. Or you can map different ports to 
different apps, in the obvious way.


There's more, but mostly everything happens automatically, and there's no need 
to dig into the details of configuration unless there's some non-standard thing 
you need. There's a bit more documentation in router.example.py.

[web2py] Re: Speeding up IS_IN_DB

2011-02-02 Thread Mirek Zvolský
It is hard to implement following internal behaviour of the control.
But I have used it earlier in other language, and it was nice
behaviour when there were many records in the related table.
Here we need to use JavaScript/Ajax to implement this. And maybe an
index on that field?

Once user pressed a key inside the control, a
SELECT TOP 31 ... WHERE Field startsWith TextBox.Value
command fired.
If it received 31 records, there was no reason to show list.
If it received 1-30, the records show in the list.
The color of the textbox can change for f.e. 0, 1, 2-5, 6-30, 31+
records.

If this is to implement, there is additional problem, that there are
languages with double-chars letters like 'ch', where we can f.e.
receive 0 records for 'Loc', but 1+ records for 'Loch'. :-))





On 31 led, 21:41, Massimo Di Pierro 
wrote:
> The rationale is easy. The field is never a problem. The problem is
> the forms. If you need to list all the options, you need to gather all
> the options from database. That is a performance hog. Using
> autocomplete is better. The issue is the same for reference and
> list:reference.


[web2py] Re: execfile

2011-02-02 Thread Anthony
Keep in mind that web2py has been around and tested in the real world by 
many users for over three years -- it seems to be working just fine.
 
Anthony

On Wednesday, February 2, 2011 2:07:46 AM UTC-5, desfrenes wrote:

> hey ! How about that ? http://lucumr.pocoo.org/2011/2/1/exec-in-python/ 
>
> Is there any real threat for web2py or is it just expert whining ? 
>
> I don't really care about theory and things being pythonic or not, as 
> long as it's efficient. So, any situation where this can really be a 
> problem ? 
>
> See you.



[web2py] Roadmap

2011-02-02 Thread contatogilson...@gmail.com
Hello Massimo,

I took a look at the roadmap, the repository and found it has web2py
some goals, and these, features for the framework. Voces
want to implement something from him?
_
*Gilson Filho*
*Web Developer
http://gilsondev.com*


Re: [web2py] Re: Testing the new router

2011-02-02 Thread Tom Atkins
Initially I tried the short version.  Just tried the long version and it
works too - impressively no typos in your untested code!  Both also work
nicely for http and https.

What are the pros and cons of the short v long version?

On 2 February 2011 17:26, Jonathan Lundell  wrote:

>
> I'm glad to here it. Did you use the short version or the long version?
>
> If you used the short version, would you mind trying out the long version
> and letting us know how it works? I'd like to include the technique in the
> documentation.
>
> BTW, this technique (or something very like it) should work fine with the
> regex-based rewrite logic; the request.env values that we're using are
> basically http request header items, slightly cleaned up.
>
>


Re: [web2py] Re: Testing the new router

2011-02-02 Thread Jonathan Lundell
On Feb 2, 2011, at 10:18 AM, Tom Atkins wrote:
> Initially I tried the short version.  Just tried the long version and it 
> works too - impressively no typos in your untested code!  Both also work 
> nicely for http and https.
> 
> What are the pros and cons of the short v long version?

The long version seems useful if you had more than one or two domains that you 
needed to redirect, and it retains the incoming http vs https scheme. Other 
than that, they should be equivalent. 

Of course, you could also implement it with regular expressions, sort of along 
the lines of the Apache rewrite module, though that seems like overkill for 
most requirements.

> 
> On 2 February 2011 17:26, Jonathan Lundell  wrote:
> 
> I'm glad to here it. Did you use the short version or the long version?
> 
> If you used the short version, would you mind trying out the long version and 
> letting us know how it works? I'd like to include the technique in the 
> documentation.
> 
> BTW, this technique (or something very like it) should work fine with the 
> regex-based rewrite logic; the request.env values that we're using are 
> basically http request header items, slightly cleaned up.
> 
> 




[web2py] [OT] Stylus - a symplified syntax for CSS

2011-02-02 Thread mikech
It begins to look more and more like Python:
http://learnboost.github.com/stylus/


[web2py] Re: can web2py support RESTful api calls? if so any pointers on how to build one?I

2011-02-02 Thread Fran
Here is an example of a RESTful API built on Web2Py:
http://eden.sahanafoundation.org/wiki/S3XRC/RESTfulAPI

F


[web2py] Multiple Selection and Send Email

2011-02-02 Thread Ialejandro
Hi every one! Again me, this time I have a little issue with this:


I have the model:

db.define_table('location',
 Field('name','string'))

db.define_table('room',
 Field('name','string'),
 Field('isbooked','boolean'),
 Field('location_id', db.location))

db.define_table('categorie',
 Field('name','string'))

db.define_table('member',
 Field('name','string'),
 Field('categorie_id',db.categorie))

db.define_table('booking',
 Field('room_id',db.room),
 Field('member_id',db.member),
 Field('date','datetime'),
 Field('comment','text'))


and what I need is this:

A user can make a booking with multiple rooms, currently for this I'm
using this controller:

def create():
form = crud.create(db.booking, next = URL('index'))
return dict(form=form)

So I was wondering to use a validator like this:

db.booking.room_id.requires = IS_IN_DB(db, db.room.id, '%
(name)s',multiple=True)

But It doesn't work.


And when a user saves a booking It must sent an email to an admin, the
admin should validate the booking.

So the magic question is, How could I do all above?

Thank's!!!


Re: [web2py] Re: Testing the new router

2011-02-02 Thread Tom Atkins
On 2 February 2011 18:27, Jonathan Lundell  wrote:

The long version seems useful if you had more than one or two domains that
> you needed to redirect
>

Of course - realised that just after I posted the question!


> , and it retains the incoming http vs https scheme.
>

Yes - what I said previously was wrong - only the long version work for
hhtps as well.

All very useful and exactly what I was looking.  Many thanks!


Re: [web2py] Multiple Selection and Send Email

2011-02-02 Thread Kenneth Lundström

> def create():
> form = crud.create(db.booking, next = URL('index'))
> return dict(form=form)

> So I was wondering to use a validator like this:
> db.booking.room_id.requires = IS_IN_DB(db, db.room.id, '% 
(name)s',multiple=True)


> But It doesn't work.

In what way doesn´t it work?

You have to put that validator before you create the form. So the create 
function should look like

def create():
db.booking.room_id.requires = IS_IN_DB(db, db.room.id, '% 
(name)s',multiple=True)

form = crud.create(db.booking, next = URL('index'))
return dict(form=form)

> And when a user saves a booking It must sent an email to an admin, 
the admin should validate the booking.


Maybe theres a easier way but one way could be like:
form = crud.create(db.booking, next = URL('send_email'))

and create function that sends the email, look at
http://web2py.com/book/default/chapter/08?search=mail.send#Auth-and-Mail

from this function you redirect to index.


Kenneth






So the magic question is, How could I do all above?

Thank's!!!




[web2py] Re: Support for Drizzle in web2py

2011-02-02 Thread Massimo Di Pierro
According to the list of differences in the docs, web2py should work
with it.

On Feb 1, 11:57 pm, Rahul  wrote:
> Hi All,
>        http://drizzle.org/Home.html
>        Not really sure if web2py should support Drizzle (opensource
> MYSQL forked Database). Will pymysql work with Drizzle? What do you
> think? Also is MySQL free for professional development now? or we need
> to pay a fee. Oracle - MySQL site does show us license fees etc.
>
> Rahul


[web2py] Re: web2py exec in the new again

2011-02-02 Thread Massimo Di Pierro


On Feb 2, 1:26 am, cjrh  wrote:
> "Now now we know the cause, why doesn't it happen if you have a
> module? The reason for that is that Python will do a trick when it
> shuts down modules. It will override all global values that do not
> begin with an underscore with None"

Can you provide a proof of concept example code to do this?

Massimo


[web2py] rename / route app admin

2011-02-02 Thread LightOfMooN
Is there a way to change name of app admin?

from https://mydomain.com/admin
to something like https://mydomain.com/mysecretadmin

I tired this:
routes_in = (
  ('(?P.*)/admin(?P.*)', '\g/myapp/default/index'),
  ('(?P.*)/mysecretadmin(?P.*)', '\g/admin\g'),
)
routes_out = (
  ('(?P.*)/admin(?P.*)', '\g/mysecretadmin\g'),
)

but it's so bad way, and doesn't work

thx


[web2py] Re: execfile

2011-02-02 Thread Massimo Di Pierro
Thank you.

This is usually my response when people bring up that post:

http://www.reddit.com/r/Python/comments/f8so6/best_framework_for_gae/c1e8ar5

Massimo

On Feb 2, 3:28 am, desfrenes  wrote:
> Yes, I read it.
>
> Anyway, thank you Massimo for keeping python web development out of
> the wannabe-java & everything-should-be-made-standard syndroms.
>
> And the statement about web2py being harmful to the python community
> is just shit. Web2py was the one framework that got me interested in
> python web development and I have yet to see another platform with
> such ease of use.
>
> On 2 fév, 09:56, Tom Atkins  wrote:
>
>
>
>
>
>
>
> > See Massimo's response here:
>
> >https://groups.google.com/forum/#!topic/web2py/dmN54cpMuXo


[web2py] Re: Roadmap

2011-02-02 Thread Massimo Di Pierro
which roadmap?

On Feb 2, 12:14 pm, "contatogilson...@gmail.com"
 wrote:
> Hello Massimo,
>
> I took a look at the roadmap, the repository and found it has web2py
> some goals, and these, features for the framework. Voces
> want to implement something from him?
> _
> *Gilson Filho*
> *Web Developerhttp://gilsondev.com*


[web2py] Error acessing Database Administration

2011-02-02 Thread Mrekko
Hi guys,

Im new in Python language and web2py framework and im recently trying
to build an aplicattion in web2py.

I´ve created a database but i can´t acess the database administration
panel, it gives me the following error:

('Incentivo')

"Incentivo" is a table

Please help me, it´s not the first time these happened and i had to
started all over!


My database code is the following:


db = DAL("sqlite://sibecbd.db")

"""
Table definition
"""
db.define_table("Utilizador",
  Field("nome", "string", length=100, notnull=True, default=None),
  Field("password", "upload", notnull=True, default=None),
  Field("email", "string", notnull=True, default=None))


"""
Table definition
"""
db.define_table("Consultorio",
  Field("id_Utilizador", db.Utilizador),
  Field("id_Incentivo", db.Incentivo),
  Field("titulo", "string", length=250, notnull=True,
default=None),
  Field("body", "text", notnull=True, default=None),
  Field("data", "date", notnull=True, default=None),
  Field("imagem", "upload", notnull=True, default=None),
  Field("pdf", "upload", notnull=True, default=None))


"""
Table definition
"""
db.define_table("Incentivo",
  Field("titulo", "string", length=300, notnull=True,
default=None),
  Field("body", "text", notnull=True, default=None),
  Field("data_inicio", "date", default=None),
  Field("data_fim", "date", default=None),
  Field("imagem", "upload", notnull=True, default=None),
  Field("site_oficial", "string", length=300, default=None))


"""
Table definition
"""
db.define_table("Destaque",
  Field("id_Utilizador", db.Utilizador),
  Field("titulo", "string", length=300, notnull=True,
default=None),
  Field("body", "text", notnull=True, default=None),
  Field("data", "date", notnull=True, default=None),
  Field("imagem", "upload", notnull=True, default=None),
  Field("fonte", "string", notnull=True, default=None))


"""
Table definition
"""
db.define_table("Contacto",
  Field("id_Empresa", db.Empresa),
  Field("id_Distrito", db.Distrito),
  Field("id_Concelho", db.Concelho),
  Field("id_Freguesia", db.Freguesia),
  Field("nome_primeiro", "string", length=100, notnull=True,
default=None),
  Field("nome_ultimo", "string", default=None),
  Field("telemovel", "integer", default=None),
  Field("telefone", "integer", default=None),
  Field("fax", "integer", default=None),
  Field("email", "string", default=None),
  Field("obs", "text", default=None))


"""
Table definition
"""
db.define_table("Empresa",
  Field("id_Distrito", db.Distrito),
  Field("id_Concelho", db.Concelho),
  Field("id_Freguesia", db.Freguesia),
  Field("id_Ramo", db.Ramo),
  Field("nome", "string", notnull=True, default=None),
  Field("email", "string", default=None),
  Field("telefone", "integer", default=None),
  Field("fax", "integer", default=None),
  Field("obs", "string", default=None))


"""
Table definition
"""
db.define_table("Distrito",
  Field("nome", "string", notnull=True, default=None))


"""
Table definition
"""
db.define_table("Concelho",
  Field("id_Distrito", db.Distrito),
  Field("nome", "string", notnull=True, default=None))


"""
Table definition
"""
db.define_table("Freguesia",
  Field("id_Concelho", db.Concelho),
  Field("nome", "string", notnull=True, default=None))


"""
Table definition
"""
db.define_table("Ramo",
  Field("nome", "string", notnull=True, default=None))


"""
Table definition
"""
db.define_table("Form",
  Field("id_Distrito", db.Distrito),
  Field("id_Assunto", db.Assunto),
  Field("Nome", "string", default=None),
  Field("empresa", "string", default=None),
  Field("body", "text", notnull=True, default=None),
  Field("email", "string", default=None),
  Field("telefone", "integer", default=None),
  Field("emailsibec", "string", notnull=True, default=None))


"""
Table definition
"""
db.define_table("Assunto",
  Field("assunto", "integer", notnull=True, default=None))


"""
Relations between tables (remove fields you don't need from requires)
"""
db.Consultorio.id_Utilizador.requires=IS_IN_DB(db,
'Utilizador.id','Utilizador.nome','Utilizador.password','Utilizador.email')
db.Consultorio.id_Incentivo.requires=IS_IN_DB(db,
'Incentivo.id','Incentivo.titulo','Incentivo.body','Incentivo.data_inicio','Incentivo.data_fim','Incentivo.imagem','Incentivo.site_oficial')
db.Destaque.id_Utilizador.requires=IS_IN_DB(db,
'Utilizador.id','Utilizador.nome','Utilizador.password','Utilizador.email')
db.Contacto.id_Empresa.requires=IS_IN_DB(db,
'Empresa.id','Empresa.id_Distrito','Empresa.id_Concelho','Empresa.id_Freguesia','Empresa.id_Ramo','Empresa.nome','Empresa.email','Empresa.telefone','Empresa.fax','Empresa.obs')
db.Contacto.id_Distrito.requires=IS_IN_DB(db,
'Distrito.id','Distrito.nome')
db.Contacto.id_Concelho.requires=IS_IN_DB(db,
'Concelho.id','Concelho.id_Distrito','Concelho.nome')
d

Re: [web2py] Re: Roadmap

2011-02-02 Thread contatogilson...@gmail.com
http://code.google.com/p/web2py/wiki/Roadmap
_
*Gilson Filho*
*Web Developer
http://gilsondev.com*



2011/2/2 Massimo Di Pierro 

> which roadmap?
>
> On Feb 2, 12:14 pm, "contatogilson...@gmail.com"
>  wrote:
> > Hello Massimo,
> >
> > I took a look at the roadmap, the repository and found it has web2py
> > some goals, and these, features for the framework. Voces
> > want to implement something from him?
> > _
> > *Gilson Filho*
> > *Web Developerhttp://gilsondev.com*


[web2py] Re: rename / route app admin

2011-02-02 Thread Massimo Di Pierro
Just rename its folder.

Counter indication: the redirection for appadmin login will break.

On Feb 2, 2:24 pm, LightOfMooN  wrote:
> Is there a way to change name of app admin?
>
> fromhttps://mydomain.com/admin
> to something likehttps://mydomain.com/mysecretadmin
>
> I tired this:
> routes_in = (
>   ('(?P.*)/admin(?P.*)', '\g/myapp/default/index'),
>   ('(?P.*)/mysecretadmin(?P.*)', '\g/admin\g'),
> )
> routes_out = (
>   ('(?P.*)/admin(?P.*)', '\g/mysecretadmin\g'),
> )
>
> but it's so bad way, and doesn't work
>
> thx


[web2py] Re: Error acessing Database Administration

2011-02-02 Thread Massimo Di Pierro
Can you show the complete traceback?

You have some errors here (and following lines) which may be causing
it

db.Consultorio.id_Utilizador.requires=IS_IN_DB(db,
'Utilizador.id','Utilizador.nome','Utilizador.password','Utilizador.email')

You are passing wrong types for the 4th and 5th arguments.

Notice that ALL of your requires=IS_IN_DB are un-necessary. Simply set
the db.define_table(...format='...')) for all tables.

On Feb 2, 1:37 pm, Mrekko  wrote:
> Hi guys,
>
> Im new in Python language and web2py framework and im recently trying
> to build an aplicattion in web2py.
>
> I´ve created a database but i can´t acess the database administration
> panel, it gives me the following error:
>
> ('Incentivo')
>
> "Incentivo" is a table
>
> Please help me, it´s not the first time these happened and i had to
> started all over!
>
> My database code is the following:
>
> db = DAL("sqlite://sibecbd.db")
>
> """
> Table definition
> """
> db.define_table("Utilizador",
>       Field("nome", "string", length=100, notnull=True, default=None),
>       Field("password", "upload", notnull=True, default=None),
>       Field("email", "string", notnull=True, default=None))
>
> """
> Table definition
> """
> db.define_table("Consultorio",
>       Field("id_Utilizador", db.Utilizador),
>       Field("id_Incentivo", db.Incentivo),
>       Field("titulo", "string", length=250, notnull=True,
> default=None),
>       Field("body", "text", notnull=True, default=None),
>       Field("data", "date", notnull=True, default=None),
>       Field("imagem", "upload", notnull=True, default=None),
>       Field("pdf", "upload", notnull=True, default=None))
>
> """
> Table definition
> """
> db.define_table("Incentivo",
>       Field("titulo", "string", length=300, notnull=True,
> default=None),
>       Field("body", "text", notnull=True, default=None),
>       Field("data_inicio", "date", default=None),
>       Field("data_fim", "date", default=None),
>       Field("imagem", "upload", notnull=True, default=None),
>       Field("site_oficial", "string", length=300, default=None))
>
> """
> Table definition
> """
> db.define_table("Destaque",
>       Field("id_Utilizador", db.Utilizador),
>       Field("titulo", "string", length=300, notnull=True,
> default=None),
>       Field("body", "text", notnull=True, default=None),
>       Field("data", "date", notnull=True, default=None),
>       Field("imagem", "upload", notnull=True, default=None),
>       Field("fonte", "string", notnull=True, default=None))
>
> """
> Table definition
> """
> db.define_table("Contacto",
>       Field("id_Empresa", db.Empresa),
>       Field("id_Distrito", db.Distrito),
>       Field("id_Concelho", db.Concelho),
>       Field("id_Freguesia", db.Freguesia),
>       Field("nome_primeiro", "string", length=100, notnull=True,
> default=None),
>       Field("nome_ultimo", "string", default=None),
>       Field("telemovel", "integer", default=None),
>       Field("telefone", "integer", default=None),
>       Field("fax", "integer", default=None),
>       Field("email", "string", default=None),
>       Field("obs", "text", default=None))
>
> """
> Table definition
> """
> db.define_table("Empresa",
>       Field("id_Distrito", db.Distrito),
>       Field("id_Concelho", db.Concelho),
>       Field("id_Freguesia", db.Freguesia),
>       Field("id_Ramo", db.Ramo),
>       Field("nome", "string", notnull=True, default=None),
>       Field("email", "string", default=None),
>       Field("telefone", "integer", default=None),
>       Field("fax", "integer", default=None),
>       Field("obs", "string", default=None))
>
> """
> Table definition
> """
> db.define_table("Distrito",
>       Field("nome", "string", notnull=True, default=None))
>
> """
> Table definition
> """
> db.define_table("Concelho",
>       Field("id_Distrito", db.Distrito),
>       Field("nome", "string", notnull=True, default=None))
>
> """
> Table definition
> """
> db.define_table("Freguesia",
>       Field("id_Concelho", db.Concelho),
>       Field("nome", "string", notnull=True, default=None))
>
> """
> Table definition
> """
> db.define_table("Ramo",
>       Field("nome", "string", notnull=True, default=None))
>
> """
> Table definition
> """
> db.define_table("Form",
>       Field("id_Distrito", db.Distrito),
>       Field("id_Assunto", db.Assunto),
>       Field("Nome", "string", default=None),
>       Field("empresa", "string", default=None),
>       Field("body", "text", notnull=True, default=None),
>       Field("email", "string", default=None),
>       Field("telefone", "integer", default=None),
>       Field("emailsibec", "string", notnull=True, default=None))
>
> """
> Table definition
> """
> db.define_table("Assunto",
>       Field("assunto", "integer", notnull=True, default=None))
>
> """
> Relations between tables (remove fields you don't need from requires)
> """
> db.Consultorio.id_Utilizador.requires=IS_IN_DB(db,
> 'Utilizador.id','Utilizador.nome','Utilizador.password','Utilizador.email')

[web2py] Re: Mixing/supporting CMS with Web2py

2011-02-02 Thread Carl
Thanks for the suggestion.

I was investigating a less compatible approach than a python CMS.

Perhaps a Wordpress website with PHP plug-ins to access a Web2py
service APIs.
See: http://codex.wordpress.org/Writing_a_Plugin

Has anyone taken this approach?


On Feb 2, 4:09 pm, "contatogilson...@gmail.com"
 wrote:
> Instant Press -http://code.google.com/p/instant-press/
> _
> *Gilson Filho*
> *Web Developerhttp://gilsondev.com*
>
> 2011/2/2 Carl 
>
>
>
> > has anyone direct experience of using Wordpress, SquareSpace or
> > similar solution alongside Web2py?
>
> > These solutions appeal for their maturity and I'd like to use one to
> > do the "donkey" work and fall back to Web2py to do my site's specific
> > functionality.
>
> > Without them I feel like I'm reinventing needlessly.


Re: [web2py] Re: Mixing/supporting CMS with Web2py

2011-02-02 Thread Vinicius Assef
If you want to use web2py services via http (i.e, rest), technology
doesn't matter.

It's trully possible.


On Wed, Feb 2, 2011 at 6:33 PM, Carl  wrote:
> Thanks for the suggestion.
>
> I was investigating a less compatible approach than a python CMS.
>
> Perhaps a Wordpress website with PHP plug-ins to access a Web2py
> service APIs.
> See: http://codex.wordpress.org/Writing_a_Plugin
>
> Has anyone taken this approach?
>
>
> On Feb 2, 4:09 pm, "contatogilson...@gmail.com"
>  wrote:
>> Instant Press -http://code.google.com/p/instant-press/
>> _
>> *Gilson Filho*
>> *Web Developerhttp://gilsondev.com*
>>
>> 2011/2/2 Carl 
>>
>>
>>
>> > has anyone direct experience of using Wordpress, SquareSpace or
>> > similar solution alongside Web2py?
>>
>> > These solutions appeal for their maturity and I'd like to use one to
>> > do the "donkey" work and fall back to Web2py to do my site's specific
>> > functionality.
>>
>> > Without them I feel like I'm reinventing needlessly.


[web2py] Re: Roadmap

2011-02-02 Thread Massimo Di Pierro
I changed id. Everything in there was done long ago.

On Feb 2, 2:27 pm, "contatogilson...@gmail.com"
 wrote:
> http://code.google.com/p/web2py/wiki/Roadmap
> _
> *Gilson Filho*
> *Web Developerhttp://gilsondev.com*
>
> 2011/2/2 Massimo Di Pierro 
>
>
>
>
>
>
>
> > which roadmap?
>
> > On Feb 2, 12:14 pm, "contatogilson...@gmail.com"
> >  wrote:
> > > Hello Massimo,
>
> > > I took a look at the roadmap, the repository and found it has web2py
> > > some goals, and these, features for the framework. Voces
> > > want to implement something from him?
> > > _
> > > *Gilson Filho*
> > > *Web Developerhttp://gilsondev.com*


[web2py] web2py promoted at Google App Engine Montreal Hackathon Sat Jan 22

2011-02-02 Thread dlypka
FYI:

I participated in the Montreal Hackathon for App Engine in Montreal on
Jan 22 where I coded and presented a portion of my web2py app to the
group.

I was demonstrating high performance data retrieval from the datastore
into a treeview.

I spoke to Sean Lynch, Product Manager of Google App Engine and made
sure he is aware of the strengths of web2py on GAE.

He also indicated the Full Text Search on GAE will be out soon (within
a few months).

He does not see any way to use GAE for streaming video however.


[web2py] Help review the DotCloud web2py deployment tutorial

2011-02-02 Thread Anthony
The DotCloud deployment tutorial for web2py (
http://docs.dotcloud.com/static/tutorials/web2py/) includes the following 
warning. Is this accurate? If so, can we offer a simple fix?

 When deploying third-party web2py appliances, you should switch from the 
default Sqlite backend to PostgreSQL or MySQL. This is generally done by 
editing “application//models/db.py”, as shown above.

However, you will probably hit the following problems:

   - the DAL (Data Abstraction Layer) does not quote properly table names 
   when creating SQL schemas – therefore, if some application defines a model 
   named “user” (which happens, well, almost all the time!), the schema 
   creation will fail; 
   - some applications (like PyPress) ship with a Sqlite database, 
   containing the database schema and some preloaded data – but when you switch 
   to another database, the schema is not always fully re-created, and the data 
   is not migrated (leaving the application in a semi-usable state).

This is not related to DotCloud: you will experience the same issues when 
running web2py on your local computer with a PostgreSQL database.

 
Also, it recommends the following to disable secure session cookies for 
remote non-SSL connections to admin -- is that a good idea?
 

 By default, web2py will allow admin connections only if you are connecting 
from localhost or through SSL. We will allow remote, non-SSL connections by 
commenting out a single line of code:

web2py$ sed -i 's/session.secure()/pass # Do not setup secure cookie/' \
applications/admin/models/access.py

 
Please review the rest of the tutorial too, and if any changes are 
necessary, I'll let them know.
 
Thanks.
 
Anthony


[web2py] Re: web2py promoted at Google App Engine Montreal Hackathon Sat Jan 22

2011-02-02 Thread Anthony
Cool. I recently mentioned on the developers list that hosting providers 
often fail to include web2py in their list of Python frameworks (
https://groups.google.com/d/topic/web2py-developers/_Mxb61ip7uQ/discussion). 
It would be great if we could get GAE to explicitly mention web2py as a 
supported framework.
 
Anthony

On Wednesday, February 2, 2011 3:59:42 PM UTC-5, dlypka wrote:

> FYI: 
>
> I participated in the Montreal Hackathon for App Engine in Montreal on 
> Jan 22 where I coded and presented a portion of my web2py app to the 
> group. 
>
> I was demonstrating high performance data retrieval from the datastore 
> into a treeview. 
>
> I spoke to Sean Lynch, Product Manager of Google App Engine and made 
> sure he is aware of the strengths of web2py on GAE. 
>
> He also indicated the Full Text Search on GAE will be out soon (within 
> a few months). 
>
> He does not see any way to use GAE for streaming video however. 
>


[web2py] Re: web2py promoted at Google App Engine Montreal Hackathon Sat Jan 22

2011-02-02 Thread Massimo Di Pierro
Congratulations.

There is other cool stuff coming out on GAE soon. I have been given
early access to some of the new SDK since December, but I am under and
NDA with Google so I will not say too much. I will say, however, there
will soon be more good reasons to have an app developed with web2py.
More projects that today would not consider running on GAE, will
consider it in near future and if they are written with web2py will
need minimal or no re-writing.

Massimo


On Feb 2, 2:59 pm, dlypka  wrote:
> FYI:
>
> I participated in the Montreal Hackathon for App Engine in Montreal on
> Jan 22 where I coded and presented a portion of my web2py app to the
> group.
>
> I was demonstrating high performance data retrieval from the datastore
> into a treeview.
>
> I spoke to Sean Lynch, Product Manager of Google App Engine and made
> sure he is aware of the strengths of web2py on GAE.
>
> He also indicated the Full Text Search on GAE will be out soon (within
> a few months).
>
> He does not see any way to use GAE for streaming video however.


[web2py] Re: Help review the DotCloud web2py deployment tutorial

2011-02-02 Thread Massimo Di Pierro
The warning is accurate.

Disabling session.secure() is not a good idea. Admin and appadmin
should not be used without SSL or your admin cookies can be stolen and
used to gain remote access to your web application.

Massimo

On Feb 2, 3:17 pm, Anthony  wrote:
> The DotCloud deployment tutorial for web2py 
> (http://docs.dotcloud.com/static/tutorials/web2py/) includes the following
> warning. Is this accurate? If so, can we offer a simple fix?
>
>  When deploying third-party web2py appliances, you should switch from the
> default Sqlite backend to PostgreSQL or MySQL. This is generally done by
> editing “application//models/db.py”, as shown above.
>
> However, you will probably hit the following problems:
>
>    - the DAL (Data Abstraction Layer) does not quote properly table names
>    when creating SQL schemas – therefore, if some application defines a model
>    named “user” (which happens, well, almost all the time!), the schema
>    creation will fail;
>    - some applications (like PyPress) ship with a Sqlite database,
>    containing the database schema and some preloaded data – but when you 
> switch
>    to another database, the schema is not always fully re-created, and the 
> data
>    is not migrated (leaving the application in a semi-usable state).
>
> This is not related to DotCloud: you will experience the same issues when
> running web2py on your local computer with a PostgreSQL database.
>
> Also, it recommends the following to disable secure session cookies for
> remote non-SSL connections to admin -- is that a good idea?
>
>  By default, web2py will allow admin connections only if you are connecting
> from localhost or through SSL. We will allow remote, non-SSL connections by
> commenting out a single line of code:
>
> web2py$ sed -i 's/session.secure()/pass # Do not setup secure cookie/' \
>         applications/admin/models/access.py
>
> Please review the rest of the tutorial too, and if any changes are
> necessary, I'll let them know.
>
> Thanks.
>
> Anthony


[web2py] Re: web2py exec in the new again

2011-02-02 Thread Anthony
Anyone? Is using local_import to import a class into a model/controller just 
as safe as using 'from a import A' (i.e., in terms of memory leaks), or do 
you have to use the Python import statement directly?

On Tuesday, February 1, 2011 5:25:51 PM UTC-5, Anthony wrote:

> But what if 'local_import' is used (instead of 'from a import Foo') -- does 
> local_import work the same as regular Python imports?
>  
> On Tuesday, February 1, 2011 5:09:25 PM UTC-5, Massimo Di Pierro wrote:
>
>> I run this test (following Armin's example): 
>>
>> # in file a.py 
>> class Foo(object): 
>> def __del__(self): 
>> print 'Deleted' 
>>
>> #in file b.py 
>> from a import A 
>> foo=Foo() 
>>
>> #in file c.py 
>> execfile('b.py', {}) 
>> execfile('b.py', {}) 
>> execfile('b.py', {}) 
>> import gc 
>> gc.collect() 
>>
>> running c.py printes 
>> Deleted 
>> Deleted 
>> Deleted 
>>
>> therefore there is NO memory leak. 
>>
>> On Feb 1, 3:08 pm, VP  wrote: 
>> > One question: 
>> > If I define a class externally, and use local_import to import it into 
>> > controller or model, will it have these potential problems or not?
>
>

[web2py] Re: adding tables instead of merging?

2011-02-02 Thread howesc
i don't know sqlite.  never really used it so i can't say much about that.

can you take your file paths and use that to prefix the table names?  there 
is nothing stopping you from creating the table name dynamically and 
accessing using db['table name string'].


Re: [web2py] Re: web2py exec in the new again

2011-02-02 Thread Jonathan Lundell
On Feb 2, 2011, at 2:08 PM, Anthony wrote:
> Anyone? Is using local_import to import a class into a model/controller just 
> as safe as using 'from a import A' (i.e., in terms of memory leaks), or do 
> you have to use the Python import statement directly?

It should be equivalent; both end up calling __import__() to do the actual work.

> 
> On Tuesday, February 1, 2011 5:25:51 PM UTC-5, Anthony wrote:
> But what if 'local_import' is used (instead of 'from a import Foo') -- does 
> local_import work the same as regular Python imports?
>  
> On Tuesday, February 1, 2011 5:09:25 PM UTC-5, Massimo Di Pierro wrote:
> I run this test (following Armin's example): 
> 
> # in file a.py 
> class Foo(object): 
> def __del__(self): 
> print 'Deleted' 
> 
> #in file b.py 
> from a import A 
> foo=Foo() 
> 
> #in file c.py 
> execfile('b.py', {}) 
> execfile('b.py', {}) 
> execfile('b.py', {}) 
> import gc 
> gc.collect() 
> 
> running c.py printes 
> Deleted 
> Deleted 
> Deleted 
> 
> therefore there is NO memory leak. 
> 
> On Feb 1, 3:08 pm, VP  wrote: 
> > One question: 
> > If I define a class externally, and use local_import to import it into 
> > controller or model, will it have these potential problems or not?




Re: [web2py] Re: migration from 1.88.2 to 1.91.6 problem

2011-02-02 Thread Richard Vézina
Still waiting for a solution!!

Richard

On Wed, Feb 2, 2011 at 12:04 PM, Richard Vézina  wrote:

> Can I just remove the added line in sqlhtml.py in the web2py 1.91.6?
>
> Is it safe to do so?
>
> I have crud.update form where I have some field that are boolean type that
> are set to writable false then I use a .represent= for them...
>
> Ex.:
> db.table1.valid.represent=\
> lambda value: value==True and T('valid').capitalize() or T('not
> valid').capitalize()
>
> They got caught by the if and remove from the update form on submit as far
> as I understand.
>
> Richard
>
>
>
> On Wed, Feb 2, 2011 at 9:10 AM, Richard Vézina <
> ml.richard.vez...@gmail.com> wrote:
>
>> True
>>
>> Richard
>>
>>
>> On Wed, Feb 2, 2011 at 12:20 AM, Marin Pranjic 
>> wrote:
>>
>>> ### this happens because FROM has no knowledge of
>>> writable
>>> ### and thinks that a missing boolean field is a None
>>> if self.table[fieldname].type == 'boolean' and
>>> self.vars[fieldname]==None:
>>> del self.vars[fieldname]
>>>
>>> these are in red
>>>
>>> On Wed, Feb 2, 2011 at 12:19 AM, Massimo Di Pierro <
>>> massimo.dipie...@gmail.com> wrote:
>>>
 Which ones are in red?

 On Feb 1, 1:13 pm, Richard Vézina  wrote:
 > Hello,
 >
 > If I change erase those line (in red) in /gluon/sqlhtml.py
 >
 >  if not self.ignore_rw and not self.table[fieldname].writable:
 > ### this happens because FROM has no knowledge of
 writable
 > ### and thinks that a missing boolean field is a None
 > if self.table[fieldname].type == 'boolean' and
 > self.vars[fieldname]==None:
 > del self.vars[fieldname]
 > continue
 >
 > It solves the problem... But I don't have clue of what the impacts are
 on
 > web2py.
 >
 > I use Postgres as backend...
 >
 > I will try to write a demo app to reproduce de problem...
 >
 > Richard
 >
 > On Tue, Feb 1, 2011 at 12:49 PM, Richard Vézina <
 ml.richard.vez...@gmail.com
 >
 >
 >
 >
 >
 >
 >
 > > wrote:
 > > Hello,
 >
 > > I am not sure where it comes from the problem I face, but for sure
 it comes
 > > from 1.91.6 because I dont have the probleme with the exact same app
 under
 > > 1.88.2.
 >
 > >  1.
 > > 2.
 > > 3.
 > > 4.
 > > 5.
 > > 6.
 > > 7.
 > > 8.
 > > 9.
 > > 10.
 > > 11.
 > > 12.
 > > 13.
 > > 14.
 >
 > > Traceback (most recent call last):
 >
 > >   File "/home/www-data/web2py/gluon/restricted.py", line 188, in
 restricted
 >
 > > exec ccode in environment
 >
 > >   File
 "/home/www-data/web2py/applications/init/controllers/test.py", line 855, in
 
 >
 > >   File "/home/www-data/web2py/gluon/globals.py", line 95, in
 
 >
 > > self._caller = lambda f: f()
 >
 > >   File "/home/www-data/web2py/gluon/tools.py", line 2297, in f
 >
 > > return action(*a, **b)
 >
 > >   File
 "/home/www-data/web2py/applications/init/controllers/test.py", line 410, in
 update
 >
 > > if form.accepts(request.vars, session):
 >
 > >   File "/home/www-data/web2py/gluon/sqlhtml.py", line 1091, in
 accepts
 >
 > > if self.table[fieldname].type == 'boolean' and
 self.vars[fieldname]==None:
 > > KeyError: 'valid'
 >
 > > I have a field name "valid" in my models... May be it conflict with
 the new
 > > DAL??
 >
 > > Thanks
 >
 > > Richard

>>>
>>>
>>
>


[web2py] Re: migration from 1.88.2 to 1.91.6 problem

2011-02-02 Thread Massimo Di Pierro
This has already been fixed some some time ago in trunk. It is now:

if self.table[fieldname].type == 'boolean' and \
self.vars.get(fieldname,True) == None:
del self.vars[fieldname]
continue


On Feb 2, 4:36 pm, Richard Vézina  wrote:
> Still waiting for a solution!!
>
> Richard
>
> On Wed, Feb 2, 2011 at 12:04 PM, Richard Vézina 
>
>
>
>
>
>
> > wrote:
> > Can I just remove the added line in sqlhtml.py in the web2py 1.91.6?
>
> > Is it safe to do so?
>
> > I have crud.update form where I have some field that are boolean type that
> > are set to writable false then I use a .represent= for them...
>
> > Ex.:
> > db.table1.valid.represent=\
> >     lambda value: value==True and T('valid').capitalize() or T('not
> > valid').capitalize()
>
> > They got caught by the if and remove from the update form on submit as far
> > as I understand.
>
> > Richard
>
> > On Wed, Feb 2, 2011 at 9:10 AM, Richard Vézina <
> > ml.richard.vez...@gmail.com> wrote:
>
> >> True
>
> >> Richard
>
> >> On Wed, Feb 2, 2011 at 12:20 AM, Marin Pranjic 
> >> wrote:
>
> >>>                 ### this happens because FROM has no knowledge of
> >>> writable
> >>>                 ### and thinks that a missing boolean field is a None
> >>>                 if self.table[fieldname].type == 'boolean' and
> >>> self.vars[fieldname]==None:
> >>>                     del self.vars[fieldname]
>
> >>> these are in red
>
> >>> On Wed, Feb 2, 2011 at 12:19 AM, Massimo Di Pierro <
> >>> massimo.dipie...@gmail.com> wrote:
>
>  Which ones are in red?
>
>  On Feb 1, 1:13 pm, Richard Vézina  wrote:
>  > Hello,
>
>  > If I change erase those line (in red) in /gluon/sqlhtml.py
>
>  >  if not self.ignore_rw and not self.table[fieldname].writable:
>  >                 ### this happens because FROM has no knowledge of
>  writable
>  >                 ### and thinks that a missing boolean field is a None
>  >                 if self.table[fieldname].type == 'boolean' and
>  > self.vars[fieldname]==None:
>  >                     del self.vars[fieldname]
>  >                 continue
>
>  > It solves the problem... But I don't have clue of what the impacts are
>  on
>  > web2py.
>
>  > I use Postgres as backend...
>
>  > I will try to write a demo app to reproduce de problem...
>
>  > Richard
>
>  > On Tue, Feb 1, 2011 at 12:49 PM, Richard Vézina <
>  ml.richard.vez...@gmail.com
>
>  > > wrote:
>  > > Hello,
>
>  > > I am not sure where it comes from the problem I face, but for sure
>  it comes
>  > > from 1.91.6 because I dont have the probleme with the exact same app
>  under
>  > > 1.88.2.
>
>  > >  1.
>  > > 2.
>  > > 3.
>  > > 4.
>  > > 5.
>  > > 6.
>  > > 7.
>  > > 8.
>  > > 9.
>  > > 10.
>  > > 11.
>  > > 12.
>  > > 13.
>  > > 14.
>
>  > > Traceback (most recent call last):
>
>  > >   File "/home/www-data/web2py/gluon/restricted.py", line 188, in
>  restricted
>
>  > >     exec ccode in environment
>
>  > >   File
>  "/home/www-data/web2py/applications/init/controllers/test.py", line 855, 
>  in
>  
>
>  > >   File "/home/www-data/web2py/gluon/globals.py", line 95, in
>  
>
>  > >     self._caller = lambda f: f()
>
>  > >   File "/home/www-data/web2py/gluon/tools.py", line 2297, in f
>
>  > >     return action(*a, **b)
>
>  > >   File
>  "/home/www-data/web2py/applications/init/controllers/test.py", line 410, 
>  in
>  update
>
>  > >     if form.accepts(request.vars, session):
>
>  > >   File "/home/www-data/web2py/gluon/sqlhtml.py", line 1091, in
>  accepts
>
>  > >     if self.table[fieldname].type == 'boolean' and
>  self.vars[fieldname]==None:
>  > > KeyError: 'valid'
>
>  > > I have a field name "valid" in my models... May be it conflict with
>  the new
>  > > DAL??
>
>  > > Thanks
>
>  > > Richard


[web2py] Re: Keys and GAE

2011-02-02 Thread howesc
Matt,

sorry for the delay.  Since i don't have use for the key queries yet i'm 
gonna ask you to try something, and then we can ask massimo to include 
it

* grab the latest web2py source from trunk, i have mercurial commit #1572 
* in gluon/dal,py find line 2697.  it should look like:
elif filter.name=='__key__' and filter.op=='=':
if filter.value==0:
items = []
else:
item = tableobj.get_by_id(filter.value)
items = (item and [item]) or []
* edit the if block method.  this if for GAE only to:
elif filter.name=='__key__' and filter.op=='=':
if filter.value==0:
items = []
elif isinstance(filter.value, Key):
items = tableobj.get(filter.value)
else:
item = tableobj.get_by_id(filter.value)
items = (item and [item]) or []
* test this.  if it works you are done.
* if it did not work, find line 2600:
def EQ(self,first,second=None):
return [GAEF(first.name,'=',self.represent(second,first.type),lambda 
a,b:a==b)
* edit the EQ method:
def EQ(self,first,second=None):
if isinstance(second, Key):
return [GAEF(first.name,'=',second,lambda a,b:a==b)
return [GAEF(first.name,'=',self.represent(second,first.type),lambda 
a,b:a==b)

what does this do? you askwell, the first edit finds the spot where the 
GQL Query object is created.  if you are doing a key query (based on ID), 
and the operator is '=' you are adding in a check that if the value you are 
filtering is a Key (instead of a long) then do a key query on the Model.  in 
the edit of the EQ method, you are allowing the pass of a raw key to the 
filter creation, so that when the query is run the code that you wrote in 
select_raw() runs.

once you make the edits you should be able to construct a GQL Key object and 
then do db(db.table.id==myGQLKeyObject).select().

give it a try and let me know if it works.  like i said, since i don't have 
a model like yours i don't have a way to test it, please be patient with my 
typos and other things.

christian


[web2py] Some troubles with trailing slash

2011-02-02 Thread walter
When I do next in the action:
def check():
if request.args(1) == None:
table = request.args(0)

return dict(table=table)

And my url has a trailing slash after a function argument (i.e.
applictation/controller/function/argument/) I catch an internal error
everytime.
I confused.  What do I do wrong?


Re: [web2py] Some troubles with trailing slash

2011-02-02 Thread Jonathan Lundell
On Feb 2, 2011, at 3:44 PM, walter wrote:
> 
> When I do next in the action:
> def check():
>if request.args(1) == None:
>table = request.args(0)
> 
>return dict(table=table)
> 
> And my url has a trailing slash after a function argument (i.e.
> applictation/controller/function/argument/) I catch an internal error
> everytime.
> I confused.  What do I do wrong?

What internal error do you get? In the current release, a URL like this:

> application/controller/function/argument/

Gives you args like this: ['argument', '']

...that is, the trailing slash is interpreted to mean that there's a second 
(empty) arg. The version in the trunk strips (all) trailing slashes, so this 
doesn't happen.

Re: [web2py] Some troubles with trailing slash

2011-02-02 Thread Jonathan Lundell
On Feb 2, 2011, at 4:00 PM, Jonathan Lundell wrote:
> 
> On Feb 2, 2011, at 3:44 PM, walter wrote:
>> 
>> When I do next in the action:
>> def check():
>>   if request.args(1) == None:
>>   table = request.args(0)
>> 
>>   return dict(table=table)
>> 
>> And my url has a trailing slash after a function argument (i.e.
>> applictation/controller/function/argument/) I catch an internal error
>> everytime.
>> I confused.  What do I do wrong?
> 
> What internal error do you get? In the current release, a URL like this:
> 
>> application/controller/function/argument/
> 
> Gives you args like this: ['argument', '']
> 
> ...that is, the trailing slash is interpreted to mean that there's a second 
> (empty) arg. The version in the trunk strips (all) trailing slashes, so this 
> doesn't happen.

You could try:

def check():
  if not request.args(1):
  table = request.args(0)



[web2py] Re: Some troubles with trailing slash

2011-02-02 Thread walter
Many thanks. I've understood where is my error.


Re: [web2py] Re: migration from 1.88.2 to 1.91.6 problem

2011-02-02 Thread Richard Vézina
I try and I get back with feedback...

Thanks Massimo

Richard

On Wed, Feb 2, 2011 at 6:17 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> This has already been fixed some some time ago in trunk. It is now:
>
>if self.table[fieldname].type == 'boolean' and \
> self.vars.get(fieldname,True) == None:
> del self.vars[fieldname]
>continue
>
>
> On Feb 2, 4:36 pm, Richard Vézina  wrote:
> > Still waiting for a solution!!
> >
> > Richard
> >
> > On Wed, Feb 2, 2011 at 12:04 PM, Richard Vézina <
> ml.richard.vez...@gmail.com
> >
> >
> >
> >
> >
> >
> >
> > > wrote:
> > > Can I just remove the added line in sqlhtml.py in the web2py 1.91.6?
> >
> > > Is it safe to do so?
> >
> > > I have crud.update form where I have some field that are boolean type
> that
> > > are set to writable false then I use a .represent= for them...
> >
> > > Ex.:
> > > db.table1.valid.represent=\
> > > lambda value: value==True and T('valid').capitalize() or T('not
> > > valid').capitalize()
> >
> > > They got caught by the if and remove from the update form on submit as
> far
> > > as I understand.
> >
> > > Richard
> >
> > > On Wed, Feb 2, 2011 at 9:10 AM, Richard Vézina <
> > > ml.richard.vez...@gmail.com> wrote:
> >
> > >> True
> >
> > >> Richard
> >
> > >> On Wed, Feb 2, 2011 at 12:20 AM, Marin Pranjic <
> marin.pran...@gmail.com>wrote:
> >
> > >>> ### this happens because FROM has no knowledge of
> > >>> writable
> > >>> ### and thinks that a missing boolean field is a None
> > >>> if self.table[fieldname].type == 'boolean' and
> > >>> self.vars[fieldname]==None:
> > >>> del self.vars[fieldname]
> >
> > >>> these are in red
> >
> > >>> On Wed, Feb 2, 2011 at 12:19 AM, Massimo Di Pierro <
> > >>> massimo.dipie...@gmail.com> wrote:
> >
> >  Which ones are in red?
> >
> >  On Feb 1, 1:13 pm, Richard Vézina 
> wrote:
> >  > Hello,
> >
> >  > If I change erase those line (in red) in /gluon/sqlhtml.py
> >
> >  >  if not self.ignore_rw and not self.table[fieldname].writable:
> >  > ### this happens because FROM has no knowledge of
> >  writable
> >  > ### and thinks that a missing boolean field is a
> None
> >  > if self.table[fieldname].type == 'boolean' and
> >  > self.vars[fieldname]==None:
> >  > del self.vars[fieldname]
> >  > continue
> >
> >  > It solves the problem... But I don't have clue of what the impacts
> are
> >  on
> >  > web2py.
> >
> >  > I use Postgres as backend...
> >
> >  > I will try to write a demo app to reproduce de problem...
> >
> >  > Richard
> >
> >  > On Tue, Feb 1, 2011 at 12:49 PM, Richard Vézina <
> >  ml.richard.vez...@gmail.com
> >
> >  > > wrote:
> >  > > Hello,
> >
> >  > > I am not sure where it comes from the problem I face, but for
> sure
> >  it comes
> >  > > from 1.91.6 because I dont have the probleme with the exact same
> app
> >  under
> >  > > 1.88.2.
> >
> >  > >  1.
> >  > > 2.
> >  > > 3.
> >  > > 4.
> >  > > 5.
> >  > > 6.
> >  > > 7.
> >  > > 8.
> >  > > 9.
> >  > > 10.
> >  > > 11.
> >  > > 12.
> >  > > 13.
> >  > > 14.
> >
> >  > > Traceback (most recent call last):
> >
> >  > >   File "/home/www-data/web2py/gluon/restricted.py", line 188, in
> >  restricted
> >
> >  > > exec ccode in environment
> >
> >  > >   File
> >  "/home/www-data/web2py/applications/init/controllers/test.py", line
> 855, in
> >  
> >
> >  > >   File "/home/www-data/web2py/gluon/globals.py", line 95, in
> >  
> >
> >  > > self._caller = lambda f: f()
> >
> >  > >   File "/home/www-data/web2py/gluon/tools.py", line 2297, in f
> >
> >  > > return action(*a, **b)
> >
> >  > >   File
> >  "/home/www-data/web2py/applications/init/controllers/test.py", line
> 410, in
> >  update
> >
> >  > > if form.accepts(request.vars, session):
> >
> >  > >   File "/home/www-data/web2py/gluon/sqlhtml.py", line 1091, in
> >  accepts
> >
> >  > > if self.table[fieldname].type == 'boolean' and
> >  self.vars[fieldname]==None:
> >  > > KeyError: 'valid'
> >
> >  > > I have a field name "valid" in my models... May be it conflict
> with
> >  the new
> >  > > DAL??
> >
> >  > > Thanks
> >
> >  > > Richard
>


Re: [web2py] Re: Some troubles with trailing slash

2011-02-02 Thread Jonathan Lundell
On Feb 2, 2011, at 4:13 PM, walter wrote:
> 
> Many thanks. I've understood where is my error.

It's sort of a bug, too; the empty arg isn't intentional, and it'll go away in 
the next release.

[web2py] JQuery harmonica menu, but what's the use in web2py, I'm totally confused

2011-02-02 Thread Stef Mientki
hello,

at the moment I'm totally confused about what should be where 

I made a page with 2 columns,
on the left a vertical menu and
on the center and right the contents to show.

The contents to be shown are paragraphs of a book.

The left menu shows the chapters of the book,
and the submenus shows the paragraph titles.

Now I wanted to use a harmonica menu for the left menu,
so I found a JQuery harmonica menu,
which works quit nice,
the chapter on which you click is expanded and all other chapters are closed.
As long as you don't attach a link to the paragraph menu items, it really looks 
very nice.

This is the main JQuery script


  $(document).ready(function(){
$("dd:not(:first)").hide();
$("dt a").click(function(){
  $("dd:visible").slideUp("slow");
  $(this).parent().next().slideDown("slow");
  return false;
});
  });
 

But how should that work with web2py,
if the whole page is refreshed each load of a new paragraph.
A load also rebuilds the harmonica menu.

Now I could think of 2 solutions, and I'm not sure which is the best, or if 
they are all bad.

first solution:
load the new paragraph in an I-frame (or something like that, I'm not an 
expert),
but I think that will be destroy a lot of power of web2py.

second solution:
dont't use the jquery harmonica menu at all,
but let the controller in web2py build a specific menu + (submenus for 1 menu 
item) for each new page.

Another side effect is that reloading a new chapter gives a lot of flicker, 
because although the
major part of the screen is (semi-) static,
each new call the whole page is refreshed.
How in general can you mainitain those static parts with web2py ?

Sorry for the long story,
but I've the feeling I'm missing something very essential in building web2py 
pages.

thanks,
Stef Mientki







[web2py] Re: upload an excel sheet to be added to the system

2011-02-02 Thread Neveen Adel
Thanks a lot Bruno Rocha for ur reply :)

But these packages are used after uploading the file.

I want to know the step before that, what i want to do simply is to
have a browse button to choose CSV file and then press upload then i
can by using one of the packages u suggested to read the CSV file.

Do you have any idea how can i do that?

Thanks in Advance

On Feb 2, 4:58 pm, Bruno Rocha  wrote:
> Take a look at this pack:http://www.python-excel.org/
>
> Bruno Rochahttp://about.me/rochacbruno/bio


[web2py] Re: Detecting test vs. production environments

2011-02-02 Thread Dane
Where does REMOTE_HOST live?

On Feb 2, 10:46 am, Vinicius Assef  wrote:
> Try to check the REMOTE_HOST.
>
> If it is "localhost", it is local.
>
>
>
>
>
>
>
> On Wed, Feb 2, 2011 at 6:09 AM, Dane  wrote:
> > I'm doing something similar for configuration, but I'd really like to
> > find a way to detect this setting automatically instead of setting a
> > flag which just adds needless complexity to my git deployments. All I
> > really need is a way to reliably check the full url of my app as the
> > client sees it, and I need it to be available when the first models
> > are being exec'd.
>
> > On Feb 2, 3:01 am, ron_m  wrote:
> >> I put all my production vs developer settings in an if else block and use 
> >> my
> >> own variable PRODUCTION. This is in the model directory and named
> >> 0_customization.py in my case. This allows you to set the migrate,
> >> local_import reload parameter and anything else you want. Then I just need
> >> to remember to set the flag True or False depending on the situation.
>
> >> RMMV
>
> >> Ron


Re: [web2py] Re: Detecting test vs. production environments

2011-02-02 Thread Jonathan Lundell
On Feb 2, 2011, at 5:29 PM, Dane wrote:
> 
> Where does REMOTE_HOST live?

Try request.env.remote_host

Keep in mind that remote_host is the host of the browser, not web2py. 
request.env.http_host is the host that the request is directed to.

> 
> On Feb 2, 10:46 am, Vinicius Assef  wrote:
>> Try to check the REMOTE_HOST.
>> 
>> If it is "localhost", it is local.
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> On Wed, Feb 2, 2011 at 6:09 AM, Dane  wrote:
>>> I'm doing something similar for configuration, but I'd really like to
>>> find a way to detect this setting automatically instead of setting a
>>> flag which just adds needless complexity to my git deployments. All I
>>> really need is a way to reliably check the full url of my app as the
>>> client sees it, and I need it to be available when the first models
>>> are being exec'd.
>> 
>>> On Feb 2, 3:01 am, ron_m  wrote:
 I put all my production vs developer settings in an if else block and use 
 my
 own variable PRODUCTION. This is in the model directory and named
 0_customization.py in my case. This allows you to set the migrate,
 local_import reload parameter and anything else you want. Then I just need
 to remember to set the flag True or False depending on the situation.
>> 
 RMMV
>> 
 Ron




[web2py] Re: background task error

2011-02-02 Thread pbreit
I commented out:
#import gluon.import_all

But now I get:

localhost:Resources pbreit$ python web2py.py -S myapp -M -N -R 
applications/myapp/private/expire_items.py
Traceback (most recent call last):
  File "web2py.py", line 4, in 
from gluon.widget import start
ImportError: No module named gluon.widget

Running MacOS



[web2py] Re: form / subform / adding row (field)...

2011-02-02 Thread skwasha
I'm curious if you ever got this all figured out? I wanna do something
similar (essentially allow people to build up lists of things with
arbitrary list length.) If you had something complete I'd love to see
it if possible. Very new to web2py myself.

On Jan 24, 11:27 am, Richard Vézina 
wrote:
> Found this :
>
> http://code.google.com/p/django-dynamic-formset/
>
> Richard
>
> On Fri, Jan 21, 2011 at 3:34 PM, Richard Vézina 
>
>
> > wrote:
> > Hello,
>
> > Here a version 0.1 pre pre before alpha [?]
> > (see attachement)
>
> > But it works...
>
> > There is code in :
>
> > layout.html in head : js that I move there to get debug web2py button (no
> > view)
> > default controller : register_new function and a couple of other functions
>
> > default/register_new
>
> > Add row button add all the rows you want. Fill it up submit... Go admin
> > db.address see that there is a row for each added input for street and city.
>
> > Didn't test it to much.
>
> > I had to use request.vars to get street2, city2, etc. inputs that were
> > filtered by .accept()
>
> > Validators not working for the added inputs... If one input is fill for
> > required field it will pass and null will be entered in db.address for empty
> > input.
>
> > Richard
>
> > On Wed, Jan 19, 2011 at 10:21 AM, Richard Vézina <
> > ml.richard.vez...@gmail.com> wrote:
>
> >> If you move the script into the layout.html in the head it still works...
> >> You can then remove the view /view/default/register.html_
>
> >> So you get access to admin, request, session, response button to see what
> >> going. You can see that city2 vars is store in session for example.
>
> >> Richard
>
> >> On Wed, Jan 19, 2011 at 10:17 AM, Richard Vézina <
> >> ml.richard.vez...@gmail.com> wrote:
>
> >>> For now only adding and removing city input. I clone city input retag
> >>> id='city' to id='city2' for the first clone and so on. I change all the id
> >>> attribute of other tag cloned like divs. I had a garbage can icon and make
> >>> it mouseover. That it for now.
>
> >>> Since I change the id of input to city2, city3 all those cloned input are
> >>> not consider by the register controller for now. I have to figure out how
> >>> _filter_fields works to modifying it (add regex hope it will work). Then I
> >>> would like the controller to add as many rows in the "subform" or table2
> >>> (address table) as there is cloned city input fields.
>
> >>> If I am not changing the id of input it will not be w3c html compliant,
> >>> but web2py will insert all the added input filled into city field of 
> >>> address
> >>> table like this :
>
> >>> |city1|city2|city3|etc|
>
> >>> Not bad but not normalized schema and possibly problematic if length of
> >>> city field is fixed or using to much space for nothing.
>
> >>> If you feel that you know how to modify register function I will be glad
> >>> for your help.
>
> >>> When it read, we could had a new recipe into the book ;-)
>
> >>> Richard
>
> >>> On Wed, Jan 19, 2011 at 9:48 AM, mart  wrote:
>
>  Excellent! je prends le train, direction MTL, a tous les quelques mois
>  pour me rendre au bureau (peut-etre un peu moins souvent l'hiver ;) )
>
>  SO, I have a question: Once, I use the button to add a field (which
>  does work well), what should be the expected back-end result? does one
>  of the tables get updated? or should a new table get generated based
>  on input type? How about a Field name? generic one name fits all (or
>  depends on type?)
>
>  Mart :)
>
>  On Jan 19, 9:12 am, Richard Vézina 
>  wrote:
>  > ;-) Originellement oui...
>
>  > I would tell you on the orther thread that I post this one... I will
>  do it
>  > just for the one that fall on the orther thread so they could keep
>  track...
>
>  > I continue today working on this.
>
>  > Richard
>
>  > On Wed, Jan 19, 2011 at 12:30 AM, mart  wrote:
>  > > Hey, es-tu de Montreal?
>
>  > > On Jan 18, 7:08 pm, Richard Vézina 
>  > > wrote:
>  > > > I forgot to paste :
>
>  > > > def register():
>  > > >     form=SQLFORM.factory(db.client, db.address, formstyle =
>  'divs') #,
>  > > > table_name='dummy_name')
>  > > >     if form.accepts(request.vars):
>  > > >         id =
>  db.client.insert(**db.client._filter_fields(form.vars))
>  > > >         form.vars.client=id
>  > > >         id =
>  db.address.insert(**db.address._filter_fields(form.vars))
>  > > >         response.flash='Thanks for filling the form'
>  > > >     return dict(form=form)
>
>  > > > What to do for what in red?
>
>  > > > I think _filter_fields is the key of the problem...
>
>  > > > I didn't have a look to it actually...
>
>  > > > Richard
>
>  > > > On Tue, Jan 18, 2011 at 7:00 PM, Richard Vézina <
>  > > ml.richard.vez...@gmail.com
>
>  > > > > wrote:
>  > > > > Hello Massimo,
>
>

[web2py] First web2py app - some advice needed

2011-02-02 Thread skwasha
Making my first foray into web2py and wanted to run a few things by
the list.

Let's say I want to have a list of Libraries, each of which contains a
Collection of Books. Here's what I've got so far:

db.define_table('library',
Field('id','id',
  represent=lambda id:SPAN(id,'
',A('view',_href=URL('library_read',args=id,
Field('name', type='string', notnull=True,
  label=T('Name')),
Field('address', type='string', notnull=True,
  label=T('Address')),
format='%(name)s',
migrate=settings.migrate)

db.define_table('book',
Field('id','id',
  represent=lambda id:SPAN(id,'
',A('view',_href=URL('book_read',args=id,
Field('title', type='string', notnull=True,
  label=T('Title')),
Field('author', type='string', notnull=True,
  label=T('Author')),
format='%(name)s',
migrate=settings.migrate)

db.define_table('collection',
Field('id','id',
  represent=lambda id:SPAN(id,'
',A('view',_href=URL('collection_read',args=id,
Field('library_id', type='reference library',
  label=T('Library ID')),
Field('book_id', type='reference book',
  label=T('Book ID')),
format='%(name)s',
migrate=settings.migrate)

Ultimately I would add other fields to the tables, stuff like a
checked_out boolean in Collections, or a rating in Books, etc.

Now, inserting and dealing with individual items is no problem (the
provided examples cover this fairly well.) Where I'm getting confused
is in how to make it a bit more user friendly. I'd like to be able to
have the Library creation form also allow Book entries. So, when
entering a new Library, you also have fields for the Books in that
Library's Collection. If the Book has already been entered pull it up
from autocomplete. Since there's also no set number of Books in a
collection, how would I keep adding additional Book entry fields to
the end of the form?

Any advice or pointers would be much appreciated.

thanx!



[web2py] Re: form / subform / adding row (field)...

2011-02-02 Thread skwasha
I'm curious if you ever got this all figured out? I wanna do something
similar (allow users to create lists of things of arbitrary list
length.) I'm new to web2py myself, so if you had something working
you'd be willing to share it'd be of great interest/help.

thanx

On Jan 24, 11:27 am, Richard Vézina 
wrote:
> Found this :
>
> http://code.google.com/p/django-dynamic-formset/
>
> Richard
>
> On Fri, Jan 21, 2011 at 3:34 PM, Richard Vézina 
>
>
> > wrote:
> > Hello,
>
> > Here a version 0.1 pre pre before alpha [?]
> > (see attachement)
>
> > But it works...
>
> > There is code in :
>
> > layout.html in head : js that I move there to get debug web2py button (no
> > view)
> > default controller : register_new function and a couple of other functions
>
> > default/register_new
>
> > Add row button add all the rows you want. Fill it up submit... Go admin
> > db.address see that there is a row for each added input for street and city.
>
> > Didn't test it to much.
>
> > I had to use request.vars to get street2, city2, etc. inputs that were
> > filtered by .accept()
>
> > Validators not working for the added inputs... If one input is fill for
> > required field it will pass and null will be entered in db.address for empty
> > input.
>
> > Richard
>
> > On Wed, Jan 19, 2011 at 10:21 AM, Richard Vézina <
> > ml.richard.vez...@gmail.com> wrote:
>
> >> If you move the script into the layout.html in the head it still works...
> >> You can then remove the view /view/default/register.html_
>
> >> So you get access to admin, request, session, response button to see what
> >> going. You can see that city2 vars is store in session for example.
>
> >> Richard
>
> >> On Wed, Jan 19, 2011 at 10:17 AM, Richard Vézina <
> >> ml.richard.vez...@gmail.com> wrote:
>
> >>> For now only adding and removing city input. I clone city input retag
> >>> id='city' to id='city2' for the first clone and so on. I change all the id
> >>> attribute of other tag cloned like divs. I had a garbage can icon and make
> >>> it mouseover. That it for now.
>
> >>> Since I change the id of input to city2, city3 all those cloned input are
> >>> not consider by the register controller for now. I have to figure out how
> >>> _filter_fields works to modifying it (add regex hope it will work). Then I
> >>> would like the controller to add as many rows in the "subform" or table2
> >>> (address table) as there is cloned city input fields.
>
> >>> If I am not changing the id of input it will not be w3c html compliant,
> >>> but web2py will insert all the added input filled into city field of 
> >>> address
> >>> table like this :
>
> >>> |city1|city2|city3|etc|
>
> >>> Not bad but not normalized schema and possibly problematic if length of
> >>> city field is fixed or using to much space for nothing.
>
> >>> If you feel that you know how to modify register function I will be glad
> >>> for your help.
>
> >>> When it read, we could had a new recipe into the book ;-)
>
> >>> Richard
>
> >>> On Wed, Jan 19, 2011 at 9:48 AM, mart  wrote:
>
>  Excellent! je prends le train, direction MTL, a tous les quelques mois
>  pour me rendre au bureau (peut-etre un peu moins souvent l'hiver ;) )
>
>  SO, I have a question: Once, I use the button to add a field (which
>  does work well), what should be the expected back-end result? does one
>  of the tables get updated? or should a new table get generated based
>  on input type? How about a Field name? generic one name fits all (or
>  depends on type?)
>
>  Mart :)
>
>  On Jan 19, 9:12 am, Richard Vézina 
>  wrote:
>  > ;-) Originellement oui...
>
>  > I would tell you on the orther thread that I post this one... I will
>  do it
>  > just for the one that fall on the orther thread so they could keep
>  track...
>
>  > I continue today working on this.
>
>  > Richard
>
>  > On Wed, Jan 19, 2011 at 12:30 AM, mart  wrote:
>  > > Hey, es-tu de Montreal?
>
>  > > On Jan 18, 7:08 pm, Richard Vézina 
>  > > wrote:
>  > > > I forgot to paste :
>
>  > > > def register():
>  > > >     form=SQLFORM.factory(db.client, db.address, formstyle =
>  'divs') #,
>  > > > table_name='dummy_name')
>  > > >     if form.accepts(request.vars):
>  > > >         id =
>  db.client.insert(**db.client._filter_fields(form.vars))
>  > > >         form.vars.client=id
>  > > >         id =
>  db.address.insert(**db.address._filter_fields(form.vars))
>  > > >         response.flash='Thanks for filling the form'
>  > > >     return dict(form=form)
>
>  > > > What to do for what in red?
>
>  > > > I think _filter_fields is the key of the problem...
>
>  > > > I didn't have a look to it actually...
>
>  > > > Richard
>
>  > > > On Tue, Jan 18, 2011 at 7:00 PM, Richard Vézina <
>  > > ml.richard.vez...@gmail.com
>
>  > > > > wrote:
>  > > > > H

[web2py] IS_MATCH() changing a valid value ?

2011-02-02 Thread Ken
I have been having trouble with truncation of data from one field of a
form. The culprit turned out to be the IS_MATCH() validator, which was
truncating a valid value to return a shorter valid value. I'm not sure
whether to call this a bug or just unexpected behavior, but if I had
trouble with it, someone else may.

The data in question were spreadsheet-style coordinate values with
letters for rows and numbers for columns, in the range A1 to J10.
Initially, I used a validator like IS_MATCH('^[A-J][1-9]|[A-J]10$').
This checks first for the two-character combinations A1 to J9, then
checks for A10 to J10. If I test this in a web2py shell, it accepts
and returns the two-character combinations, but it accepts and
truncates any values ending in 10.

In [1] : vdtr = IS_MATCH('^[A-J][1-9]|[A-J]10$')

In [2] : vdtr('A1')
('A1', None)

In [3] : vdtr('J1')
('J1', None)

In [4] : vdtr('A10')
('A1', None)

In [5] : vdtr('J10')
('J1', None)

It seems to me that A1 and J1 are not proper matches because the '1'
does not appear at the end of the validated string. In any case, I am
surprised that IS_MATCH() would modify a value under any
circumstances.

If I turn the regex around, so that it tests for the three-character
combinations first, like IS_MATCH('^[A-J]10|[A-J][1-9]$'), then things
work better.

In [6] : vdtr = IS_MATCH('^[A-J]10|[A-J][1-9]$')

In [7] : vdtr('A1')
('A1', None)

In [8] : vdtr('J1')
('J1', None)

In [9] : vdtr('A10')
('A10', None)

In [10] : vdtr('J10')
('J10', None)



[web2py] Re: background task error

2011-02-02 Thread Massimo Di Pierro
Can you please try the OSX binary "nightly build" from the web2py
download page?



On Feb 2, 7:56 pm, pbreit  wrote:
> I commented out:
> #import gluon.import_all
>
> But now I get:
>
> localhost:Resources pbreit$ python web2py.py -S myapp -M -N -R
> applications/myapp/private/expire_items.py
> Traceback (most recent call last):
>   File "web2py.py", line 4, in 
>     from gluon.widget import start
> ImportError: No module named gluon.widget
>
> Running MacOS


[web2py] Re: form / subform / adding row (field)...

2011-02-02 Thread Massimo Di Pierro
I am not sure what the Django doce does. Did you look into
Field('items','list:string')?
Is that any close?



On Feb 2, 5:40 pm, skwasha  wrote:
> I'm curious if you ever got this all figured out? I wanna do something
> similar (essentially allow people to build up lists of things with
> arbitrary list length.) If you had something complete I'd love to see
> it if possible. Very new to web2py myself.
>
> On Jan 24, 11:27 am, Richard Vézina 
> wrote:
>
>
>
>
>
>
>
> > Found this :
>
> >http://code.google.com/p/django-dynamic-formset/
>
> > Richard
>
> > On Fri, Jan 21, 2011 at 3:34 PM, Richard Vézina 
> > > wrote:
> > > Hello,
>
> > > Here a version 0.1 pre pre before alpha [?]
> > > (see attachement)
>
> > > But it works...
>
> > > There is code in :
>
> > > layout.html in head : js that I move there to get debug web2py button (no
> > > view)
> > > default controller : register_new function and a couple of other functions
>
> > > default/register_new
>
> > > Add row button add all the rows you want. Fill it up submit... Go admin
> > > db.address see that there is a row for each added input for street and 
> > > city.
>
> > > Didn't test it to much.
>
> > > I had to use request.vars to get street2, city2, etc. inputs that were
> > > filtered by .accept()
>
> > > Validators not working for the added inputs... If one input is fill for
> > > required field it will pass and null will be entered in db.address for 
> > > empty
> > > input.
>
> > > Richard
>
> > > On Wed, Jan 19, 2011 at 10:21 AM, Richard Vézina <
> > > ml.richard.vez...@gmail.com> wrote:
>
> > >> If you move the script into the layout.html in the head it still works...
> > >> You can then remove the view /view/default/register.html_
>
> > >> So you get access to admin, request, session, response button to see what
> > >> going. You can see that city2 vars is store in session for example.
>
> > >> Richard
>
> > >> On Wed, Jan 19, 2011 at 10:17 AM, Richard Vézina <
> > >> ml.richard.vez...@gmail.com> wrote:
>
> > >>> For now only adding and removing city input. I clone city input retag
> > >>> id='city' to id='city2' for the first clone and so on. I change all the 
> > >>> id
> > >>> attribute of other tag cloned like divs. I had a garbage can icon and 
> > >>> make
> > >>> it mouseover. That it for now.
>
> > >>> Since I change the id of input to city2, city3 all those cloned input 
> > >>> are
> > >>> not consider by the register controller for now. I have to figure out 
> > >>> how
> > >>> _filter_fields works to modifying it (add regex hope it will work). 
> > >>> Then I
> > >>> would like the controller to add as many rows in the "subform" or table2
> > >>> (address table) as there is cloned city input fields.
>
> > >>> If I am not changing the id of input it will not be w3c html compliant,
> > >>> but web2py will insert all the added input filled into city field of 
> > >>> address
> > >>> table like this :
>
> > >>> |city1|city2|city3|etc|
>
> > >>> Not bad but not normalized schema and possibly problematic if length of
> > >>> city field is fixed or using to much space for nothing.
>
> > >>> If you feel that you know how to modify register function I will be glad
> > >>> for your help.
>
> > >>> When it read, we could had a new recipe into the book ;-)
>
> > >>> Richard
>
> > >>> On Wed, Jan 19, 2011 at 9:48 AM, mart  wrote:
>
> >  Excellent! je prends le train, direction MTL, a tous les quelques mois
> >  pour me rendre au bureau (peut-etre un peu moins souvent l'hiver ;) )
>
> >  SO, I have a question: Once, I use the button to add a field (which
> >  does work well), what should be the expected back-end result? does one
> >  of the tables get updated? or should a new table get generated based
> >  on input type? How about a Field name? generic one name fits all (or
> >  depends on type?)
>
> >  Mart :)
>
> >  On Jan 19, 9:12 am, Richard Vézina 
> >  wrote:
> >  > ;-) Originellement oui...
>
> >  > I would tell you on the orther thread that I post this one... I will
> >  do it
> >  > just for the one that fall on the orther thread so they could keep
> >  track...
>
> >  > I continue today working on this.
>
> >  > Richard
>
> >  > On Wed, Jan 19, 2011 at 12:30 AM, mart  wrote:
> >  > > Hey, es-tu de Montreal?
>
> >  > > On Jan 18, 7:08 pm, Richard Vézina 
> >  > > wrote:
> >  > > > I forgot to paste :
>
> >  > > > def register():
> >  > > >     form=SQLFORM.factory(db.client, db.address, formstyle =
> >  'divs') #,
> >  > > > table_name='dummy_name')
> >  > > >     if form.accepts(request.vars):
> >  > > >         id =
> >  db.client.insert(**db.client._filter_fields(form.vars))
> >  > > >         form.vars.client=id
> >  > > >         id =
> >  db.address.insert(**db.address._filter_fields(form.vars))
> >  > > >         response.flash='Thanks for filling

[web2py] Re: IS_MATCH() changing a valid value ?

2011-02-02 Thread Massimo Di Pierro
This is the correct behavio of regular expressions. Anyway, good that
you are pointing this out since others may find it counter intuitive.

Massimo

On Feb 2, 6:33 pm, Ken  wrote:
> I have been having trouble with truncation of data from one field of a
> form. The culprit turned out to be the IS_MATCH() validator, which was
> truncating a valid value to return a shorter valid value. I'm not sure
> whether to call this a bug or just unexpected behavior, but if I had
> trouble with it, someone else may.
>
> The data in question were spreadsheet-style coordinate values with
> letters for rows and numbers for columns, in the range A1 to J10.
> Initially, I used a validator like IS_MATCH('^[A-J][1-9]|[A-J]10$').
> This checks first for the two-character combinations A1 to J9, then
> checks for A10 to J10. If I test this in a web2py shell, it accepts
> and returns the two-character combinations, but it accepts and
> truncates any values ending in 10.
>
> In [1] : vdtr = IS_MATCH('^[A-J][1-9]|[A-J]10$')
>
> In [2] : vdtr('A1')
> ('A1', None)
>
> In [3] : vdtr('J1')
> ('J1', None)
>
> In [4] : vdtr('A10')
> ('A1', None)
>
> In [5] : vdtr('J10')
> ('J1', None)
>
> It seems to me that A1 and J1 are not proper matches because the '1'
> does not appear at the end of the validated string. In any case, I am
> surprised that IS_MATCH() would modify a value under any
> circumstances.
>
> If I turn the regex around, so that it tests for the three-character
> combinations first, like IS_MATCH('^[A-J]10|[A-J][1-9]$'), then things
> work better.
>
> In [6] : vdtr = IS_MATCH('^[A-J]10|[A-J][1-9]$')
>
> In [7] : vdtr('A1')
> ('A1', None)
>
> In [8] : vdtr('J1')
> ('J1', None)
>
> In [9] : vdtr('A10')
> ('A10', None)
>
> In [10] : vdtr('J10')
> ('J10', None)


[web2py] Re: background task error

2011-02-02 Thread pbreit
Same error:

localhost:Resources pbreit$ python web2py.py
Traceback (most recent call last):
  File "web2py.py", line 16, in 
import gluon.widget
ImportError: No module named gluon.widget


Could there be a path issue? I do have another python installation on my 
Mac.


Re: [web2py] IS_MATCH() changing a valid value ?

2011-02-02 Thread Jonathan Lundell
On Feb 2, 2011, at 4:33 PM, Ken wrote:
> 
> I have been having trouble with truncation of data from one field of a
> form. The culprit turned out to be the IS_MATCH() validator, which was
> truncating a valid value to return a shorter valid value. I'm not sure
> whether to call this a bug or just unexpected behavior, but if I had
> trouble with it, someone else may.
> 
> The data in question were spreadsheet-style coordinate values with
> letters for rows and numbers for columns, in the range A1 to J10.
> Initially, I used a validator like IS_MATCH('^[A-J][1-9]|[A-J]10$').
> This checks first for the two-character combinations A1 to J9, then
> checks for A10 to J10. If I test this in a web2py shell, it accepts
> and returns the two-character combinations, but it accepts and
> truncates any values ending in 10.
> 
> In [1] : vdtr = IS_MATCH('^[A-J][1-9]|[A-J]10$')

This is because the precedence of alternation is very low. If you make the 
precedence explicit, your pattern is really:

> vdtr = IS_MATCH('(^[A-J][1-9])|([A-J]10$)')

You can fix it like this:

> vdtr = IS_MATCH('^([A-J][1-9]|[A-J]10)$')




[web2py] Re: upload an excel sheet to be added to the system

2011-02-02 Thread Brian M
Neveen,

I've got a mini app that I upload excel files to for later parsing, here's 
now I do it. Getting the file would probably be even easier if you used an 
upload field in the DB & CRUD forms.

def excel_uploader():
response.subtitle = "Upload excel file "
from gluon.sqlhtml import form_factory
form=form_factory(SQLField('import_xls','upload'))
if form.accepts(request.vars,session):
request.flash='Received: %s'%request.vars.import_xls
path = 
os.path.join(request.folder,'private','spreadsheet_to_process.xls')
#I happen to be copying the uploaded file to a known location & 
filename, but you wouldn't have to
#the uploaded file gets saved to the /uploads folder with a 
auto-generated name too
import shutil
shutil.copyfileobj(request.vars.import_xls.file,open(path, 'wb'))

#Then redirect to the next screen (or do the processing now)
redirect(URL(r=request, f='process_excel'))

return dict(form=form)

def process_excel():
import xlrd
from applications.app_name.modules.readexcel import readexcel as 
readexcel
#see 
http://code.activestate.com/recipes/483742-easy-cross-platform-excel-parsing-with-xlrd/


excel_filepath = 
os.path.join(request.folder,'private','spreadsheet_to_process.xls')
xl = readexcel(excel_filepath)
sheetnames = xl.worksheets()
#for sheet in sheetnames:
#print sheet
#for row in xl.getiter('Sheet  name'):
#print row
return dict(rows = xl.getiter('Sheet Contents'))


[web2py] Re: Support for Drizzle in web2py

2011-02-02 Thread KMax

http://wiki.drizzle.org/FAQ
Can I run a website with this?
No. We are still making incompatible changes, and certainly do not
believe the code is production quality. Right now we are defaulting
many configure operations to generate debugging code for us so our
binaries are not optimal. Therefore, do not go out and benchmark this
and expect it to be one way or the other. We are currently only doing
benchmarks where it makes sense for us to determine where bottlenecks
are.


On 2 фев, 11:57, Rahul  wrote:
> Hi All,
>        http://drizzle.org/Home.html
>        Not really sure if web2py should support Drizzle (opensource
> MYSQL forked Database). Will pymysql work with Drizzle? What do you
> think? Also is MySQL free for professional development now? or we need
> to pay a fee. Oracle - MySQL site does show us license fees etc.
>
> Rahul


[web2py] Re: Mixing/supporting CMS with Web2py

2011-02-02 Thread KMax
Once I have idea for seamless moving from joomla for web2py.
Stoped on attaching to joomla users table and joomla coocke of
loggined in.

Maing goal was to use links in joomla site to web2py functions which
should use user auth from joomla.
And with several steps move completely to web2py or share functions
along two application (joomla and web2py part)

On 2 фев, 18:46, Carl  wrote:
> has anyone direct experience of using Wordpress, SquareSpace or
> similar solution alongside Web2py?
>
> These solutions appeal for their maturity and I'd like to use one to
> do the "donkey" work and fall back to Web2py to do my site's specific
> functionality.
>
> Without them I feel like I'm reinventing needlessly.


Re: [web2py] Re: form / subform / adding row (field)...

2011-02-02 Thread Richard Vézina
The app I had attached in the preceding email works, but it broke the
workflow. I can't get the added inputs values in form.vars, so I take them
from request.vars or somewhere else don't remember...

There is also an other problem with this hack... It not uses de validators
for all the inputs... So as long as there is one filled input the form
submit and the other added inputs will let pass empty value or if you prefer
NULL will be inserted.

But at least you will be able to add all the field you want no matter how
many field the subform contain... Remove the added field you no more want if
you add to much inputs.

Submit and the data will be all linked or related to the id of the record of
the "master" table or the base table form.

 The jQuery script has to be edited by hand for each subform (or subtable
you use). If you modify your subtable (add a field) you will have to go
change the jQuery script... I just tried to make a proof of concept and see
what were the limits... So nothing fancy with the code. There is also a
couple of jQuery lines that were not working properly in this version I
think.

Ha yeah there is an other issue on read or update... There is no way to make
it works with crud.read or crud.update (I did not try anything about that
when I realize I broked the workflow).

Also, there is no way to make SQLFORM.factory works on update or read (edit
your linked data)... At least there is no easy already available way. You
have to crud.update on subtable and master table independantly to make any
change after the first seizure.

I did not have time last week to continue to work on that.

I identified differents alternatives that I did not explored in details yet
:

1) There is a "lib" in django for doing exactly that. I don't know django,
but the basic (tutorial 1, 2, 3, 4).

2) There is also Pyjamas that could be use into web2py... It seems to me the
most cumbersome alternative, since I have to learn many differents things.

3) WTForms... I also have to learn a lot to figure out if it could work with
web2py or if it has to be stand alone. If it needs work separately I actualy
think to explore if a loosely coupled framework could be more reliable for
my needs (Flask, WTForms, WSGI, jinja...)

That where I am...

I appreciate any help to push further the reflexion or build something...

Richard


On Wed, Feb 2, 2011 at 6:45 PM, skwasha  wrote:

> I'm curious if you ever got this all figured out? I wanna do something
> similar (allow users to create lists of things of arbitrary list
> length.) I'm new to web2py myself, so if you had something working
> you'd be willing to share it'd be of great interest/help.
>
> thanx
>
> On Jan 24, 11:27 am, Richard Vézina 
> wrote:
> > Found this :
> >
> > http://code.google.com/p/django-dynamic-formset/
> >
> > Richard
> >
> > On Fri, Jan 21, 2011 at 3:34 PM, Richard Vézina <
> ml.richard.vez...@gmail.com
> >
> >
> >
> > > wrote:
> > > Hello,
> >
> > > Here a version 0.1 pre pre before alpha [?]
> > > (see attachement)
> >
> > > But it works...
> >
> > > There is code in :
> >
> > > layout.html in head : js that I move there to get debug web2py button
> (no
> > > view)
> > > default controller : register_new function and a couple of other
> functions
> >
> > > default/register_new
> >
> > > Add row button add all the rows you want. Fill it up submit... Go admin
> > > db.address see that there is a row for each added input for street and
> city.
> >
> > > Didn't test it to much.
> >
> > > I had to use request.vars to get street2, city2, etc. inputs that were
> > > filtered by .accept()
> >
> > > Validators not working for the added inputs... If one input is fill for
> > > required field it will pass and null will be entered in db.address for
> empty
> > > input.
> >
> > > Richard
> >
> > > On Wed, Jan 19, 2011 at 10:21 AM, Richard Vézina <
> > > ml.richard.vez...@gmail.com> wrote:
> >
> > >> If you move the script into the layout.html in the head it still
> works...
> > >> You can then remove the view /view/default/register.html_
> >
> > >> So you get access to admin, request, session, response button to see
> what
> > >> going. You can see that city2 vars is store in session for example.
> >
> > >> Richard
> >
> > >> On Wed, Jan 19, 2011 at 10:17 AM, Richard Vézina <
> > >> ml.richard.vez...@gmail.com> wrote:
> >
> > >>> For now only adding and removing city input. I clone city input retag
> > >>> id='city' to id='city2' for the first clone and so on. I change all
> the id
> > >>> attribute of other tag cloned like divs. I had a garbage can icon and
> make
> > >>> it mouseover. That it for now.
> >
> > >>> Since I change the id of input to city2, city3 all those cloned input
> are
> > >>> not consider by the register controller for now. I have to figure out
> how
> > >>> _filter_fields works to modifying it (add regex hope it will work).
> Then I
> > >>> would like the controller to add as many rows in the

Re: [web2py] Re: form / subform / adding row (field)...

2011-02-02 Thread Richard Vézina
Ref about my search on this topic :

RANDOM : NO ORDER

Here the funding thread of WTForms FormBase :
http://groups.google.com/group/wtforms/browse_frm/thread/c8b5f5d98c41a6d2/6e69c5c4e820fd7b?lnk=gst&q=subform#6e69c5c4e820fd7b


Subform seems a long awaiting feature :
http://groups.google.com/group/web2py/browse_thread/thread/8d50fd87d0f2e233?pli=1
http://groups.google.com/group/web2py/browse_thread/thread/4cc5d30600c628bb
http://web2py.uservoice.com/forums/42577-general/suggestions/525773-create-a-new-form-system-?ref=title

Here the funding thread of WTForms FormBase :
http://groups.google.com/group/wtforms/browse_frm/thread/c8b5f5d98c41a6d2/6e69c5c4e820fd7b?lnk=gst&q=subform#6e69c5c4e820fd7b

Looks like a solution :

http://wtforms.simplecodes.com/

Django inline formset :
http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#inline-formsets

There is also this :
http://code.google.com/p/django-dynamic-formset/
That I already post above... That is something like what I did on cocaine
for django ;-)

Richard

On Wed, Feb 2, 2011 at 10:34 PM, Richard Vézina  wrote:

> The app I had attached in the preceding email works, but it broke the
> workflow. I can't get the added inputs values in form.vars, so I take them
> from request.vars or somewhere else don't remember...
>
> There is also an other problem with this hack... It not uses de validators
> for all the inputs... So as long as there is one filled input the form
> submit and the other added inputs will let pass empty value or if you prefer
> NULL will be inserted.
>
> But at least you will be able to add all the field you want no matter how
> many field the subform contain... Remove the added field you no more want if
> you add to much inputs.
>
> Submit and the data will be all linked or related to the id of the record
> of the "master" table or the base table form.
>
>  The jQuery script has to be edited by hand for each subform (or subtable
> you use). If you modify your subtable (add a field) you will have to go
> change the jQuery script... I just tried to make a proof of concept and see
> what were the limits... So nothing fancy with the code. There is also a
> couple of jQuery lines that were not working properly in this version I
> think.
>
> Ha yeah there is an other issue on read or update... There is no way to
> make it works with crud.read or crud.update (I did not try anything about
> that when I realize I broked the workflow).
>
> Also, there is no way to make SQLFORM.factory works on update or read (edit
> your linked data)... At least there is no easy already available way. You
> have to crud.update on subtable and master table independantly to make any
> change after the first seizure.
>
> I did not have time last week to continue to work on that.
>
> I identified differents alternatives that I did not explored in details yet
> :
>
> 1) There is a "lib" in django for doing exactly that. I don't know django,
> but the basic (tutorial 1, 2, 3, 4).
>
> 2) There is also Pyjamas that could be use into web2py... It seems to me
> the most cumbersome alternative, since I have to learn many differents
> things.
>
> 3) WTForms... I also have to learn a lot to figure out if it could work
> with web2py or if it has to be stand alone. If it needs work separately I
> actualy think to explore if a loosely coupled framework could be more
> reliable for my needs (Flask, WTForms, WSGI, jinja...)
>
> That where I am...
>
> I appreciate any help to push further the reflexion or build something...
>
> Richard
>
>
> On Wed, Feb 2, 2011 at 6:45 PM, skwasha  wrote:
>
>> I'm curious if you ever got this all figured out? I wanna do something
>> similar (allow users to create lists of things of arbitrary list
>> length.) I'm new to web2py myself, so if you had something working
>> you'd be willing to share it'd be of great interest/help.
>>
>> thanx
>>
>> On Jan 24, 11:27 am, Richard Vézina 
>> wrote:
>> > Found this :
>> >
>> > http://code.google.com/p/django-dynamic-formset/
>> >
>> > Richard
>> >
>> > On Fri, Jan 21, 2011 at 3:34 PM, Richard Vézina <
>> ml.richard.vez...@gmail.com
>> >
>> >
>> >
>> > > wrote:
>> > > Hello,
>> >
>> > > Here a version 0.1 pre pre before alpha [?]
>> > > (see attachement)
>> >
>> > > But it works...
>> >
>> > > There is code in :
>> >
>> > > layout.html in head : js that I move there to get debug web2py button
>> (no
>> > > view)
>> > > default controller : register_new function and a couple of other
>> functions
>> >
>> > > default/register_new
>> >
>> > > Add row button add all the rows you want. Fill it up submit... Go
>> admin
>> > > db.address see that there is a row for each added input for street and
>> city.
>> >
>> > > Didn't test it to much.
>> >
>> > > I had to use request.vars to get street2, city2, etc. inputs that were
>> > > f

[web2py] Re: Support for Drizzle in web2py

2011-02-02 Thread Massimo Di Pierro
yet all of the changes listed are in APIs that are not used by web2py
in MySQL.

On Feb 2, 9:18 pm, KMax  wrote:
> http://wiki.drizzle.org/FAQ
> Can I run a website with this?
> No. We are still making incompatible changes, and certainly do not
> believe the code is production quality. Right now we are defaulting
> many configure operations to generate debugging code for us so our
> binaries are not optimal. Therefore, do not go out and benchmark this
> and expect it to be one way or the other. We are currently only doing
> benchmarks where it makes sense for us to determine where bottlenecks
> are.
>
> On 2 фев, 11:57, Rahul  wrote:
>
>
>
>
>
>
>
> > Hi All,
> >        http://drizzle.org/Home.html
> >        Not really sure if web2py should support Drizzle (opensource
> > MYSQL forked Database). Will pymysql work with Drizzle? What do you
> > think? Also is MySQL free for professional development now? or we need
> > to pay a fee. Oracle - MySQL site does show us license fees etc.
>
> > Rahul


[web2py] pending issues?

2011-02-02 Thread Massimo Di Pierro
Is there any pending issues I have forgotten about?

Please verify the problem persist in trunk or check the nightly built
(on the web2py download page) and either post a link to the issue in
this thread to remind me or open an issue on googlecode (better).

I would like to try close as many issues as possible and release a new
stable web2py by the end of the week.


[web2py] Re: pending issues?

2011-02-02 Thread Massimo Di Pierro
clarification by issue I do not mean any question (how do I do
this?) but a possible bug issue.

On Feb 2, 10:31 pm, Massimo Di Pierro 
wrote:
> Is there any pending issues I have forgotten about?
>
> Please verify the problem persist in trunk or check the nightly built
> (on the web2py download page) and either post a link to the issue in
> this thread to remind me or open an issue on googlecode (better).
>
> I would like to try close as many issues as possible and release a new
> stable web2py by the end of the week.


  1   2   >