Re: [web2py] Re: order by surname, name

2011-02-03 Thread Johann Spies
On 3 February 2011 16:49, Marin Pranjic  wrote:

> + you can use ~ to reverse order.
>
>
> http://web2py.com/book/default/chapter/06#orderby,-groupby,-limitby,-distinct
>
>
> On Thu, Feb 3, 2011 at 2:21 PM, dederocks  wrote:
>
>> Hi Johann,
>>
>> Just use "|":
>> orderby=db.table.name|db.table.surname
>>
>>
Thanks.  I missed that in the book.

Regards
Johann

-- 
 May grace and peace be yours in abundance through the full knowledge of God
and of Jesus our Lord!  His divine power has given us everything we need for
life and godliness through the full knowledge of the one who called us by
his own glory and excellence.
2 Pet. 1:2b,3a


[web2py] Re: powertable problem

2011-02-03 Thread ceriox
Kenneth -> i just copy the code from a powertable example app
(web2py.app.skrywer_powertable.w2p) now i try to delete ".load"

Bruno Rocha -> i download it yesterday from your website
http://powertable.blouweb.com/ , now i try to re-download the plugin
from bitbucket

thanks for help!

Bruno Rocha -> there is a guide with all the powertable parameters ?



[web2py] Re: Redirect after GAE authorization.

2011-02-03 Thread walter
My previous post has look ambiguous enough. I use GAE to run my web2py
application.


[web2py] Re: Unable to run web2py from Mac command line

2011-02-03 Thread pbreit
OK, thanks, that must be it. I noodled around with Snow Leopard python in 
order to run Fabric from my Mac.

[web2py] Re: Unable to run web2py from Mac command line

2011-02-03 Thread pbreit
I should mention that I have tried on two different Macs and I have tried 
both the Current Download and the Nightly Build.

[web2py] Re: Unable to run web2py from Mac command line

2011-02-03 Thread Massimo Di Pierro
My guess is that you downloaded the Mac Binary distribution. You have
to run it as a mac app with

open web2py.app

if you want to run with your own python from command line, you must
get the source distribution.

On Feb 3, 11:48 pm, pbreit  wrote:
> I am getting "No module named gluon.widget" when trying to run web2py from
> the command line on a Mac. Double-clicking web2py.app works fine. Does
> double-clicking the app add some sort of path?
>
> I have other versions of Python on my Mac. Should web2py be running off the
> Python that comes in the download? How do I force it to run off that Python?
>
> Any ideas?
>
> Resources $ which python
> /usr/bin/python
>
> Resources $ python web2py.py -h
> Traceback (most recent call last):
>   File "web2py.py", line 16, in 
>     import gluon.widget
> ImportError: No module named gluon.widget
>
> Resources $ python2.5 web2py.py -h
> Traceback (most recent call last):
>   File "web2py.py", line 16, in 
>     import gluon.widget
> ImportError: No module named gluon.widget


[web2py] Unable to run web2py from Mac command line

2011-02-03 Thread pbreit
I am getting "No module named gluon.widget" when trying to run web2py from 
the command line on a Mac. Double-clicking web2py.app works fine. Does 
double-clicking the app add some sort of path?

I have other versions of Python on my Mac. Should web2py be running off the 
Python that comes in the download? How do I force it to run off that Python?

Any ideas?

Resources $ which python
/usr/bin/python

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

Resources $ python2.5 web2py.py -h
Traceback (most recent call last):
  File "web2py.py", line 16, in 
import gluon.widget
ImportError: No module named gluon.widget



[web2py] Not a bug, but

2011-02-03 Thread Kenneth Lundström
When you create a new application with the wizard and you get to Step 1: 
Setting Parameters
fields you fill out with parameters are little bit small, especially 
Database Uri: and Security Key:


The preview of the selected layout could also be a little bit bigger.


Kenneth



Re: [web2py] Re: Need help in standardizing my coding and naming schemes before I start my main project

2011-02-03 Thread Rupesh Pradhan
How about you show me couple (say 5) of the database structures of the 
applications that you have already written? I can go through it and get some 
practical ideas.


[web2py] Re: Few general questions

2011-02-03 Thread Massimo Di Pierro
On Feb 3, 8:27 pm, devGS  wrote:
> Hi, I have a few general questions, answers for which I didn't find in
> the book:
> 1. How does the model work in web2py's MVC? What is the workflow? When
> does the code from those files called? The only relevant information I
> found was the sequence diagram from the book.

yes this is an important omission.
at every http request, all models are executed in the same
environment. Then environment is copied. The requested controller is
executed and the called function is called. The output dict() is added
to the copied environment and passed to the view. The output is
returned to the visitor.

> 2. How does the following form of passing arguments in Python work:
> cache.ram.clear(regex='...')? I come from Java, as I understand regex
> is some kind of an optional value to be passed?

regex is any regular expression. All keys in the cache matching the
regular expression are deleted from the cache.

> 3. How do the layouts work (layout as a pattern that is being used in
> the views)?  I tried to do the following, which sometimes works and
> sometimes not, providing errors: remove the {{extend 'layout.html'}}
> from some view, i.e. "myview.html" and add {{include "myview.html"}}
> into a second view. Mainly, it works, but when I try to remove
> {{extend 'layout.html'}} from "default/user.html" and add {{include
> 'default/user.html'}} into "index.html", it fails. Why, and how to do
> it properly?

Think of a tree. Each node is an HTML file. You move up by calling
extend. You move down by calling include. The parent should have a
simple {{include}} not {{include "child.html"}} where the extending
child is to be inserted. This is in the book in some detail.

> 4. I understood that in order to manipulate my database from GAE, I
> need to index my tables. Where can I find information about indexing
> and what is it?

You only need this for speed. You have to do this in sql

db.executesql("")

> 5. While uploading my app into GAE, I find the example entries inside
> my online GAE app. Why is that and how to prevent it?

I am not sure I understand this question.


Re: [web2py] Re: Checking permissions on a group

2011-02-03 Thread Jonathan Lundell
On Feb 3, 2011, at 8:00 PM, Massimo Di Pierro wrote:
> 
> please check it in trunk.

That looks about right. No log for the group case, but I don't think that a log 
here is all that important anyway.

> 
> On Feb 3, 11:10 am, Jonathan Lundell  wrote:
>> On Feb 3, 2011, at 6:14 AM, Franzé Jr wrote:
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>>> On Thu, Feb 3, 2011 at 11:08 AM, Clayton  wrote:
>>> Hello,
>> 
>>> I can't seem to find an easy way to check if a *group* has a
>>> permission without making my own query on the auth_permission table
>>> (and then I lose auth logging and the code is uglier).
>>> auth.has_permission only works on users, not groups, as far as I can
>>> tell. I need it for a control which is adding and removing permissions
>>> from groups.
>> 
>>> add_permission and del_permission use groups. Shouldn't there perhaps
>>> be a function that checks whether a group has a given permission? Or
>>> am I just missing something.
>> 
>>> Cheers,
>> 
>>> Clayton
>> 
>>> I have the same doubt.
>> 
>> Proposal:
>> 
>> Change Auth.has_permission from this:
>> 
>> def has_permission(
>> self,
>> name='any',
>> table_name='',
>> record_id=0,
>> user_id=None,
>> ):
>> 
>> to this:
>> 
>> def has_permission(
>> self,
>> name='any',
>> table_name='',
>> record_id=0,
>> user_id=None,
>> group_id=None,
>> ):
>> 
>> If the caller specifies a group_id, then we check permissions on that group 
>> instead of the groups the user belongs to. It is an error to call 
>> has_permission with both user_id and group_id.
>> 
>> The change would be simple.




[web2py] Re: Simple question on rocket server - how to disable httpserver.log

2011-02-03 Thread Massimo Di Pierro
try

web2py.py -l ''




On Feb 3, 7:37 pm, Bruno Rocha  wrote:
> Can I disable httpserver.log when running in development mode?
>
> I tried to change main.appfactory, but I messed it up, I also tried
> options.py and does not works.
>
> Can it be done?
>
> Thanks
>
> --
> Bruno Rochahttp://about.me/rochacbruno/bio


[web2py] Re: Checking permissions on a group

2011-02-03 Thread Massimo Di Pierro
please check it in trunk.

On Feb 3, 11:10 am, Jonathan Lundell  wrote:
> On Feb 3, 2011, at 6:14 AM, Franzé Jr wrote:
>
>
>
>
>
>
>
>
>
> > On Thu, Feb 3, 2011 at 11:08 AM, Clayton  wrote:
> > Hello,
>
> > I can't seem to find an easy way to check if a *group* has a
> > permission without making my own query on the auth_permission table
> > (and then I lose auth logging and the code is uglier).
> > auth.has_permission only works on users, not groups, as far as I can
> > tell. I need it for a control which is adding and removing permissions
> > from groups.
>
> > add_permission and del_permission use groups. Shouldn't there perhaps
> > be a function that checks whether a group has a given permission? Or
> > am I just missing something.
>
> > Cheers,
>
> > Clayton
>
> > I have the same doubt.
>
> Proposal:
>
> Change Auth.has_permission from this:
>
>     def has_permission(
>         self,
>         name='any',
>         table_name='',
>         record_id=0,
>         user_id=None,
>         ):
>
> to this:
>
>     def has_permission(
>         self,
>         name='any',
>         table_name='',
>         record_id=0,
>         user_id=None,
>         group_id=None,
>         ):
>
> If the caller specifies a group_id, then we check permissions on that group 
> instead of the groups the user belongs to. It is an error to call 
> has_permission with both user_id and group_id.
>
> The change would be simple.


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

2011-02-03 Thread ron_m
session.forget() will prevent you from adding to the session from that line 
forward because it inhibits storing of the session to the file at the end of 
the request. I only wanted to remove session variables if the new user was 
not the same as the previous use logged into the application from that 
particular workstation.

I put the code in the model because I wanted to jettison the session 
variable if they actually came from a different account on the application. 
With web application logouts is a very tentative thing, many users just go 
away, close the browser etc. If you then reopen the browser on that 
workstation you will pick up the original session. Putting it on the front 
end of the request cycle and comparing the auth.user_id with the 
session.saved_id allows me to see if a new user as far as the web 
application is concerned is actually logged in.

The code to clean_session looks like

def clean_session():
  session.varx = None
  session.dict2 = {}

so you build it to scrub whatever you put in the session that you do not 
want to have move from user1 to user2 when they login from the same 
workstation using the same workstation account but a different web2py 
application account.

Ron


[web2py] Re: background task error

2011-02-03 Thread pbreit
Could someone else on a Mac give this a try to see if it works? I'm still 
not able to run Web2py from the command line:

In Terminal in web2py.app/Contents/Resources, try:

$ python web2py.py

I continue to get this error on two different Macs:

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



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

2011-02-03 Thread devGS
Thanks a lot, could you post the complete code of your
clean_session()? (Why is session.forget is not sufficient?) You also
mentioned the placement of the above code in a model, why not in a
controller within the logout?


On Feb 4, 4:09 am, ron_m  wrote:
> Sorry, I didn't explain well enough.
>
> The clean_session() function is something I wrote to reset all session
> variables in the case the user is a different person logging in from the
> same machine. So it contains lines like:
>
> session.var1 = None
> session.dict1 = {}
>
> etc.
>
> The nutshell is an expression of brevity so the following couple of
> sentences explaining what the code does is what I meant.
>
> What you could do is try this out without Janrain to see how it works. I had
> the problem were several users share the same Windows workstation and the IT
> department set the workstation up with a common user id for all users. So if
> a more privileged user logged out and a less privileged one logged in the
> session file was reused and as far as teh web2py app was concerned it was
> still the same user. Browser cookies are used to establish the session id so
> if you stay on the client PC as the same user the same cookie is used the
> next time anyone logs in form that workstation. That is the way it works
> with web browsers.
>
> If you can login on the client workstation with different ids then that
> would help.
>
> I offered the above concept to show you how I got around this with  multiple
> users sharing the same login on the workstation. However I do not use
> Janrain so there are very likely other issues in there.
>
> Ron


[web2py] Few general questions

2011-02-03 Thread devGS
Hi, I have a few general questions, answers for which I didn't find in
the book:
1. How does the model work in web2py's MVC? What is the workflow? When
does the code from those files called? The only relevant information I
found was the sequence diagram from the book.
2. How does the following form of passing arguments in Python work:
cache.ram.clear(regex='...')? I come from Java, as I understand regex
is some kind of an optional value to be passed?
3. How do the layouts work (layout as a pattern that is being used in
the views)?  I tried to do the following, which sometimes works and
sometimes not, providing errors: remove the {{extend 'layout.html'}}
from some view, i.e. "myview.html" and add {{include "myview.html"}}
into a second view. Mainly, it works, but when I try to remove
{{extend 'layout.html'}} from "default/user.html" and add {{include
'default/user.html'}} into "index.html", it fails. Why, and how to do
it properly?
4. I understood that in order to manipulate my database from GAE, I
need to index my tables. Where can I find information about indexing
and what is it?
5. While uploading my app into GAE, I find the example entries inside
my online GAE app. Why is that and how to prevent it?

Thanks.


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

2011-02-03 Thread ron_m
Sorry, I didn't explain well enough.

The clean_session() function is something I wrote to reset all session 
variables in the case the user is a different person logging in from the 
same machine. So it contains lines like:

session.var1 = None
session.dict1 = {}

etc.

The nutshell is an expression of brevity so the following couple of 
sentences explaining what the code does is what I meant.

What you could do is try this out without Janrain to see how it works. I had 
the problem were several users share the same Windows workstation and the IT 
department set the workstation up with a common user id for all users. So if 
a more privileged user logged out and a less privileged one logged in the 
session file was reused and as far as teh web2py app was concerned it was 
still the same user. Browser cookies are used to establish the session id so 
if you stay on the client PC as the same user the same cookie is used the 
next time anyone logs in form that workstation. That is the way it works 
with web browsers.

If you can login on the client workstation with different ids then that 
would help.

I offered the above concept to show you how I got around this with  multiple 
users sharing the same login on the workstation. However I do not use 
Janrain so there are very likely other issues in there.

Ron


[web2py] Simple question on rocket server - how to disable httpserver.log

2011-02-03 Thread Bruno Rocha
Can I disable httpserver.log when running in development mode?

I tried to change main.appfactory, but I messed it up, I also tried
options.py and does not works.

Can it be done?

Thanks


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


[web2py] plugin_wiki routes.py

2011-02-03 Thread Plumo
The default URL's when using plugin_wiki are ugly:

/welcome/plugin_wiki/page/about

Does anyone have a good routes.py for this?


Re: [web2py] localize messges in gluon/tools.py

2011-02-03 Thread Jonathan Lundell
On Feb 3, 2011, at 3:43 PM, kawate wrote:
> 
> The messages initialized in this module is not passed to T.
> Thus such as the message  'Registration needs verification' can not be
> translated.
> Please visit and register and login before mail address verification
> at 'https://masel-style.appspot.com/questions/client/person', where
> every thing is in Japanese but easy to understand the form( i hope)
> Please advise smart solutions.
> Thank you in advance

Massimo & I have been discussing a solution to this problem that would also 
solve a set of other difficulties in gluon. I think we've reached a tentative 
resolution. However, Massimo will be releasing a new stable version shortly, 
and we don't want to make the changes until that's out.

So: not yet, but soon.

[web2py] Re: pending issues?

2011-02-03 Thread Anthony
The Resources > Documentation menu in the Welcome app is missing a link for 
ch. 13 in the book. To add it, you can insert the following line between 
lines 99 and 100 of /welcome/models/menu.py:
 
(T('Components and Plugins'), False, 
'http://www.web2py.com/book/default/chapter/13'),
 
Anthony
 


[web2py] localize messges in gluon/tools.py

2011-02-03 Thread kawate
The messages initialized in this module is not passed to T.
Thus such as the message  'Registration needs verification' can not be
translated.
Please visit and register and login before mail address verification
at 'https://masel-style.appspot.com/questions/client/person', where
every thing is in Japanese but easy to understand the form( i hope)
Please advise smart solutions.
Thank you in advance


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

2011-02-03 Thread devGS
Thanks a lot for your response, I tried to follow it but got a "Not
defined" error for the clean_session() function you'd mentioned. I
tried to force "session.clear" at the begging of modules/menu.py, but
the after logging out from my app, Janrain's plugin still recognized
me with "Welcome back" and "it's not me" screen. Cleaning local cache
and cookies did help, but this cleans Janrain's (local) cache too, so
I don't know how to proceed from here. In addition, you mentioned a
"nutshell" - what is it?
I would like to few words about "It is not a web2py deficiency." -
web2py is great, because it is done right. It is designed and written
the right way, the adoption to web2py framework is excellent. The
above addressees to new users.
Thanks.

On Feb 2, 6:58 pm, ron_m  wrote:
> 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.


[web2py] Re: Capturing history of values in a field

2011-02-03 Thread Philip
Thanks - I haven't used _select - I'm checking into it now.

Thanks,
Philip

On Feb 3, 2:54 pm, DenesL  wrote:
> This might be doable by using _select (note the underscore) for the
> inner selection.
> Can you post the SQL command that you wish to accomplish?.
>
> On Feb 3, 2:14 pm, Philip  wrote:
>
>
>
>
>
>
>
> > Here's an example of what I am trying to do - suppose I have an app
> > that tracks a sales pipeline in which each opportunity moves through a
> > series of stages (ending with either a closed sale or a lost sale).
> > In most daily usage, all I need to know is the current status.  The
> > challenge is that I also want to be able to look back and see how each
> > opportunity progressed (how far and how fast did it go before it
> > resolved as either closed or lost).
>
> > The approach I tried is to have a separate 1-many table with the
> > related_opportunity_id, the stage, and the date moved.  That way, each
> > time an opportunity moved to the next stage, a record would be
> > created.  This is the approach I tried, but I cannot find a way to
> > select only the most recent entry for each opportunity to show in
> > reports or edit forms.
> >  I once wrote a similar application in MS Access and used this
> > method;  I created a query to show me only the most recent stage for
> > each opportunity, and joined that query (rather than the whole table
> > of stage records) back to the opportunities table.  As I understand
> > it, based on a thread from last April on this list, web2py does not
> > have a similar mechanism to join the result of a db().select() back to
> > another table in a subsequent select.  Am I correct in that?  If so,
> > is there a better way to do this in web2py?
>
> > any ideas on either making this approach work in web2py or a totally
> > different approach would be much appreciated.
>
> > Thanks,
> > Philip


[web2py] Re: Error acessing Database Administration

2011-02-03 Thread Mrekko
First of all, thank you for your quick response. I already figure it
out. That database was generated by the export to web2py tool from the
online database design. I made a new one "by my hand" without the
"online tool" following your tip and it worked! Thanks again and
congratulations for your work!

On Feb 2, 8:31 pm, Massimo Di Pierro 
wrote:
> 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", 

Re: [web2py] http and https

2011-02-03 Thread Jonathan Lundell
On Feb 3, 2011, at 2:43 PM, Vasile Ermicioi wrote:
> there are 2 ports, so I think he must run 2 instances, 
>  he can use router if he uses a proxy like nginx which will pass all requests 
> to the web2py 
> 

It should work for Apache, too, as long as Apache is configured to go to web2py 
for both domains/ports.

Speaking of which, there's no real need for separate subdomains, I don't think. 
some.domain.com should be able to serve both http and https.

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

2011-02-03 Thread Jonathan Lundell
On Feb 3, 2011, at 3:03 PM, Ken wrote:
> 
> You are right. Having (re)read the documentation for re, I find that
> it is working as advertised. My original regex was wrong. However, I
> would argue that if the match found by regex.match() is different from
> the input value, IS_MATCH should return an error. That is, in the
> IS_MATCH.__call__ definition, "if match:" should be "if match and
> (value == match.group():". That change would raise an error that would
> force a user like me to correct a regex that was matching in an
> unexpected way. I would never want IS_MATCH to silently change data
> between a form and insertion into a database.

IS_MATCH is already implicitly anchored at the beginning of the field, since it 
uses re.match. I think it'd make sense to implicitly anchor at the end as well. 

We could change this:

self.regex = re.compile(expression)

to this:

self.regex = re.compile('(%s)$' % expression)


> 
> Ken
> 
> On Feb 2, 9:13 pm, Massimo Di Pierro 
> wrote:
>> 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: GAE Query

2011-02-03 Thread howesc
this depends on many factors including:
 * DNS config for the domain and sub-domains
 * app.yaml
 * routes.py

if you have the GAE app on 1 subdomain, and other web services on another 
subdomain that is fine.  if all traffic is going to the same sub-domain 
which is mapped to GAE, GAE will service all those requests.  whether or not 
web2py services a GAE request depends on app.yaml (i believe the default 
app.yaml tells GAE to serve the static files up directly without invoking 
web2py for example).

hope that helps some.

cfh


[web2py] Re: Capturing history of values in a field

2011-02-03 Thread howesc
while not answering your select question, check out crud.archive: 
http://web2py.com/book/default/chapter/07?search=archive

it's pretty slick and does the archiving for you automagically.  now your 
query is still a problem


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

2011-02-03 Thread Ken
You are right. Having (re)read the documentation for re, I find that
it is working as advertised. My original regex was wrong. However, I
would argue that if the match found by regex.match() is different from
the input value, IS_MATCH should return an error. That is, in the
IS_MATCH.__call__ definition, "if match:" should be "if match and
(value == match.group():". That change would raise an error that would
force a user like me to correct a regex that was matching in an
unexpected way. I would never want IS_MATCH to silently change data
between a form and insertion into a database.

Ken

On Feb 2, 9:13 pm, Massimo Di Pierro 
wrote:
> 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)
>
>


Re: [web2py] http and https

2011-02-03 Thread Vasile Ermicioi
there are 2 ports, so I think he must run 2 instances,
 he can use router if he uses a proxy like nginx which will pass all
requests to the web2py


Re: [web2py] http and https

2011-02-03 Thread Tom Atkins
No need to start to instances of web2py. If you use Jonathan's new routers
syntax available in trunk you can put something like this in routes.py:

routers = dict(
  BASE  = dict(
  domains = {
  'www.domain.com:80 '  : 'myappname',
  'secure.domain.com:443' : 'myappname',
  }
  ),
)

Have a look at the documentation in router.example.py.  It's very powerful
and much more straightforward than the old routes.

On 3 February 2011 21:28, Martin Weissenboeck  wrote:

> Hi,
>
> I want to use one server with two addresses, e.g.
> http://www.mydomain.org:80 and https://secure.mydomain.org:443
>
> What shall I do:
> - start two instances of web2py
> - or use URL-rewrite?
>
> Regards,
> Martin
>
>


[web2py] Redirect after GAE authorization.

2011-02-03 Thread walter
I'm using GAE. Is there a possibility to perform a redirect back to a
page where I have come to perform authentication?


[web2py] Re: username or email

2011-02-03 Thread mattynoce
hi marin. good thought -- i'll give that a try. thanks!

On Feb 3, 11:32 am, Marin Pranjic  wrote:
> not sure if something like that is implemented, but here's what you can do:
>
> before validating form:
> 1. check if email is given in post vars (instead of username)
> 2. if it is, make select query to db to find out username related to given
> email
> 3. change variable (if email is given in username field, insert username
> instead)
> 4. username will be sent to validation instead of email
>
> you'll be using username field for login, but you can set label to "username
> or email"
>
> not sure if this fits, but if it is ok, i can give you exact code (i use
> something very similar to this)
>
> On Thu, Feb 3, 2011 at 8:18 PM, mattynoce  wrote:
> > hi all. i know we can use username instead of email by simply adding
> > username=True to auth, but i wanted to know if there happened to be a
> > way to use either.
>
> > for example, i have parent and children users, and i want kids to use
> > username, since they might not have email addresses. but i want
> > parents to use username or email, whichever they can remember.
>
> > so i'd like a field that accepts EITHER username or email, and checks
> > to see if either would allow login. i will figure out how to do this
> > on my own, but i wanted to see if there were something secret in auth
> > to do it automatically.
>
> > thanks,
>
> > matt
>
>


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

2011-02-03 Thread Neveen Adel
Dear Brian,

  Thanks a lot for your help.

On Feb 3, 4:29 am, Brian M  wrote:
> 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
>     
> #seehttp://code.activestate.com/recipes/483742-easy-cross-platform-excel-...
>
>     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: Checking permissions on a group

2011-02-03 Thread Clayton
You all rock. Thanks for the fast response!

Clayton


Re: [web2py] powertable problem

2011-02-03 Thread Bruno Rocha
Do you have the latest version of the plugin?

Demo app and newest plugin version in: https://bitbucket.org/rochacbruno/
powertable/downloads



Hi,

I could not reproduce your model, but here it is my example app running.


db.define_table('category',
Field('name'),
)

db.define_table('product',
Field('category_id',db.category,
represent=lambda r:r.name,
requires=IS_IN_DB(db,db.category.id,'%(name)s')),
Field('name'),
Field('description'),
Field('price','double'),
Field('quantity','integer')
)



def index():
"""
Test powerTable
"""
table = plugins.powerTable
table.datasource = db.product

table.keycolumn = 'product.id'
table.showkeycolumn = False
table.extra = dict(
   details={'detailscallback':URL('*myfunction*.load')}
   )

table = table.create()

return locals()


def *myfunction*():
"""
return a custom object to be inserted in detail for table
"""
obj = DIV()
obj.append(H1('Title for my details'))
obj.append(SQLFORM(db.product))
obj.append(SQLTABLE(db(db.category).select()))
obj.append(A('powertable',_href='http://bitbucket.org/rochacbruno/
powertable'))

# return locals(), which has only one object 'obj'
return locals()


*Screenshots*:

Table: http://awesomescreenshot.com/05d6rcxbc

Expanded details: http://awesomescreenshot.com/0706rcv8b

AjaxCallback: http://awesomescreenshot.com/08a6rd793



Demo app and newest plugin version in: https://bitbucket.org/rochacbruno/
powertable/downloads

*Note*: powerTable plugin is an alpha version, too much work in progress, I
am working to fix many issues people reported, any suggestion or help are
apreciated.

Thanks

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


2011/2/3 ceriox 

> hi all,
> i'm testing powertable plugin but i can't make it work correctly (i
> don't have the "green plus" icon for expand the row of a table item)
> where is the problem?
>
> this is my code:
>
> def index():
>"""
>Test powerTable
>"""
>table = plugins.powerTable
>table.datasource = db.auth_user
>table.dtfeatures['sScrollY'] = '100%'
>table.dtfeatures['sPaginationType'] = 'full_numbers'
>table.headers = 'labels'
>table.keycolumn = 'auth_user.id'
>table.columns =
> ['auth_user.username','auth_user.first_name','auth_user.last_name']
>table.showkeycolumn = False
>table.uitheme = 'redmond'
>table.extra = dict(
>
> details={'detailscallback':URL('myfunction.load')}
>   )
>
>table = table.create()
>
>return locals()
>
> def myfunction():
>"""
>return a custom object to be inserted in detail for table
>"""
>obj = DIV()
>obj.append(H1('Title for my details'))
>obj.append(SQLFORM(db.auth_user))
>obj.append(SQLTABLE(db(db.auth_user).select()))
>
>return locals()


[web2py] http and https

2011-02-03 Thread Martin Weissenboeck
Hi,

I want to use one server with two addresses, e.g. http://www.mydomain.org:80and
https://secure.mydomain.org:443

What shall I do:
- start two instances of web2py
- or use URL-rewrite?

Regards,
Martin


Re: [web2py] powertable problem

2011-02-03 Thread Kenneth Lundström
Too me it sounds like you have a problem with getting the data that 
should be shown in details. If powertable never gets data that should be 
displayed it doen´t show the  "green plus".


Why are you calling URL('myfunction.load') and not URL('myfunction')?


Kenneth


hi all,
i'm testing powertable plugin but i can't make it work correctly (i
don't have the "green plus" icon for expand the row of a table item)
where is the problem?

this is my code:

def index():
 """
 Test powerTable
 """
 table = plugins.powerTable
 table.datasource = db.auth_user
 table.dtfeatures['sScrollY'] = '100%'
 table.dtfeatures['sPaginationType'] = 'full_numbers'
 table.headers = 'labels'
 table.keycolumn = 'auth_user.id'
 table.columns =
['auth_user.username','auth_user.first_name','auth_user.last_name']
 table.showkeycolumn = False
 table.uitheme = 'redmond'
 table.extra = dict(

details={'detailscallback':URL('myfunction.load')}
)

 table = table.create()

 return locals()

def myfunction():
 """
 return a custom object to be inserted in detail for table
 """
 obj = DIV()
 obj.append(H1('Title for my details'))
 obj.append(SQLFORM(db.auth_user))
 obj.append(SQLTABLE(db(db.auth_user).select()))

 return locals()




[web2py] powertable problem

2011-02-03 Thread ceriox
hi all,
i'm testing powertable plugin but i can't make it work correctly (i
don't have the "green plus" icon for expand the row of a table item)
where is the problem?

this is my code:

def index():
"""
Test powerTable
"""
table = plugins.powerTable
table.datasource = db.auth_user
table.dtfeatures['sScrollY'] = '100%'
table.dtfeatures['sPaginationType'] = 'full_numbers'
table.headers = 'labels'
table.keycolumn = 'auth_user.id'
table.columns =
['auth_user.username','auth_user.first_name','auth_user.last_name']
table.showkeycolumn = False
table.uitheme = 'redmond'
table.extra = dict(
 
details={'detailscallback':URL('myfunction.load')}
   )

table = table.create()

return locals()

def myfunction():
"""
return a custom object to be inserted in detail for table
"""
obj = DIV()
obj.append(H1('Title for my details'))
obj.append(SQLFORM(db.auth_user))
obj.append(SQLTABLE(db(db.auth_user).select()))

return locals()


Re: [web2py] Form to Email

2011-02-03 Thread Kenneth Lundström

I wouldn´t use those PHP scripts if you wan´t to use web2py.

You need to make a form with SQLFORM. I guess you wan´t to save the 
fields to a database and send them to you via email.


In the if form.accepts section you gather the data and create the mail 
you want to send.



Kenneth




I expect that I am going about this the wrong way but here it
goes..

I am currently designing a form for my web2py website. When the user
clicks submit I would like  my application to send me the form fields
via email.

My hosting provider will supply form mail.php files:
On Linux hosting accounts, this will re-install the "gdform.php",
"webformmailer.php", and "gdform.cgi" (this is in the "cgi" directory)
form-mailer scripts for your hosting account

Can I utilize these?





[web2py] GAE Query

2011-02-03 Thread bee
I am using GAE to run my website web2py application.

I have added the domain to my GAE site settings.
Does this affect the way i can access the files on my website? For
example I have a couple of image files @ root on my host, when I try
to explore to that location using a web browser I get an invalid
request.
I suppose my question is, if I have attached GAE to my domain does my
web2py application take over all requests?


[web2py] Form to Email

2011-02-03 Thread bee
I expect that I am going about this the wrong way but here it
goes..

I am currently designing a form for my web2py website. When the user
clicks submit I would like  my application to send me the form fields
via email.

My hosting provider will supply form mail.php files:
On Linux hosting accounts, this will re-install the "gdform.php",
"webformmailer.php", and "gdform.cgi" (this is in the "cgi" directory)
form-mailer scripts for your hosting account

Can I utilize these?



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

2011-02-03 Thread Stef Mientki
Thanks Tom,

your answer helped me a lot.

I come to the following conclusion:
- Relatively little information, which much GUI interactive changes can best be 
done in JS.
(btw I use PyJamas for that so I can program in pure Python)
- Much information, which heavily changes on the base of user interaction can 
best be done by web2py.
- The use of fancy JQuery widgets within web2py had not much meaning (because 
of the reload of the
whole page)
- JQuery widgets within web2py should be limited to simple effects (with 
already available data),
like flash objects, pull-down menus, calendars etc.

cheers,
Stef

On 03-02-2011 09:16, Tom Atkins wrote:
> This isn't really a direct answer to your question but it might help clarify 
> some things for you
> (it got me thinking anyway)... it's a quote from a user on another mailing 
> list:
>
> "There's been a big move toward Javascript-heavy web apps in the last couple 
> of years, and new
> tools & frameworks are springing up to ease JS development -- see 
> Backbone.js, Knockout.js, etc.
> The model here is typically to move almost the entire app to the front end. 
> After the initial page
> load, everything happens in a single page, with no page refresh. A 
> server-side backend is still
> (usually) a necessary component, but it's reduced to a dumb pipe to shuttle 
> data to/from the
> database via JSON.
>
> This approach makes it possible to create much richer apps with lower 
> latency, so it's a pretty
> clear win for user experience. I'm creating an app right now (in Flask) that 
> could benefit from
> such an approach.
> The problem is that you have to write most of your app in JS to do so. It 
> also appears to increase
> the complexity of development quite a bit (beyond just learning a new tool), 
> and tools in this
> space are fairly new and immature. But I think it's clear that this is where 
> web development is
> headed.
>
> Most server-side frameworks are still firmly rooted in the old way of doing 
> things. It's possible
> to pair them with a JS-centric front end, sure, but you give up most of their 
> power by doing so.
> Do you see frameworks changing in the next couple of years to accommodate 
> this approach? Are there
> big roadblocks to doing so?"
>
> (link for the source of this quote
> is 
> http://flask.pocoo.org/mailinglist/archive/2011/1/31/flask-and-javascript-centric-front-ends/)
>
> There are of course still huge uses for web2py and other server centric 
> frameworks (not least ease
> of development) - but if your app is (almost) one page you may find a 
> javascript option more
> suitable.  The CoffeScript site is a good example of a single (large) page 
> Javascript app (and if
> you know Python but not Javascript you may fall in love with CoffeScript):
>
> http://jashkenas.github.com 
>
> Have fun!
>
>
> On 3 February 2011 00:43, Stef Mientki  > wrote:
>
> 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 

[web2py] Re: Bug in def data(): return dict(form=crud())

2011-02-03 Thread Anthony
I think that bug has been fixed already in trunk: 
https://groups.google.com/d/topic/web2py/iquAOtqZPNM/discussion

On Thursday, February 3, 2011 3:16:22 PM UTC-5, Art Zemon wrote:

> Found a bug. I wrote:
>
> def data(): return dict(form=crud())
>
> The page .../default/data/select/orders creates a nice list of all records 
> in the orders table. The links in the ID column are wrong, though. They are 
> to URLs of this form:
>
> .../default/read/orders/3
>
> instead of
>
> .../default/data/read/orders/3
>
> I am running Version 1.91.6 (2011-01-03 17:55:14)
>
> -- Art Z.
>


[web2py] Bug in def data(): return dict(form=crud())

2011-02-03 Thread Art Zemon

Found a bug. I wrote:

   def data(): return dict(form=crud())

The page .../default/data/select/orders creates a nice list of all 
records in the orders table. The links in the ID column are wrong, 
though. They are to URLs of this form:


   .../default/read/orders/3

instead of

   .../default/data/read/orders/3

I am running Version 1.91.6 (2011-01-03 17:55:14)

-- Art Z.


[web2py] Re: rename / route app admin

2011-02-03 Thread Anthony
Looks like there are a couple occurrences of 'admin' in the top section of 
the appadmin.py controller file (i.e., in the controllers folder of your 
app) -- one for the redirection and one for the menu. Try changing those to 
the new admin app name.

On Thursday, February 3, 2011 2:54:33 PM UTC-5, LightOfMooN wrote:

> Yes, it's work. But appadmin database administraton redirects to admin/ 
> default/index and rises invalid request error. How to fix it? 
>
> On 3 фев, 01:28, Massimo Di Pierro  wrote: 
> > 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: Capturing history of values in a field

2011-02-03 Thread DenesL

This might be doable by using _select (note the underscore) for the
inner selection.
Can you post the SQL command that you wish to accomplish?.


On Feb 3, 2:14 pm, Philip  wrote:
> Here's an example of what I am trying to do - suppose I have an app
> that tracks a sales pipeline in which each opportunity moves through a
> series of stages (ending with either a closed sale or a lost sale).
> In most daily usage, all I need to know is the current status.  The
> challenge is that I also want to be able to look back and see how each
> opportunity progressed (how far and how fast did it go before it
> resolved as either closed or lost).
>
> The approach I tried is to have a separate 1-many table with the
> related_opportunity_id, the stage, and the date moved.  That way, each
> time an opportunity moved to the next stage, a record would be
> created.  This is the approach I tried, but I cannot find a way to
> select only the most recent entry for each opportunity to show in
> reports or edit forms.
>  I once wrote a similar application in MS Access and used this
> method;  I created a query to show me only the most recent stage for
> each opportunity, and joined that query (rather than the whole table
> of stage records) back to the opportunities table.  As I understand
> it, based on a thread from last April on this list, web2py does not
> have a similar mechanism to join the result of a db().select() back to
> another table in a subsequent select.  Am I correct in that?  If so,
> is there a better way to do this in web2py?
>
> any ideas on either making this approach work in web2py or a totally
> different approach would be much appreciated.
>
> Thanks,
> Philip


[web2py] Re: rename / route app admin

2011-02-03 Thread LightOfMooN
Yes, it's work. But appadmin database administraton redirects to admin/
default/index and rises invalid request error. How to fix it?

On 3 фев, 01:28, Massimo Di Pierro  wrote:
> 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


Re: [web2py] Search form in CRUD

2011-02-03 Thread Running Clam

Hi All,

Not sure if anyone else has worked through the CRUD URLs described in 
the book on p317, but the search URL described does not work: -


def client_search():
return dict(form=crud.search(db.client))

...works as expected, but using: -

def data():
return dict(form=crud())

...and visiting the URL indicated by the book: -

[app]/[controller]/data/search/client

...throws a 404.

I'm not sure if this is a bug, or if the book is incorrect?


--

Cheers,

Clam


[web2py] Re: background task error

2011-02-03 Thread pbreit
I tried both web2py.py files on a different Mac and get the same errors. How 
does python know where to find gluon? Is it a problem that I have python 
installed separately on my Mac?

Re: [web2py] username or email

2011-02-03 Thread Marin Pranjic
not sure if something like that is implemented, but here's what you can do:

before validating form:
1. check if email is given in post vars (instead of username)
2. if it is, make select query to db to find out username related to given
email
3. change variable (if email is given in username field, insert username
instead)
4. username will be sent to validation instead of email

you'll be using username field for login, but you can set label to "username
or email"


not sure if this fits, but if it is ok, i can give you exact code (i use
something very similar to this)

On Thu, Feb 3, 2011 at 8:18 PM, mattynoce  wrote:

> hi all. i know we can use username instead of email by simply adding
> username=True to auth, but i wanted to know if there happened to be a
> way to use either.
>
> for example, i have parent and children users, and i want kids to use
> username, since they might not have email addresses. but i want
> parents to use username or email, whichever they can remember.
>
> so i'd like a field that accepts EITHER username or email, and checks
> to see if either would allow login. i will figure out how to do this
> on my own, but i wanted to see if there were something secret in auth
> to do it automatically.
>
> thanks,
>
> matt


[web2py] username or email

2011-02-03 Thread mattynoce
hi all. i know we can use username instead of email by simply adding
username=True to auth, but i wanted to know if there happened to be a
way to use either.

for example, i have parent and children users, and i want kids to use
username, since they might not have email addresses. but i want
parents to use username or email, whichever they can remember.

so i'd like a field that accepts EITHER username or email, and checks
to see if either would allow login. i will figure out how to do this
on my own, but i wanted to see if there were something secret in auth
to do it automatically.

thanks,

matt


[web2py] Capturing history of values in a field

2011-02-03 Thread Philip
Here's an example of what I am trying to do - suppose I have an app
that tracks a sales pipeline in which each opportunity moves through a
series of stages (ending with either a closed sale or a lost sale).
In most daily usage, all I need to know is the current status.  The
challenge is that I also want to be able to look back and see how each
opportunity progressed (how far and how fast did it go before it
resolved as either closed or lost).

The approach I tried is to have a separate 1-many table with the
related_opportunity_id, the stage, and the date moved.  That way, each
time an opportunity moved to the next stage, a record would be
created.  This is the approach I tried, but I cannot find a way to
select only the most recent entry for each opportunity to show in
reports or edit forms.
 I once wrote a similar application in MS Access and used this
method;  I created a query to show me only the most recent stage for
each opportunity, and joined that query (rather than the whole table
of stage records) back to the opportunities table.  As I understand
it, based on a thread from last April on this list, web2py does not
have a similar mechanism to join the result of a db().select() back to
another table in a subsequent select.  Am I correct in that?  If so,
is there a better way to do this in web2py?

any ideas on either making this approach work in web2py or a totally
different approach would be much appreciated.

Thanks,
Philip


Re: [web2py] Checking permissions on a group

2011-02-03 Thread Kenneth Lundström

Sounds like a web2py-way soolution, simple and elegant :=)


Kenneth


On Feb 3, 2011, at 6:14 AM, Franzé Jr wrote:

On Thu, Feb 3, 2011 at 11:08 AM, Clayton  wrote:
Hello,

I can't seem to find an easy way to check if a *group* has a
permission without making my own query on the auth_permission table
(and then I lose auth logging and the code is uglier).
auth.has_permission only works on users, not groups, as far as I can
tell. I need it for a control which is adding and removing permissions
from groups.

add_permission and del_permission use groups. Shouldn't there perhaps
be a function that checks whether a group has a given permission? Or
am I just missing something.

Cheers,

Clayton

I have the same doubt.

Proposal:

Change Auth.has_permission from this:

 def has_permission(
 self,
 name='any',
 table_name='',
 record_id=0,
 user_id=None,
 ):

to this:

 def has_permission(
 self,
 name='any',
 table_name='',
 record_id=0,
 user_id=None,
 group_id=None,
 ):

If the caller specifies a group_id, then we check permissions on that group 
instead of the groups the user belongs to. It is an error to call 
has_permission with both user_id and group_id.

The change would be simple.




[web2py] Re: Checking permissions on a group

2011-02-03 Thread Massimo Di Pierro
ok. will do this later today.

Massimo

On Feb 3, 11:10 am, Jonathan Lundell  wrote:
> On Feb 3, 2011, at 6:14 AM, Franzé Jr wrote:
>
>
>
>
>
>
>
>
>
> > On Thu, Feb 3, 2011 at 11:08 AM, Clayton  wrote:
> > Hello,
>
> > I can't seem to find an easy way to check if a *group* has a
> > permission without making my own query on the auth_permission table
> > (and then I lose auth logging and the code is uglier).
> > auth.has_permission only works on users, not groups, as far as I can
> > tell. I need it for a control which is adding and removing permissions
> > from groups.
>
> > add_permission and del_permission use groups. Shouldn't there perhaps
> > be a function that checks whether a group has a given permission? Or
> > am I just missing something.
>
> > Cheers,
>
> > Clayton
>
> > I have the same doubt.
>
> Proposal:
>
> Change Auth.has_permission from this:
>
>     def has_permission(
>         self,
>         name='any',
>         table_name='',
>         record_id=0,
>         user_id=None,
>         ):
>
> to this:
>
>     def has_permission(
>         self,
>         name='any',
>         table_name='',
>         record_id=0,
>         user_id=None,
>         group_id=None,
>         ):
>
> If the caller specifies a group_id, then we check permissions on that group 
> instead of the groups the user belongs to. It is an error to call 
> has_permission with both user_id and group_id.
>
> The change would be simple.


[web2py] Re: Unicity condition and database update

2011-02-03 Thread Massimo Di Pierro
The problem is that unicity must be computed but it needs triggename.
You are not passing triggername when you do the update_rector and
web2y does not do what to do. web2py wants you to be explicit:

row=db.alarms(2)
row.update_record(message='rz',triggerName=row.triggerName)


On Feb 3, 4:40 am, "Joseph.Piron"  wrote:
> Hi guys, I'm currently facing a strange thing :)
>
> I make use of datatables (jquery datatables.net) and jeditable to
> update values in my db. If the user clicks on a value, he changes it
> and sends it, thus, only the value of this field.
>
> On the server part, i then do a
> db.alarms[request.vars.id].update_record(field=value).
>
> Unfortunately, i have to have a unicity condition for this table, and
> thus, with the previous statement, i get an error.
>
> Here's some code to help understand..
>
> db.define_table('alarms',
>     Field('triggerName', type = 'string', label = T('Trigger Name'),
> required = True, notnull = True),
>     Field('triggerValue', type = 'integer', label = T('Trigger
> Value'), required = True, notnull = True),
>     Field('message', type = 'string', label = T('Message'), required =
> True, notnull = True),
>     Field('alarmScope', type = 'string', label = T('Alarm Scope'),
> required = True, notnull = True),
>     Field('unicity', type = 'string', compute = lambda x:
> x.triggerName + str(x.triggerValue), unique = True),
>     format = '%(triggerName)s - %(triggerValue)s',
>     migrate = settings.migrate)
>
> db.alarms.triggerValue.requires =
> IS_NOT_IN_DB(db(db.alarms.triggerName == request.vars.triggerName),
> 'alarms.triggerValue')
>
> If i want to update one of the fields, I have absolutely to also
> update (even if the don't change) triggerName and triggerValue (fields
> for unicity condition), and thus I need some test dependent on which
> field is updated..
>
> Here's an exemple:
>
> In [15]: db.alarms[2].update_record(message='rz')
> ---
> KeyError                                  Traceback (most recent call
> last)
>
> /Users/joseph/Documents/workspace/web2py/ in
> ()
>
> /Users/joseph/Documents/workspace/web2py/gluon/dal.pyc in (_,
> **a)
>    1245                 if field_type == 'id':
>    1246                     id = colset[field.name]
> -> 1247                     colset.update_record = lambda _ = (colset,
> table, id), **a: update_record(_, a)
>    1248                     colset.delete_record = lambda t = table, i
> = id: t._db(t._id==i).delete()
>    1249                     for (referee_table, referee_name) in \
>
> /Users/joseph/Documents/workspace/web2py/gluon/dal.pyc in
> update_record(pack, a)
>    4433     c = dict([(k,v) for (k,v) in b.items() \
>    4434                   if k in table.fields and not k=='id'])
> -> 4435     table._db(table._id==id).update(**c)
>    4436     for (k, v) in c.items():
>    4437         colset[k] = v
>
> /Users/joseph/Documents/workspace/web2py/gluon/dal.pyc in update(self,
> **update_fields)
>    4392     def update(self, **update_fields):
>    4393         tablename = self.db._adapter.get_table(self.query)
> -> 4394         fields =
> self.db[tablename]._listify(update_fields,update=True)
>    4395         self.delete_uploaded_files(update_fields)
>    4396         return
> self.db._adapter.update(tablename,self.query,fields)
>
> /Users/joseph/Documents/workspace/web2py/gluon/dal.pyc in
> _listify(self, fields, update)
>    3748                 new_fields.append((ofield,ofield.update))
>    3749             elif ofield.compute:
> -> 3750
> new_fields.append((ofield,ofield.compute(Row(fields
>    3751             elif not update and ofield.required:
>    3752                 raise SyntaxError,'Table: missing required
> field: %s' % name
>
> /Users/joseph/Documents/workspace/web2py/applications/hmiwebsite/
> models/model_alarms.py in (x)
>       7     Field('message', type = 'string', label = T('Message'),
> required = True, notnull = True),
>       8     Field('alarmScope', type = 'string', label = T('Alarm
> Scope'), required = True, notnull = True),
> > 9     Field('unicity', type = 'string', compute = lambda x:
> x.triggerName + str(x.triggerValue), unique = True),
>      10     format = '%(triggerName)s - %(triggerValue)s',
>      11     migrate = settings.migrate)
>
> /Users/joseph/Documents/workspace/web2py/gluon/dal.pyc in
> __getattr__(self, key)
>    3061
>    3062     def __getattr__(self, key):
> -> 3063         return dict.__getitem__(self,key)
>    3064
>    3065     def __setattr__(self, key, value):
>
> KeyError: 'triggerName'
>
> Could anyone help me out of this one ? :)


Re: [web2py] Checking permissions on a group

2011-02-03 Thread Jonathan Lundell
On Feb 3, 2011, at 6:14 AM, Franzé Jr wrote:
> On Thu, Feb 3, 2011 at 11:08 AM, Clayton  wrote:
> Hello,
> 
> I can't seem to find an easy way to check if a *group* has a
> permission without making my own query on the auth_permission table
> (and then I lose auth logging and the code is uglier).
> auth.has_permission only works on users, not groups, as far as I can
> tell. I need it for a control which is adding and removing permissions
> from groups.
> 
> add_permission and del_permission use groups. Shouldn't there perhaps
> be a function that checks whether a group has a given permission? Or
> am I just missing something.
> 
> Cheers,
> 
> Clayton
> 
> I have the same doubt.

Proposal:

Change Auth.has_permission from this:

def has_permission(
self,
name='any',
table_name='',
record_id=0,
user_id=None,
):

to this:

def has_permission(
self,
name='any',
table_name='',
record_id=0,
user_id=None,
group_id=None,
):

If the caller specifies a group_id, then we check permissions on that group 
instead of the groups the user belongs to. It is an error to call 
has_permission with both user_id and group_id.

The change would be simple.

[web2py] Re: pending issues?

2011-02-03 Thread dlypka
I think "self['_last_reference'] = tmp" is missing from insert() in
the dal.py:

Here is my suggested patch:

   def insert(self,table,fields):
dfields=dict((f.name,self.represent(v,f.type)) for f,v in
fields)
# table._db['_lastsql'] = self._insert(table,fields)
tmp = table._tableobj(**dfields)
tmp.put()
self['_last_reference'] = tmp # from June 27/2010 mod in the
trunk
rid = Reference(tmp.key().id())
(rid._table, rid._record) = (table, None)
return rid

On Feb 3, 11:03 am, VP  wrote:
> Another possible feature I hope to see in this or upcoming releases is
> an official support for the admin app to have different users
> (different users will  be able view and edit only their apps). In
> previous discussions, I think you implemented this in trunk.  I hope
> this feature becomes official.
>
> Thanks.


Re: [web2py] Checking permissions on a group

2011-02-03 Thread Franzé Jr
On Thu, Feb 3, 2011 at 11:08 AM, Clayton  wrote:

> Hello,
>
> I can't seem to find an easy way to check if a *group* has a
> permission without making my own query on the auth_permission table
> (and then I lose auth logging and the code is uglier).
> auth.has_permission only works on users, not groups, as far as I can
> tell. I need it for a control which is adding and removing permissions
> from groups.
>
> add_permission and del_permission use groups. Shouldn't there perhaps
> be a function that checks whether a group has a given permission? Or
> am I just missing something.
>
> Cheers,
>
> Clayton


I have the same doubt.



-- 
Franzé Jr


[web2py] Attention: Web application developers! Exciting event on Feb 26th in Pune (WebApps 2011)

2011-02-03 Thread arun

Hello,

SiliconIndia is organizing WebApps 2011 at Pune on Feb 26th,
2011.Drawing well-renowned thought-leaders, contributors,
influencer's, and organizations in the Web Development space, the
conference offers insight to develop industry-leading Web Development
projects. The conference brings together web developers, web designers
technology enthusiasts, innovators, vendors, and users to experience
the future of Web Applications.

Web-based applications are revolutionizing both the features that can
be delivered and the technologies for developing and deploying
applications. They also involve a diverse collection of issues and
technologies.We have lined up some of the best speakers and the
sessions & networking will be of the highest order.Get hands-on
technical training and gain new skills. WebApps 2011 guarantees
perfect networking and exciting learning success in workshops,
sessions, discussion panels & fascinating keynotes.

TOPICS:
5 New Skills that Every Web Designer Needs to Know
Progressive CSS3 Design
How to Build a HTML5 Website - Live Demo
Accessibility in Web Design
Icon Design

Who should attend: Web Application Developers, Application Managers,
Web Architects, Web and Graphic Designers, Web Development Managers,
Web Strategists, Web Technologists, Business Strategists, E-commerce
Managers, Product Managers, Technologists and Entrepreneurs and Others

DATE: Feb 26, 2011 (Saturday)
TIME: 8.00 AM to 5.30 PM
VENUE: Pune

We have limited Seats. Registration for this game-changing Symposium
is by invitation only. Attendance is limited to maintain an intimate
setting and foster dialogue among all participants.

To request an invitation, please visit:
http://www.siliconindia.com/events/siliconindia_events/index.php?eid=WebAppPune2011
and complete the  form .

And also you can NOMINATE your colleagues and friends who ever is
interested in attending this event.

We will review your submission and let you know. Once we qualify you,
there will be a registration fee of Rs 500 only. This is towards:
Access to Sessions, Tea/ Coffee & Refreshments and Lunch.

Here's your chance to meet tech leaders and get expert instruction and
hands-on tutorials to create the best web applications, tools, and
software.

Thanks ,




[web2py] Unicity condition and database update

2011-02-03 Thread Joseph.Piron
Hi guys, I'm currently facing a strange thing :)

I make use of datatables (jquery datatables.net) and jeditable to
update values in my db. If the user clicks on a value, he changes it
and sends it, thus, only the value of this field.

On the server part, i then do a
db.alarms[request.vars.id].update_record(field=value).

Unfortunately, i have to have a unicity condition for this table, and
thus, with the previous statement, i get an error.

Here's some code to help understand..

db.define_table('alarms',
Field('triggerName', type = 'string', label = T('Trigger Name'),
required = True, notnull = True),
Field('triggerValue', type = 'integer', label = T('Trigger
Value'), required = True, notnull = True),
Field('message', type = 'string', label = T('Message'), required =
True, notnull = True),
Field('alarmScope', type = 'string', label = T('Alarm Scope'),
required = True, notnull = True),
Field('unicity', type = 'string', compute = lambda x:
x.triggerName + str(x.triggerValue), unique = True),
format = '%(triggerName)s - %(triggerValue)s',
migrate = settings.migrate)


db.alarms.triggerValue.requires =
IS_NOT_IN_DB(db(db.alarms.triggerName == request.vars.triggerName),
'alarms.triggerValue')


If i want to update one of the fields, I have absolutely to also
update (even if the don't change) triggerName and triggerValue (fields
for unicity condition), and thus I need some test dependent on which
field is updated..

Here's an exemple:

In [15]: db.alarms[2].update_record(message='rz')
---
KeyError  Traceback (most recent call
last)

/Users/joseph/Documents/workspace/web2py/ in
()

/Users/joseph/Documents/workspace/web2py/gluon/dal.pyc in (_,
**a)
   1245 if field_type == 'id':
   1246 id = colset[field.name]
-> 1247 colset.update_record = lambda _ = (colset,
table, id), **a: update_record(_, a)
   1248 colset.delete_record = lambda t = table, i
= id: t._db(t._id==i).delete()
   1249 for (referee_table, referee_name) in \

/Users/joseph/Documents/workspace/web2py/gluon/dal.pyc in
update_record(pack, a)
   4433 c = dict([(k,v) for (k,v) in b.items() \
   4434   if k in table.fields and not k=='id'])
-> 4435 table._db(table._id==id).update(**c)
   4436 for (k, v) in c.items():
   4437 colset[k] = v

/Users/joseph/Documents/workspace/web2py/gluon/dal.pyc in update(self,
**update_fields)
   4392 def update(self, **update_fields):
   4393 tablename = self.db._adapter.get_table(self.query)
-> 4394 fields =
self.db[tablename]._listify(update_fields,update=True)
   4395 self.delete_uploaded_files(update_fields)
   4396 return
self.db._adapter.update(tablename,self.query,fields)

/Users/joseph/Documents/workspace/web2py/gluon/dal.pyc in
_listify(self, fields, update)
   3748 new_fields.append((ofield,ofield.update))
   3749 elif ofield.compute:
-> 3750
new_fields.append((ofield,ofield.compute(Row(fields
   3751 elif not update and ofield.required:
   3752 raise SyntaxError,'Table: missing required
field: %s' % name

/Users/joseph/Documents/workspace/web2py/applications/hmiwebsite/
models/model_alarms.py in (x)
  7 Field('message', type = 'string', label = T('Message'),
required = True, notnull = True),
  8 Field('alarmScope', type = 'string', label = T('Alarm
Scope'), required = True, notnull = True),
> 9 Field('unicity', type = 'string', compute = lambda x:
x.triggerName + str(x.triggerValue), unique = True),
 10 format = '%(triggerName)s - %(triggerValue)s',
 11 migrate = settings.migrate)

/Users/joseph/Documents/workspace/web2py/gluon/dal.pyc in
__getattr__(self, key)
   3061
   3062 def __getattr__(self, key):
-> 3063 return dict.__getitem__(self,key)
   3064
   3065 def __setattr__(self, key, value):

KeyError: 'triggerName'


Could anyone help me out of this one ? :)


[web2py] Re: Differing Form Presentation with SQLFORM readonly=True

2011-02-03 Thread Massimo Di Pierro
this is fixed in trunk already

On Feb 3, 7:01 am, Art Zemon  wrote:
> Hello,
>
> I have a field defined like this:
>
>     Field('state', 'string', requires=IS_IN_DB(db, 'state.id',
>     'state.abbreviation', zero=T('Choose one')))
>
> If I create a SQLFORM like this,
>
>     form = SQLFORM(db.address, address)
>
> I get what I expect: a drop-down menu displaying all of the
> state.abbreviation values. But if I generate the form like this,
>
>     form = SQLFORM(db.address, address, readonly=True)
>
> I see state.id and not state.abbreviation. Is this expected behavior or
> a bug? I am running Version 1.91.6 (2011-01-03 17:55:14)
>
>      -- Art Z.


[web2py] Re: Multiple Selection and Send Email

2011-02-03 Thread Ialejandro
I've written the validator like this:

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 I run it in the browser if I try to save the data I get a
ticket, the traceback says:

Traceback (most recent call last):
  File "gluon/restricted.py", line 188, in restricted
  File "C:/SERVER/web2py/applications/booksys/controllers/
bookings.py", line 28, in 
  File "gluon/globals.py", line 95, in 
  File "C:/SERVER/web2py/applications/booksys/controllers/
bookings.py", line 20, in create
  File "gluon/tools.py", line 2902, in create
  File "gluon/tools.py", line 2845, in update
  File "gluon/sqlhtml.py", line 1130, in accepts
  File "gluon/sqlhtml.py", line 36, in safe_int
TypeError: int() argument must be a string or a number, not 'list'


Re: [web2py] Please help me with info. about security testing

2011-02-03 Thread Richard Vézina
Back Track

On Thu, Feb 3, 2011 at 3:19 AM, AW  wrote:

> Can someone please recommend a hands-on book or some articles about
> security testing beside the "Web Security Testing Cookbook"
> (http://goo.gl/E1fbL )? I don't want to use Perl as recommended in
> that book.
>
> Thanks in advance.


[web2py] Re: pending issues?

2011-02-03 Thread VP
Another possible feature I hope to see in this or upcoming releases is
an official support for the admin app to have different users
(different users will  be able view and edit only their apps). In
previous discussions, I think you implemented this in trunk.  I hope
this feature becomes official.

Thanks.


Re: [web2py] Re: Creating subdomain on user registration

2011-02-03 Thread Jonathan Lundell
On Feb 3, 2011, at 12:15 AM, Prashanth wrote:
> 
> If _next is set with some value ( eg: _next='myapp/default/show_id' :
> show_id has @auth.login_required ) .. set_domain method will not get
> called and it just redirects to the value set in _next variable in
> which case I will not be able the redirect to username.mydomain.com.
> 
> 
> How can I work this out.. or is their any better approach to achieve
> this?

To tell the truth, I get a little confused by this logic myself. 

One possibility: suppose your ultimate destination after login is default/index 
in the user's domain. Go ahead and let login go there (I think it does by 
default), and inside that function do the domain redirect conditionally if 
http_host isn't already set to the user's domain.

Another possibility: create a decorator along the lines of auth.requires_login 
that does a conditional redirect to set the domain. Keep in mind that you can 
use multiple decorators, so you can first check for login, and then for the 
correct domain. Then any function that requires a logged-in user can also check 
the subdomain and redirect if necessary.

Re: [web2py] Re: order by surname, name

2011-02-03 Thread Marin Pranjic
+ you can use ~ to reverse order.

http://web2py.com/book/default/chapter/06#orderby,-groupby,-limitby,-distinct

On Thu, Feb 3, 2011 at 2:21 PM, dederocks  wrote:

> Hi Johann,
>
> Just use "|":
> orderby=db.table.name|db.table.surname
>
> On 3 fév, 13:56, Johann Spies  wrote:
> > According to the book the syntax to create an  'order by'  query is
> > db(query).select(ALL,orderby=field).
> >
> > What if I want to use more than one field in the 'order by' ?
> >
> > Regards
> > Johann
> >
> > --
> >  May grace and peace be yours in abundance through the full knowledge of
> God
> > and of Jesus our Lord!  His divine power has given us everything we need
> for
> > life and godliness through the full knowledge of the one who called us by
> > his own glory and excellence.
> > 2 Pet. 1:2b,3a
>


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

2011-02-03 Thread Richard Vézina
Gone!

Thanks you.

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
>


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

2011-02-03 Thread Plumo
that's fantastic you get early access to the SDK, and hopefully that lets 
you support new features faster.

[web2py] Re: Checking permissions on a group

2011-02-03 Thread Clayton
As far as I understand, you then assign permissions to groups with
add_permission.

>From the manual:

>auth.add_permission(group_id, 'name', 'object', record_id)
>gives permission "name" (user defined) on the object "object" (also user 
>defined) to members of the group group_id.

The problem is, there's no easy way to check if they've been added!

Clayton

On Feb 3, 9:13 am, Kenneth Lundström 
wrote:
> I think that the idea is that if you belong to a specific group you have
> some specific rights.
>
> I have not seen anything about giving permissions to groups.
>
> Kenneth
>
>
>
>
>
>
>
> > Hello,
>
> > I can't seem to find an easy way to check if a *group* has a
> > permission without making my own query on the auth_permission table
> > (and then I lose auth logging and the code is uglier).
> > auth.has_permission only works on users, not groups, as far as I can
> > tell. I need it for a control which is adding and removing permissions
> > from groups.
>
> > add_permission and del_permission use groups. Shouldn't there perhaps
> > be a function that checks whether a group has a given permission? Or
> > am I just missing something.
>
> > Cheers,
>
> > Clayton


Re: [web2py] Checking permissions on a group

2011-02-03 Thread Kenneth Lundström
I think that the idea is that if you belong to a specific group you have 
some specific rights.


I have not seen anything about giving permissions to groups.


Kenneth


Hello,

I can't seem to find an easy way to check if a *group* has a
permission without making my own query on the auth_permission table
(and then I lose auth logging and the code is uglier).
auth.has_permission only works on users, not groups, as far as I can
tell. I need it for a control which is adding and removing permissions
from groups.

add_permission and del_permission use groups. Shouldn't there perhaps
be a function that checks whether a group has a given permission? Or
am I just missing something.

Cheers,

Clayton




[web2py] Checking permissions on a group

2011-02-03 Thread Clayton
Hello,

I can't seem to find an easy way to check if a *group* has a
permission without making my own query on the auth_permission table
(and then I lose auth logging and the code is uglier).
auth.has_permission only works on users, not groups, as far as I can
tell. I need it for a control which is adding and removing permissions
from groups.

add_permission and del_permission use groups. Shouldn't there perhaps
be a function that checks whether a group has a given permission? Or
am I just missing something.

Cheers,

Clayton


[web2py] Re: order by surname, name

2011-02-03 Thread dederocks
Hi Johann,

Just use "|":
orderby=db.table.name|db.table.surname

On 3 fév, 13:56, Johann Spies  wrote:
> According to the book the syntax to create an  'order by'  query is
> db(query).select(ALL,orderby=field).
>
> What if I want to use more than one field in the 'order by' ?
>
> Regards
> Johann
>
> --
>  May grace and peace be yours in abundance through the full knowledge of God
> and of Jesus our Lord!  His divine power has given us everything we need for
> life and godliness through the full knowledge of the one who called us by
> his own glory and excellence.
>                                                     2 Pet. 1:2b,3a


[web2py] Differing Form Presentation with SQLFORM readonly=True

2011-02-03 Thread Art Zemon

Hello,

I have a field defined like this:

   Field('state', 'string', requires=IS_IN_DB(db, 'state.id',
   'state.abbreviation', zero=T('Choose one')))

If I create a SQLFORM like this,

   form = SQLFORM(db.address, address)

I get what I expect: a drop-down menu displaying all of the 
state.abbreviation values. But if I generate the form like this,


   form = SQLFORM(db.address, address, readonly=True)

I see state.id and not state.abbreviation. Is this expected behavior or 
a bug? I am running Version 1.91.6 (2011-01-03 17:55:14)


-- Art Z.


[web2py] order by surname, name

2011-02-03 Thread Johann Spies
According to the book the syntax to create an  'order by'  query is
db(query).select(ALL,orderby=field).

What if I want to use more than one field in the 'order by' ?

Regards
Johann

-- 
 May grace and peace be yours in abundance through the full knowledge of God
and of Jesus our Lord!  His divine power has given us everything we need for
life and godliness through the full knowledge of the one who called us by
his own glory and excellence.
2 Pet. 1:2b,3a


[web2py] Re: Pls help me with info. about security testing

2011-02-03 Thread AW
Thanks a lot. Yeah, I'll go with OWASP.




On Feb 3, 3:54 am, Vasile Ermicioi  wrote:
> A few links, just to give you a start point
>
> http://www.web2py.com/book/default/chapter/01#Security
>
> http://www.pythonsecurity.org/


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

2011-02-03 Thread Robert
Awesome news, I am really curious to see where this is heading!

By the way, 2 weeks ago I wrote a short post on our experiences on web2py 
and GAE. So I am extra thrilled, and will evangelize it even more. I really 
hope web2py gains more traction in the Netherlands, there are so many 
talented developers here, but the majority of them are lost to PHP.

http://www.unwind.nl/nl/blog/21/unwind_enters_the_cloud_with_google_app_engine_en_web2py/


Re: [web2py] Pls help me with info. about security testing

2011-02-03 Thread Vasile Ermicioi
A few links, just to give you a start point

http://www.web2py.com/book/default/chapter/01#Security

http://www.pythonsecurity.org/


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

2011-02-03 Thread Tom Atkins
Sorry - posted broken link to CoffeeScript site.  It should have been:

http://jashkenas.github.com/coffee-script/

On 3 February 2011 08:16, Tom Atkins  wrote:

>
> http://jashkenas.github.com
>
>
>


[web2py] Please help me with info. about security testing

2011-02-03 Thread AW
Can someone please recommend a hands-on book or some articles about
security testing beside the "Web Security Testing Cookbook"
(http://goo.gl/E1fbL )? I don't want to use Perl as recommended in
that book.

Thanks in advance.


[web2py] Pls help me with info. about security testing

2011-02-03 Thread AW
Can someone please recommend a hands-on book or some articles about
security testing beside the "Web Security Testing Cookbook" (http://
goo.gl/E1fbL ) ? I don't want to use Perl as recommended in that
book.

Thanks in advance.


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

2011-02-03 Thread Tom Atkins
This isn't really a direct answer to your question but it might help clarify
some things for you (it got me thinking anyway)... it's a quote from a user
on another mailing list:

"There's been a big move toward Javascript-heavy web apps in the last couple
of years, and new tools & frameworks are springing up to ease JS development
-- see Backbone.js, Knockout.js, etc.
The model here is typically to move almost the entire app to the front end.
After the initial page load, everything happens in a single page, with no
page refresh. A server-side backend is still (usually) a necessary
component, but it's reduced to a dumb pipe to shuttle data to/from the
database via JSON.

This approach makes it possible to create much richer apps with lower
latency, so it's a pretty clear win for user experience. I'm creating an app
right now (in Flask) that could benefit from such an approach.
The problem is that you have to write most of your app in JS to do so. It
also appears to increase the complexity of development quite a bit (beyond
just learning a new tool), and tools in this space are fairly new and
immature. But I think it's clear that this is where web development is
headed.

Most server-side frameworks are still firmly rooted in the old way of doing
things. It's possible to pair them with a JS-centric front end, sure, but
you give up most of their power by doing so. Do you see frameworks changing
in the next couple of years to accommodate this approach? Are there big
roadblocks to doing so?"

(link for the source of this quote is
http://flask.pocoo.org/mailinglist/archive/2011/1/31/flask-and-javascript-centric-front-ends/
)

There are of course still huge uses for web2py and other server centric
frameworks (not least ease of development) - but if your app is (almost) one
page you may find a javascript option more suitable.  The CoffeScript site
is a good example of a single (large) page Javascript app (and if you
know Python but not Javascript you may fall in love with CoffeScript):

http://jashkenas.github.com

Have fun!


On 3 February 2011 00:43, Stef Mientki  wrote:

> 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: Creating subdomain on user registration

2011-02-03 Thread Prashanth
Thanks Jonathan & Kenneth,

 have successfully implemented the subdomain module based on your
feedback ( using request.env.http_host ) and setting it globally
( 0.py ) using the following function:

def get_subdomain():
"""
Extracts subdomain from the url
"""
try:
subdomain = request.env.http_host.split('.')[:-2].pop()
if subdomain == 'www':
return ''
return subdomain
except IndexError:
return ''
DOMAIN = 'mydomain.com'
SUBDOMAIN = get_subdomain()

Now I have to redirect to the user1.mydomain.com after user1 has
logged in .. which works but only if _next variable is not set.

in db.py I have set auth.settings.login_next =
URL(r=request,c='default',f='set_domain') where the set_domain method
goes like this..

def set_domain():
if auth.user and request.get_vars._next:
redirect('http://'+auth.user.username+'.'+DOMAIN
+request.get_vars._next)
elif auth.user:
redirect('http://'+auth.user.username+'.'+DOMAIN)
else:
redirect(URL(f='index'))

This works only if the _next variable is not set

If _next is set with some value ( eg: _next='myapp/default/show_id' :
show_id has @auth.login_required ) .. set_domain method will not get
called and it just redirects to the value set in _next variable in
which case I will not be able the redirect to username.mydomain.com.


How can I work this out.. or is their any better approach to achieve
this?

.. Thanks in advance!


On Feb 2, 10:28 am, Jonathan Lundell  wrote:
> On Feb 1, 2011, at 9:23 PM, Kenneth Lundström wrote:
>
>
>
> > >> Also user1 must be able to point user1.mydomain.com to his own domain ( 
> > >> custom domain feature) for the application interface. How can I achieve 
> > >> this?
>
> >> I'm not sure what you mean by that.
>
> > I understod it like that a user should have the ability to in settings add 
> > a custom domain (myowndomain.net) to point to user1.mydomain.com. Of course 
> > the users takes care of DNS and things like that but how to get web2py to 
> > understand that users own domain even should be used.
>
> By the time web2py sees it, request.env.http_host will be either 
> myowndomain.net or user1.mydomain.net, depending on how the external 
> redirection goes. Assuming all this is going to the same application, the 
> easiest thing to do would be to look at http_host in a model file (before the 
> controller gets it) and maybe stash it somewhere else, like 
> request.env.user_domain or the like, for the controller to use.
>
> It could be tacked on to request.vars, too, but I don't think there's any 
> great point in doing that.
>
> This all depends on what you want to *do* with the domain name information, 
> of course.


[web2py] Pls help me with info. about security testing

2011-02-03 Thread AW
Can someone please recommend a hands-on book or some articles about
security testing beside the "Web Security Testing Cookbook" (http://
www.amazon.com/Web-Security-Testing-Cookbook-Systematic/dp/0596514832
) ? I don't want to use Perl as recommended in that book.

Thanks in advance.