[web2py] Postgresql query using trgm-indexing (fuzzy search option)

2011-12-08 Thread Johann Spies
How would one translate the following query into DAL - or should I use
executesql (I would like to use the query in SQLFORM.grid):

select B.title, A.title, similarity(A.title, B.title)
from
us2006_2010 B
left join akb_articles A on (A.title % B.title)
where
B.id in
(select A.id from us2006_2010 A
left join akb_articles B on A.ltitle = B.ltitle
where B.title is null)
order by similarity desc

The shortened result looks like this:

B.title1 |  A.title1 | 0.960526
B.title2 |  A.title2 | 0.905263
B.title1 | A.title3  | 0.511905
...

Johann Spies
-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)


[web2py] Progress update on Mongodb adapter now forked GIT repo

2011-12-08 Thread Mark Breedveld
The GIT repository below contains the Mongodb adapter.
https://github.com/MarkBreedveld/web2py

Currently working
- Select with
   - startswith, endswith,contains, like,   = = = !=  | IN NOT EQ
LIMIT ORDER
   - Snapshot switch
   - safe switch
- truncate
- count()
- drop()
- create_table()

TODO
- update
- capped collections
- embedded collections
- MOD, DIV, SUB, ADD, MUL, AS

TESTS
- with AUTH
- against official SQL LIKE, STARTSWITH, ENDSWITH operators
- BELONGS
- writing tests


[web2py] idea for embedded documents for document stores which is compatible with SQL

2011-12-08 Thread Mark Breedveld
Hi all,

I would like your opinion on the following matter.
There are currently two document store adapters in web2py.
CouchDB and Mongodb, both still highly experimental.

Now would it be nice if there was a way in which we could define
embedded documents in a way that is still compatible with SQL.
My first thoughts on this topic are that we could map them like this.

db.define_table(MAIN,FIELD(subdoc,reference SUBDOC,embed=True))
db.define_table(SUBDOC,FIELD(one,'string')

De SQL databases will solve this with a one-many table relation and
the document store will embed it.
But this definition leaves room for mistakes.
- The definition could embed the same subdoc twice, which will work in
the document store, but not in web2py.
- The statement would be implemented in alle SQL adapers
- A definition before the main document will lead to troube

My alternative thoughts on this are like this.
Fields=
[FIELD('fieldone','string',notnull=True),FIELD('fieldtwo','string',notnull=True)]
db.define_table(MAIN,FIELD(subdoc,define_table SUBDOC,Fields))
Again the field gets embedded on document stores and translated into
one-many relationship for SQL stores.

You're comments, ideas or critics please.

regards Mark Breedveld,


[web2py] How to modify response.write output

2011-12-08 Thread Saurabh Kumar
Hi,

I am returning  a dict (user_name=something) from my controller.

In my view, I am displaying it using {{=user_name}}

It generates an html code like...

span style=color: rgb(30, 30, 30)something/span

but I am looking for just

something

Can I modify the output of response.write to achieve this? Is there
some other way to achieve this?

Thanks

Saurabh


Re: [web2py] How to modify response.write output

2011-12-08 Thread Vinicius Assef
In your controller, just return something, without the dict().

[code]
return something
[/code]



On Thu, Dec 8, 2011 at 10:34 AM, Saurabh Kumar saurabh.ca...@gmail.com wrote:
 Hi,

 I am returning  a dict (user_name=something) from my controller.

 In my view, I am displaying it using {{=user_name}}

 It generates an html code like...

 span style=color: rgb(30, 30, 30)something/span

 but I am looking for just

 something

 Can I modify the output of response.write to achieve this? Is there
 some other way to achieve this?

 Thanks

 Saurabh


[web2py] Re: How to modify response.write output

2011-12-08 Thread Saurabh Kumar
Thanks for you reply.

But my controller is not that simple,

The return statement actually looks like

return
dict(lines=lines,channels=channels,staff=staff,current=int(request.args[0]),user_name=s.name)





On Dec 8, 5:49 pm, Vinicius Assef vinicius...@gmail.com wrote:
 In your controller, just return something, without the dict().

 [code]
 return something
 [/code]







 On Thu, Dec 8, 2011 at 10:34 AM, Saurabh Kumar saurabh.ca...@gmail.com 
 wrote:
  Hi,

  I am returning  a dict (user_name=something) from my controller.

  In my view, I am displaying it using {{=user_name}}

  It generates an html code like...

  span style=color: rgb(30, 30, 30)something/span

  but I am looking for just

  something

  Can I modify the output of response.write to achieve this? Is there
  some other way to achieve this?

  Thanks

  Saurabh


[web2py] Re: How to modify response.write output

2011-12-08 Thread lyn2py
Saurabh,

 {{=user_name}}

will only give:

 something

in view, without the additional code (span, style etc that you
mentioned).

If it doesn't work for you, please show us the actual code that is not
performing as expected.

On Dec 8, 9:08 pm, Saurabh Kumar saurabh.ca...@gmail.com wrote:
 Thanks for you reply.

 But my controller is not that simple,

 The return statement actually looks like

     return
 dict(lines=lines,channels=channels,staff=staff,current=int(request.args[0]) 
 ,user_name=s.name)

 On Dec 8, 5:49 pm, Vinicius Assef vinicius...@gmail.com wrote:







  In your controller, just return something, without the dict().

  [code]
  return something
  [/code]

  On Thu, Dec 8, 2011 at 10:34 AM, Saurabh Kumar saurabh.ca...@gmail.com 
  wrote:
   Hi,

   I am returning  a dict (user_name=something) from my controller.

   In my view, I am displaying it using {{=user_name}}

   It generates an html code like...

   span style=color: rgb(30, 30, 30)something/span

   but I am looking for just

   something

   Can I modify the output of response.write to achieve this? Is there
   some other way to achieve this?

   Thanks

   Saurabh


[web2py] Re: How to modify response.write output

2011-12-08 Thread Saurabh Kumar

My view file looks like :

{{extend 'layout.html'}}
{{=user_name}}
div id=chat
div id=chatlines style=margin: 5px; border: 1px solid
rgb(22,44,22)
{{for line in lines:}}
{{=line}}
{{pass}}
/div

div id=chatform_box
form id=chatform onKeyPress=enter(event);
fieldset
div
textarea cols=100 rows=3 name=statement 
id=statement  //
textarea
input type=submit value=chat /
/div
div
select name=channel id=channel
{{for channel in channels:}}
option 
value={{=channel.id}}{{if channel.id==current:}}
selected=selected{{pass}}{{=channel.name}}/option
{{pass}}
/select
/div
/fieldset
/form
/div
/div


My controller is like

def rooms():
   # Require the socket.IO file
response.files.append('http://cdn.socket.io/stable/
socket.io.js')#URL('static','js/socket.io.js'))
response.files.append(URL('static', 'js/jquery.blockUI.js'))
staff=auth.has_permission('delete', 'chat')

lines=[]
for line in rawlines:
# Treat emote lines and other lines different from each other
clazz=(line.deleted!=None and 'chat-deleted') or ''
if line.emote:
lines.append(DIV(line.statement,_id=line.id,_class=clazz))
else:
lines.append(DIV(line.speaker.name, B(),  %s %
(line.statement, ),_id=line.id, _class=clazz))
# This puts the lines in the direction that makes more sense to
read from top to bottom
lines.reverse()
# The list of channels available
channels=db().select(db.chat_channel.ALL)
# get logged in user name
s=db(db.auth_user.id==auth.user.id).select().first()
return
dict(lines=lines,channels=channels,staff=staff,current=int(request.args[0]),user_name=s.name)


The browser receives a html code like

div id=page !-- Here my central body --

 !-- content --
 div id=content style=width: 100% 

span style=color: rgb(30, 30, 30)abc/span
div id=chat
..
...




On Dec 8, 6:20 pm, lyn2py lyn...@gmail.com wrote:
 Saurabh,

  {{=user_name}}

 will only give:

  something

 in view, without the additional code (span, style etc that you
 mentioned).

 If it doesn't work for you, please show us the actual code that is not
 performing as expected.

 On Dec 8, 9:08 pm, Saurabh Kumar saurabh.ca...@gmail.com wrote:







  Thanks for you reply.

  But my controller is not that simple,

  The return statement actually looks like

      return
  dict(lines=lines,channels=channels,staff=staff,current=int(request.args[0]) 
  ,user_name=s.name)

  On Dec 8, 5:49 pm, Vinicius Assef vinicius...@gmail.com wrote:

   In your controller, just return something, without the dict().

   [code]
   return something
   [/code]

   On Thu, Dec 8, 2011 at 10:34 AM, Saurabh Kumar saurabh.ca...@gmail.com 
   wrote:
Hi,

I am returning  a dict (user_name=something) from my controller.

In my view, I am displaying it using {{=user_name}}

It generates an html code like...

span style=color: rgb(30, 30, 30)something/span

but I am looking for just

something

Can I modify the output of response.write to achieve this? Is there
some other way to achieve this?

Thanks

Saurabh


[web2py] Re: How to modify response.write output

2011-12-08 Thread Saurabh Kumar
Hi,

If you could give some idea about the definition of response.write
function (where it is defined), it will help.

On Dec 8, 6:28 pm, Saurabh Kumar saurabh.ca...@gmail.com wrote:
 My view file looks like :

 {{extend 'layout.html'}}
 {{=user_name}}
 div id=chat
         div id=chatlines style=margin: 5px; border: 1px solid
 rgb(22,44,22)
                 {{for line in lines:}}
                         {{=line}}
                 {{pass}}
         /div

         div id=chatform_box
                 form id=chatform onKeyPress=enter(event);
                         fieldset
                                 div
                                 textarea cols=100 rows=3 
 name=statement id=statement  //
 textarea
                                         input type=submit value=chat /
                                 /div
                                 div
                                         select name=channel id=channel
                                                 {{for channel in channels:}}
                                                 option 
 value={{=channel.id}}{{if channel.id==current:}}
 selected=selected{{pass}}{{=channel.name}}/option
                                                 {{pass}}
                                         /select
                                 /div
                         /fieldset
                 /form
         /div
 /div

 My controller is like

 def rooms():
        # Require the socket.IO file
     response.files.append('http://cdn.socket.io/stable/
 socket.io.js')#URL('static','js/socket.io.js'))
     response.files.append(URL('static', 'js/jquery.blockUI.js'))
     staff=auth.has_permission('delete', 'chat')

     lines=[]
     for line in rawlines:
         # Treat emote lines and other lines different from each other
         clazz=(line.deleted!=None and 'chat-deleted') or ''
         if line.emote:
             lines.append(DIV(line.statement,_id=line.id,_class=clazz))
         else:
             lines.append(DIV(line.speaker.name, B(),  %s %
 (line.statement, ),_id=line.id, _class=clazz))
     # This puts the lines in the direction that makes more sense to
 read from top to bottom
     lines.reverse()
     # The list of channels available
     channels=db().select(db.chat_channel.ALL)
     # get logged in user name
     s=db(db.auth_user.id==auth.user.id).select().first()
     return
 dict(lines=lines,channels=channels,staff=staff,current=int(request.args[0]),user_name=s.name)

 The browser receives a html code like

 div id=page !-- Here my central body --

  !-- content --
  div id=content style=width: 100% 

 span style=color: rgb(30, 30, 30)abc/span
 div id=chat
 ..
 ...

 On Dec 8, 6:20 pm, lyn2py lyn...@gmail.com wrote:







  Saurabh,

   {{=user_name}}

  will only give:

   something

  in view, without the additional code (span, style etc that you
  mentioned).

  If it doesn't work for you, please show us the actual code that is not
  performing as expected.

  On Dec 8, 9:08 pm, Saurabh Kumar saurabh.ca...@gmail.com wrote:

   Thanks for you reply.

   But my controller is not that simple,

   The return statement actually looks like

       return
   dict(lines=lines,channels=channels,staff=staff,current=int(request.args[0])
,user_name=s.name)

   On Dec 8, 5:49 pm, Vinicius Assef vinicius...@gmail.com wrote:

In your controller, just return something, without the dict().

[code]
return something
[/code]

On Thu, Dec 8, 2011 at 10:34 AM, Saurabh Kumar 
saurabh.ca...@gmail.com wrote:
 Hi,

 I am returning  a dict (user_name=something) from my controller.

 In my view, I am displaying it using {{=user_name}}

 It generates an html code like...

 span style=color: rgb(30, 30, 30)something/span

 but I am looking for just

 something

 Can I modify the output of response.write to achieve this? Is there
 some other way to achieve this?

 Thanks

 Saurabh


Re: [web2py] web2py, amazon ec2 and static pages outside of the application

2011-12-08 Thread José Luis Redrejo Rodríguez
2011/12/8 Marco Tulio Cicero de M. Porto mtcpo...@gmail.com:
 Hi there!

 ok, here's the deal:

 I installed web2py on ec2 following the instructions on the attached file.
 So far so good. I had it installed and working perfectly.

 Thing is that now, I want to use on that same server a geoprocessing
 application that will read from the databases I created with my web2py
 applications.
 This geoprocessing tool (i3geo), was made with PHP and works well when
 installed on another server.

 But on when I try to put them togheter, I won't be able to see the
 geoprocessing tool.

 At first, I thought I should put the application on /var/www (/var/www/i3geo
 for ex), but it wouldn't read the pages there... then I remembered that when
 I was installing web2py there, I placed it on /home/www-data/web2py and that
 all of it's applications are under that (
 /home/www-data/web2py/applications/app_name for ex) then I tried to create a
 directory with a hello world on it and place it there. Couldn't read it.

 Well, problem: I can make applications with web2py that'll run smoothly on
 ec2. But I'm not beeing able to publish anything else (not a single html) on
 that server.

 Any hints?




Yes, I'm running a web server with php apps, and had to add a web2py
application on it.

You can use this recipe: http://www.web2pyslices.com/slices/take_slice/56

It mostly works, but since versions =1.96.1 of web2py you also have
to tweak a little bit routes.py to make it work.

Regards
José L.




 Thanks in advanced,
 Marco Tulio

 --
 []'s
 Marco Tulio


[web2py] .contains() in query with SQLCustomType

2011-12-08 Thread Daniel Blomqvist

Hello, I tried making a query like this:

db(db.table.field.contains(1)).select()

where the field is a SQLCustomType with type 'list:integer' and native 
'int(11)'


The query does not work because of this function in gluon.dal.SQLCustomType:

def startswith(self, dummy=None):
return False

Why does this always return false?

I get this exception from gluon.dal.Expression in the contains function:

if not self.type in ('string', 'text') and not 
*self.type.startswith('list:')*:

raise SyntaxError, contains used with incompatible field type

Am i missing something? Is this not supposed to be allowed?


[web2py] Re: Postgresql query using trgm-indexing (fuzzy search option)

2011-12-08 Thread Massimo Di Pierro
What's similarity? What database engine supports it?

On Dec 8, 4:02 am, Johann Spies johann.sp...@gmail.com wrote:
 How would one translate the following query into DAL - or should I use
 executesql (I would like to use the query in SQLFORM.grid):

 select B.title, A.title, similarity(A.title, B.title)
 from
 us2006_2010 B
 left join akb_articles A on (A.title % B.title)
 where
     B.id in
                 (select A.id from us2006_2010 A
                 left join akb_articles B on A.ltitle = B.ltitle
                 where B.title is null)
 order by similarity desc

 The shortened result looks like this:

 B.title1 |  A.title1 | 0.960526
 B.title2 |  A.title2 | 0.905263
 B.title1 | A.title3  | 0.511905
 ...

 Johann Spies
 --
 Because experiencing your loyal love is better than life itself,
 my lips will praise you.  (Psalm 63:3)


[web2py] Re: Progress update on Mongodb adapter now forked GIT repo

2011-12-08 Thread Massimo Di Pierro
I am happy to include this. Do I just need the adapter from your dal?

On Dec 8, 5:42 am, Mark Breedveld m.breedv...@solcon.nl wrote:
 The GIT repository below contains the Mongodb 
 adapter.https://github.com/MarkBreedveld/web2py

 Currently working
 - Select with
    - startswith, endswith,contains, like,   = = = !=  | IN NOT EQ
 LIMIT ORDER
    - Snapshot switch
    - safe switch
 - truncate
 - count()
 - drop()
 - create_table()

 TODO
 - update
 - capped collections
 - embedded collections
 - MOD, DIV, SUB, ADD, MUL, AS

 TESTS
 - with AUTH
 - against official SQL LIKE, STARTSWITH, ENDSWITH operators
 - BELONGS
 - writing tests


[web2py] Re: web2py, amazon ec2 and static pages outside of the application

2011-12-08 Thread Marco Tulio Cicero de M. Porto
well, about this: I created an application called maps and moved the
whole php application to
/home/www-data/web2py/applications/maps/static/i3geo so that, now instead
of http://servername.com/i3geo I have
http://servername.com/maps/static/i3geo wich ends up working since I can
see the static files and they seem to be running fine. On the other hand,
I'll have to configure that application (php one), in order to work with
the new path... If anyone thinks of another way of making this work, I

2011/12/8 Marco Tulio Cicero de M. Porto mtcpo...@gmail.com

 Hi there!

 ok, here's the deal:

 I installed web2py on ec2 following the instructions on the attached file.
 So far so good. I had it installed and working perfectly.

 Thing is that now, I want to use on that same server a geoprocessing
 application that will read from the databases I created with my web2py
 applications.
 This geoprocessing tool (i3geo), was made with PHP and works well when
 installed on another server.

 But on when I try to put them togheter, I won't be able to see the
 geoprocessing tool.

 At first, I thought I should put the application on /var/www
 (/var/www/i3geo for ex), but it wouldn't read the pages there... then I
 remembered that when I was installing web2py there, I placed it on
 /home/www-data/web2py and that all of it's applications are under that (
 /home/www-data/web2py/applications/app_name for ex) then I tried to create
 a directory with a hello world on it and place it there. Couldn't read it.

 Well, problem: I can make applications with web2py that'll run smoothly on
 ec2. But I'm not beeing able to publish anything else (not a single html)
 on that server.

 Any hints?

 Thanks in advanced,
 Marco Tulio

 --
 []'s
 Marco Tulio




-- 
[]'s
Marco Tulio


[web2py] Re: web2py, amazon ec2 and static pages outside of the application

2011-12-08 Thread Marco Tulio Cicero de M. Porto
I'd appreciate, (that's what I was going to say when the mail was sent by
itself... :P :)

Thanks in advanced,
Marco Tulio

2011/12/8 Marco Tulio Cicero de M. Porto mtcpo...@gmail.com

 well, about this: I created an application called maps and moved the
 whole php application to
 /home/www-data/web2py/applications/maps/static/i3geo so that, now instead
 of http://servername.com/i3geo I have
 http://servername.com/maps/static/i3geo wich ends up working since I can
 see the static files and they seem to be running fine. On the other hand,
 I'll have to configure that application (php one), in order to work with
 the new path... If anyone thinks of another way of making this work, I

 2011/12/8 Marco Tulio Cicero de M. Porto mtcpo...@gmail.com

 Hi there!

 ok, here's the deal:

 I installed web2py on ec2 following the instructions on the attached
 file.
 So far so good. I had it installed and working perfectly.

 Thing is that now, I want to use on that same server a geoprocessing
 application that will read from the databases I created with my web2py
 applications.
 This geoprocessing tool (i3geo), was made with PHP and works well when
 installed on another server.

 But on when I try to put them togheter, I won't be able to see the
 geoprocessing tool.

 At first, I thought I should put the application on /var/www
 (/var/www/i3geo for ex), but it wouldn't read the pages there... then I
 remembered that when I was installing web2py there, I placed it on
 /home/www-data/web2py and that all of it's applications are under that (
 /home/www-data/web2py/applications/app_name for ex) then I tried to create
 a directory with a hello world on it and place it there. Couldn't read it.

 Well, problem: I can make applications with web2py that'll run smoothly
 on ec2. But I'm not beeing able to publish anything else (not a single
 html) on that server.

 Any hints?

 Thanks in advanced,
 Marco Tulio

 --
 []'s
 Marco Tulio




 --
 []'s
 Marco Tulio




-- 
[]'s
Marco Tulio


[web2py] Re: How to modify response.write output

2011-12-08 Thread Massimo Di Pierro
I do not understand you question.

if

{{=user_name}}

outputs

span style=color: rgb(30, 30, 30)something/span

It is because user_name == 'span style=color: rgb(30, 30,
30)something/span'

Is that the case? Do you want to parse the data, remove the tag and
then print it?
It seems wrong to me to store HTML into user name. It could cause XSS.


On Dec 8, 6:34 am, Saurabh Kumar saurabh.ca...@gmail.com wrote:
 Hi,

 I am returning  a dict (user_name=something) from my controller.

 In my view, I am displaying it using {{=user_name}}

 It generates an html code like...

 span style=color: rgb(30, 30, 30)something/span

 but I am looking for just

 something

 Can I modify the output of response.write to achieve this? Is there
 some other way to achieve this?

 Thanks

 Saurabh


[web2py] Re: .contains() in query with SQLCustomType

2011-12-08 Thread Massimo Di Pierro
Good point. I have a possible fix to trunk, please check if it
resolves the problem.

On Dec 8, 8:11 am, Daniel Blomqvist dan...@emediate.se wrote:
 Hello, I tried making a query like this:

 db(db.table.field.contains(1)).select()

 where the field is a SQLCustomType with type 'list:integer' and native
 'int(11)'

 The query does not work because of this function in gluon.dal.SQLCustomType:

 def startswith(self, dummy=None):
          return False
 Why does this always return false?
 I get this exception from gluon.dal.Expression in the contains function:

 if not self.type in ('string', 'text') and not
 *self.type.startswith('list:')*:
              raise SyntaxError, contains used with incompatible field type

 Am i missing something? Is this not supposed to be allowed?


Re: [web2py] Re: Postgresql query using trgm-indexing (fuzzy search option)

2011-12-08 Thread Johann Spies
On 8 December 2011 16:23, Massimo Di Pierro massimo.dipie...@gmail.comwrote:

 What's similarity?


It is an indication of the probability of the match.


 What database engine supports it


Postgresql.

See
http://stackoverflow.com/questions/2254999/similarity-function-in-postgres-with-pg-trgm

There is also http://www.sai.msu.su/~megera/postgres/gist/  but I am unable
to connect to that site at the moment.

From the pg_trgm manual: The pg_trgm module provides functions and
operators for determining the similarity of text based on trigram matching,
as
well as index operator classes that support fast searching for similar
strings.

I only started using it today and I am excited about it.

Regards
Johann
-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)


[web2py] Re: How to modify response.write output

2011-12-08 Thread lyn2py
That's weird. I tried your code but I am unable to reproduce the html
you got span style

If user_name is what you need:

#view
{{if auth.is_logged_in:}}
{{=session.auth.user.name}}
{{pass}}



On Dec 8, 9:28 pm, Saurabh Kumar saurabh.ca...@gmail.com wrote:
 My view file looks like :

 {{extend 'layout.html'}}
 {{=user_name}}
 div id=chat
         div id=chatlines style=margin: 5px; border: 1px solid
 rgb(22,44,22)
                 {{for line in lines:}}
                         {{=line}}
                 {{pass}}
         /div

         div id=chatform_box
                 form id=chatform onKeyPress=enter(event);
                         fieldset
                                 div
                                 textarea cols=100 rows=3 
 name=statement id=statement  //
 textarea
                                         input type=submit value=chat /
                                 /div
                                 div
                                         select name=channel id=channel
                                                 {{for channel in channels:}}
                                                 option 
 value={{=channel.id}}{{if channel.id==current:}}
 selected=selected{{pass}}{{=channel.name}}/option
                                                 {{pass}}
                                         /select
                                 /div
                         /fieldset
                 /form
         /div
 /div

 My controller is like

 def rooms():
        # Require the socket.IO file
     response.files.append('http://cdn.socket.io/stable/
 socket.io.js')#URL('static','js/socket.io.js'))
     response.files.append(URL('static', 'js/jquery.blockUI.js'))
     staff=auth.has_permission('delete', 'chat')

     lines=[]
     for line in rawlines:
         # Treat emote lines and other lines different from each other
         clazz=(line.deleted!=None and 'chat-deleted') or ''
         if line.emote:
             lines.append(DIV(line.statement,_id=line.id,_class=clazz))
         else:
             lines.append(DIV(line.speaker.name, B(),  %s %
 (line.statement, ),_id=line.id, _class=clazz))
     # This puts the lines in the direction that makes more sense to
 read from top to bottom
     lines.reverse()
     # The list of channels available
     channels=db().select(db.chat_channel.ALL)
     # get logged in user name
     s=db(db.auth_user.id==auth.user.id).select().first()
     return
 dict(lines=lines,channels=channels,staff=staff,current=int(request.args[0]) 
 ,user_name=s.name)

 The browser receives a html code like

 div id=page !-- Here my central body --

  !-- content --
  div id=content style=width: 100% 

 span style=color: rgb(30, 30, 30)abc/span
 div id=chat
 ..
 ...

 On Dec 8, 6:20 pm, lyn2py lyn...@gmail.com wrote:







  Saurabh,

   {{=user_name}}

  will only give:

   something

  in view, without the additional code (span, style etc that you
  mentioned).

  If it doesn't work for you, please show us the actual code that is not
  performing as expected.

  On Dec 8, 9:08 pm, Saurabh Kumar saurabh.ca...@gmail.com wrote:

   Thanks for you reply.

   But my controller is not that simple,

   The return statement actually looks like

       return
   dict(lines=lines,channels=channels,staff=staff,current=int(request.args[0])
,user_name=s.name)

   On Dec 8, 5:49 pm, Vinicius Assef vinicius...@gmail.com wrote:

In your controller, just return something, without the dict().

[code]
return something
[/code]

On Thu, Dec 8, 2011 at 10:34 AM, Saurabh Kumar 
saurabh.ca...@gmail.com wrote:
 Hi,

 I am returning  a dict (user_name=something) from my controller.

 In my view, I am displaying it using {{=user_name}}

 It generates an html code like...

 span style=color: rgb(30, 30, 30)something/span

 but I am looking for just

 something

 Can I modify the output of response.write to achieve this? Is there
 some other way to achieve this?

 Thanks

 Saurabh


Re: [web2py] Re: .contains() in query with SQLCustomType

2011-12-08 Thread Daniel Blomqvist

Thanks for your help Massimo

Although now I'm getting this error:

File/home/daniel/dev/tempw2p/web2py/gluon/dal.py,line5496,instartswith
return self.type.startswith(self,text)
TypeError:slice indices must be integersor None orhave an __index__ method


On 2011-12-08 15:36, Massimo Di Pierro wrote:

Good point. I have a possible fix to trunk, please check if it
resolves the problem.

On Dec 8, 8:11 am, Daniel Blomqvistdan...@emediate.se  wrote:
   

Hello, I tried making a query like this:

db(db.table.field.contains(1)).select()

where the field is a SQLCustomType with type 'list:integer' and native
'int(11)'

The query does not work because of this function in gluon.dal.SQLCustomType:

def startswith(self, dummy=None):
  return False
Why does this always return false?
I get this exception from gluon.dal.Expression in the contains function:

if not self.type in ('string', 'text') and not
*self.type.startswith('list:')*:
  raise SyntaxError, contains used with incompatible field type

Am i missing something? Is this not supposed to be allowed?
 





Re: [web2py] Two tables and one grid

2011-12-08 Thread Martin Weissenboeck
Thank to all for help.
I have found an idea in another thread and this is my solution:

def editcv():
   pid = db(db.person.name == 'Smith').select().first().id
   query = db.cv.id == pid
   db.cv.person.writable = False
   *db.cv.person.default = pid*
   return dict(grid=SQLFORM.grid(query,user_signature=False))

2011/12/7 Anthony abasta...@gmail.com

 You probably have to define a function to add records to 'cv' and modify
 the SQLFORM-grid to let the 'add' button refer to that function where the
 'person' field will be writable.

 I don't know hot to change the link in the 'add' button in the grid.
 Maybe someone else can help.


 You can edit the href of the 'add' button via:

 grid.element('.web2py_search_actions a')['_href'] = URL(...)

 Anthony




-- 
Mit freundlichen Grüßen / With kind regards
Martin Weissenböck
Gregor-Mendel-Str. 37, 1190 Wien
Austria / European Union
Tel  +43 1 31400 00
Fax  +43 1 31400 700


[web2py] Re: Massimo

2011-12-08 Thread Chris May
I second that! 

We are truly blessed to have so many great, patient and 
available contributors to the code and the community!


Anthony, do you have the book memorized yet? :D


[web2py] Re: Progress update on Mongodb adapter now forked GIT repo

2011-12-08 Thread Alan Etkin
Great! Thanks for sharing

On 8 dic, 08:42, Mark Breedveld m.breedv...@solcon.nl wrote:
 The GIT repository below contains the Mongodb 
 adapter.https://github.com/MarkBreedveld/web2py

 Currently working
 - Select with
    - startswith, endswith,contains, like,   = = = !=  | IN NOT EQ
 LIMIT ORDER
    - Snapshot switch
    - safe switch
 - truncate
 - count()
 - drop()
 - create_table()

 TODO
 - update
 - capped collections
 - embedded collections
 - MOD, DIV, SUB, ADD, MUL, AS

 TESTS
 - with AUTH
 - against official SQL LIKE, STARTSWITH, ENDSWITH operators
 - BELONGS
 - writing tests


[web2py] Re: How to modify response.write output

2011-12-08 Thread Anthony
On Thursday, December 8, 2011 7:34:52 AM UTC-5, Saurabh Kumar wrote:

 Hi,

 I am returning  a dict (user_name=something) from my controller.

 In my view, I am displaying it using {{=user_name}}

 It generates an html code like...

 span style=color: rgb(30, 30, 30)something/span

If user_name truly has the value something when returned in the dict by 
the controller, then {{=user_name}} will only write something to the 
response. The span tag must be generated by something else. Show your 
controller and view code, and maybe we can figure it out.

Anthony



[web2py] Missing information on chapter 05 in the book (view functions)

2011-12-08 Thread Tito Garrido
html
  body
{{include}} !-- must come before the two blocks below --

div class=sidebar
  {{if 'mysidebar' in :}}{{mysidebar()}}{{else:}}

my default sidebar
  {{pass}}
/div

  /body
/html


I guess something is missing on:

{{if 'mysidebar' in :}}


Regards,

Tito

-- 

Linux User #387870
.
 _/_õ|__|
..º[ .-.___.-._| . . . .
.__( o)__( o).:___


[web2py] Re: Missing information on chapter 05 in the book (view functions)

2011-12-08 Thread Massimo Di Pierro
{{if 'mysidebar' in globals():}}{{mysidebar()}}{{else:}}

thanks


On Dec 8, 10:06 am, Tito Garrido titogarr...@gmail.com wrote:
 html
   body
     {{include}} !-- must come before the two blocks below --

     div class=sidebar
       {{if 'mysidebar' in :}}{{mysidebar()}}{{else:}}

         my default sidebar
       {{pass}}
     /div

   /body
 /html

 I guess something is missing on:

 {{if 'mysidebar' in :}}

 Regards,

 Tito

 --

 Linux User #387870
 .
  _/_õ|__|
 ..º[ .-.___.-._| . . . .
 .__( o)__( o).:___


Re: [web2py] How to reuse view functions

2011-12-08 Thread Vinicius Assef
On Thu, Dec 8, 2011 at 3:14 PM, Tito Garrido titogarr...@gmail.com wrote:
 Folks,

 I need to change my sidebar sometimes so I've created a view
 leftsidebar.html with a function like this:

 {{def mysidebar():}}
 my new sidebar!!!
 {{return}}

 And then on may layout.html I've put:
 {{if 'mysidebar' in globals():}}{{mysidebar()}}{{else:}}
 ...
 {{pass}}

 And on a controller view I've tryed:
 {{include 'leftsidebar.html'}}
 {{extend 'layout.html'}}
 ...

 This doesn't work... but If I put the content of leftsidebar.html in the
 controller view it works...

What exactly doesn't work? Your function call, {{include}}?

Do you see any error message?


Re: [web2py] How to reuse view functions

2011-12-08 Thread Tito Garrido
{{include 'leftsidebar.html'}} doesn't work... it just appears my default
sidebar... if I put:
{{def mysidebar():}}
my new sidebar!!!
{{return}}

instead of the include it works...

PS:
{{def mysidebar():}}
my new sidebar!!!
{{return}}
is the content of leftsidebar.html

Regards,

Tito

On Thu, Dec 8, 2011 at 3:20 PM, Vinicius Assef vinicius...@gmail.comwrote:

 On Thu, Dec 8, 2011 at 3:14 PM, Tito Garrido titogarr...@gmail.com
 wrote:
  Folks,
 
  I need to change my sidebar sometimes so I've created a view
  leftsidebar.html with a function like this:
 
  {{def mysidebar():}}
  my new sidebar!!!
  {{return}}
 
  And then on may layout.html I've put:
  {{if 'mysidebar' in globals():}}{{mysidebar()}}{{else:}}
  ...
  {{pass}}
 
  And on a controller view I've tryed:
  {{include 'leftsidebar.html'}}
  {{extend 'layout.html'}}
  ...
 
  This doesn't work... but If I put the content of leftsidebar.html in the
  controller view it works...

 What exactly doesn't work? Your function call, {{include}}?

 Do you see any error message?




-- 

Linux User #387870
.
 _/_õ|__|
..º[ .-.___.-._| . . . .
.__( o)__( o).:___


[web2py] Re: How to modify response.write output

2011-12-08 Thread Saurabh Kumar
Hi,

Thanks all for the replies.

I finally got it working. The problem was that the user_name variable
itself  was 'span style=color: rgb(30, 30,
30)something/span'.

Really sorry for this silly mistake.

Special thanks to Massimo !! Regarding XSS concern, thanks but this is
not the user name of the database table. It is just a common variable.

Saurabh




On Dec 8, 9:12 pm, Anthony abasta...@gmail.com wrote:
 On Thursday, December 8, 2011 7:34:52 AM UTC-5, Saurabh Kumar wrote:

  Hi,

  I am returning  a dict (user_name=something) from my controller.

  In my view, I am displaying it using {{=user_name}}

  It generates an html code like...

  span style=color: rgb(30, 30, 30)something/span

 If user_name truly has the value something when returned in the dict by
 the controller, then {{=user_name}} will only write something to the
 response. The span tag must be generated by something else. Show your
 controller and view code, and maybe we can figure it out.

 Anthony


Re: [web2py] Easy handling of subforms

2011-12-08 Thread Richard Vézina
Bump...

Is there some development about that solution for sub-form?

Richard

On Tue, Nov 22, 2011 at 1:24 PM, Richard Vézina ml.richard.vez...@gmail.com
 wrote:

 I think we need Massimo opinion on this...

 Richard


 On Thu, Nov 17, 2011 at 12:16 PM, ~redShadow~ redsha...@hackzine.orgwrote:

 On Wed, 2011-11-16 at 15:36 -0500, Richard Vézina wrote:
  Man!
 
 
  I think you got a nice solution for this exact problem...
 
 
  I had tried with jQuery in the pass to manage this by duplicating the
  field that I want to bunch insert for... It was working but was
  breaking the workflow of form validation if I remember... Web2py has
  change a lot since then and I don't know if Massimo has not resolved
  this issue (confirmation needed!!).
 
 
  But I think what you suggest is pretty neath approach and easy to
  implement...
 
 
  Web2py guru??
 
 
  I suspect that you want to make insertion in multiple table...

 Yep, but I also want to have some control over this.. since whether to
 insert/update a record is determined by other form fields, the number of
 tables is variable and possibly there are clashing field names, ...

  You may be interrested by this :
 
 
 
 http://web2py.com/book/default/chapter/07?search=SQLFORM.factory#One-form-for-multiple-tables

 Tried that, but «This only works when the tables don't have field names
 in common.».


 Anyways, I managed to find a way that seems to work, in order to merge
 SQLFORMs for multiple tables, adding a namespace in front of field
 name, and then stripping it before doing inserts.

 See relevant parts from the controller source code here:
 http://pastebin.com/V1xwcjAg

 This of course could be extended to build a tree from ``form.vars``,
 instead of just a ``dict``-of-``dict``s (maybe by exploding
 ``my[var][name]``-style subscripted vars), etc..
 --
 Samuele ~redShadow~ Santi
 
 redshadow[at]hackzine.org - redshadowhack[at]gmail.com

  Blog: http://hackzine.org

  GPG Key signature:
   050D 3E9F 6E0B 44CE C008 D1FC 166C 3C7E EB26 4933
 
 /me recommends:
Squadra Informatica - http://www.squadrainformatica.com
 
  - Proud ThinkPad T-Series owner
  - Registered Linux-User: #440008
  * GENTOO User since 1199142000 (2008-01-01)
  * former DEBIAN SID user
 
  Software is like sex: it's better when it's free!
  -- Linus Torvalds





[web2py] Re: SQLFORM.factory int() argument must be a string or a number, not 'list' in many-to-many relationship

2011-12-08 Thread Cliff
Vincenzo,

Does it still blow up if you comment out these three lines?

 id =
db.users_categories.insert(**db.user_categories._filter_fields(perm_form.va
rs))
 id =
db.users_dictionaries.insert(**db.user_dictionaries._filter_fields(perm_for
m.vars))
 response.flash='Thanks for filling the form'

On Dec 7, 6:08 pm, Vincenzo Ampolo vincenzo.amp...@gmail.com wrote:
 Hi all

 I'm new to web2py. I set up a many to many relationship like these ones:

 db.define_table('users_dictionaries',

                  Field('user_id', db.auth_user, requires = 
 IS_IN_DB(db,'auth_user.id', db.auth_user._format)),

                  Field('dictionary_id', db.dictionary, 
 requires=IS_IN_DB(db,'dictionary.id',db.dictionary._format,multiple=True)),

                  )

 db.define_table('users_categories',

                  Field('user_id', db.auth_user, requires = 
 IS_IN_DB(db,'auth_user.id', db.auth_user._format)),

                  Field('category_id', db.category, 
 requires=IS_IN_DB(db,'category.id',db.category._format,multiple=True))

                  )

 in the controller i'm doing:

   perm_form=SQLFORM.factory(db.users_categories,db.users_dictionaries)
      if perm_form.process().accepted:
          form.vars.user=auth_user.id
          id = 
 db.users_categories.insert(**db.user_categories._filter_fields(perm_form.va 
 rs))
          id = 
 db.users_dictionaries.insert(**db.user_dictionaries._filter_fields(perm_for 
 m.vars))
          response.flash='Thanks for filling the form'

 It's displayed correctly: combo for the user, multiple select for
 user_categories and user_dictionaries but when i try to select a user,
 some or one category and some or one dictionary and i press submit i get
 this error:

 Traceback(most recent call last):
    File/var/www/argomenti.in/web2py/gluon/restricted.py,line194,inrestricted
      execccodeinenvironment
    
 File/var/www/argomenti.in/web2py/applications/webkeywords2/controllers/adm 
 in.py  
 http://localhost:8000/admin/default/edit/webkeywords2/controllers/adm...,line20,inmodule
    File/var/www/argomenti.in/web2py/gluon/globals.py,line149,inlambda
      self._caller=lambdaf:f()
    
 File/var/www/argomenti.in/web2py/applications/webkeywords2/controllers/adm 
 in.py  
 http://localhost:8000/admin/default/edit/webkeywords2/controllers/adm...,line9,inindex
      ifperm_form.process().accepted:
    File/var/www/argomenti.in/web2py/gluon/html.py,line1950,inprocess
      self.validate(**kwargs)
    File/var/www/argomenti.in/web2py/gluon/html.py,line1898,invalidate
      if self.accepts(**kwargs):
    File/var/www/argomenti.in/web2py/gluon/sqlhtml.py,line1219,inaccepts
      fields[fieldname] =safe_int(value)
    File/var/www/argomenti.in/web2py/gluon/sqlhtml.py,line48,insafe_int
      returnint(x)
 TypeError:int()argument must be a stringora number,not'list'

 How can i fix it? is that multiple=True of my tables that triggers the 
 problem?

 Thanks

 --
 Vincenzo Ampolohttp://vincenzo-ampolo.nethttp://goshawknest.wordpress.com


[web2py] Re: web2py, amazon ec2 and static pages outside of the application

2011-12-08 Thread Marco Tulio Cicero de M. Porto
I was wondering if there was any configuration on Apache that could help on
that, so that I could set the php application on www root and the web2py
applications on www-data ...

2011/12/8 Marco Tulio Cicero de M. Porto mtcpo...@gmail.com

 I'd appreciate, (that's what I was going to say when the mail was sent by
 itself... :P :)

 Thanks in advanced,
 Marco Tulio

 2011/12/8 Marco Tulio Cicero de M. Porto mtcpo...@gmail.com

 well, about this: I created an application called maps and moved the
 whole php application to
 /home/www-data/web2py/applications/maps/static/i3geo so that, now instead
 of http://servername.com/i3geo I have
 http://servername.com/maps/static/i3geo wich ends up working since I can
 see the static files and they seem to be running fine. On the other hand,
 I'll have to configure that application (php one), in order to work with
 the new path... If anyone thinks of another way of making this work, I

 2011/12/8 Marco Tulio Cicero de M. Porto mtcpo...@gmail.com

 Hi there!

 ok, here's the deal:

 I installed web2py on ec2 following the instructions on the attached
 file.
 So far so good. I had it installed and working perfectly.

 Thing is that now, I want to use on that same server a geoprocessing
 application that will read from the databases I created with my web2py
 applications.
 This geoprocessing tool (i3geo), was made with PHP and works well when
 installed on another server.

 But on when I try to put them togheter, I won't be able to see the
 geoprocessing tool.

 At first, I thought I should put the application on /var/www
 (/var/www/i3geo for ex), but it wouldn't read the pages there... then I
 remembered that when I was installing web2py there, I placed it on
 /home/www-data/web2py and that all of it's applications are under that (
 /home/www-data/web2py/applications/app_name for ex) then I tried to create
 a directory with a hello world on it and place it there. Couldn't read it.

 Well, problem: I can make applications with web2py that'll run smoothly
 on ec2. But I'm not beeing able to publish anything else (not a single
 html) on that server.

 Any hints?

 Thanks in advanced,
 Marco Tulio

 --
 []'s
 Marco Tulio




 --
 []'s
 Marco Tulio




 --
 []'s
 Marco Tulio




-- 
[]'s
Marco Tulio


[web2py] Factoid: How to reset id field in Postgres tables

2011-12-08 Thread Cliff
db.mytable.truncate() cleans all the data out of the table, but does
not reset the counter for the id field.  (See Ch 4 of the book.)

db.products.truncate('RESTART IDENTITY CASCADE') resets the counter
back to zero, so the first record gets an id of 1.

Resetting the counter is useful for automated testing.


[web2py] Re: How to deploy web2py on PythonAnywhere

2011-12-08 Thread Lazarof
I am trying to run web2py on pythonanywhere but using Dropbox.
Can someone help us with
http://www.pythonanywhere.com/forums/topic/9/

On Dec 6, 10:42 pm, Ovidio Marinho ovidio...@gmail.com wrote:
       I also tried to use Dropbox to have an automatic update, but it seems
 that sharing does not work with the dropbox

        Ovidio Marinho Falcao Neto
                 Web Developer
              ovidio...@gmail.com
           ovidiomari...@itjp.net.br
                  ITJP - itjp.net.br
                83   8826 9088 - Oi
                83   9334 0266 - Claro
                         Brasil

                         Apóio

 2011/12/6 Lazarof lazaro...@gmail.com

  Bruno thank muito!

  What about web2py - dropbox - pythonanywhere?
  ##
  import os
  import sys

  path = '/home/my_username/Dropbox/web2py'
  if path not in sys.path:
     sys.path.append(path)

  from wsgihandler import application
  ##

  I am getting
   Internal Server Error
   The server encountered an internal error or misconfiguration and was
  unable to complete your request.

  On Dec 5, 6:52 pm, Bruno Rocha rochacbr...@gmail.com wrote:
   How to deploy web2py on PythonAnywhere

  http://stackoverflow.com/a/8386751/559935

   --

   Bruno Rocha
   [http://rochacbruno.com.br]




[web2py] foreign key reference and not null mutually exclusive. by design, or a bug?

2011-12-08 Thread nick name
I want to have a non-null foreign key reference, e.g.

owner = db.define_table('owner'', Field('name'))
package = db.define_table('package', Field('owner_id', owner, 
notnull=True), Field('name'))

SQLite for example has no problem with this:

sqlite create table owner(id int primary key, name text);
sqlite create table package(id int primary key, owner_id references owner 
not null, name text);
sqlite insert into owner values(1, web2py);
sqlite insert into package values(1, 1, markmin);
sqlite insert into package values(2, null, hello);
Error: package.owner_id may not be NULL

However, web2py will not put a not null qualifier on the foreign key 
reference; there is a specific check to NOT add a not null if the field 
is an id field or it is a reference field. Why is that?

A bug in my app relating to this was just discovered by a user; I was 
relying on the database to signal an IntegrityError and fail to insert 
records that have a null reference, but they got in anyway.

validate_and_insert will actually catch this -- but, why doesn't web2py 
append the NOT NULL?



RE: [web2py] Re: Progress update on Mongodb adapter now forked GIT repo

2011-12-08 Thread Mark Breedveld
Yes, that's all

-Oorspronkelijk bericht-
Van: web2py@googlegroups.com [mailto:web2py@googlegroups.com] Namens Massimo
Di Pierro
Verzonden: donderdag 8 december 2011 16:25
Aan: web2py-users
Onderwerp: [web2py] Re: Progress update on Mongodb adapter now forked GIT
repo

I am happy to include this. Do I just need the adapter from your dal?

On Dec 8, 5:42 am, Mark Breedveld m.breedv...@solcon.nl wrote:
 The GIT repository below contains the Mongodb 
 adapter.https://github.com/MarkBreedveld/web2py

 Currently working
 - Select with
    - startswith, endswith,contains, like,   = = = !=  | IN NOT EQ 
 LIMIT ORDER
    - Snapshot switch
    - safe switch
 - truncate
 - count()
 - drop()
 - create_table()

 TODO
 - update
 - capped collections
 - embedded collections
 - MOD, DIV, SUB, ADD, MUL, AS

 TESTS
 - with AUTH
 - against official SQL LIKE, STARTSWITH, ENDSWITH operators
 - BELONGS
 - writing tests

-
Geen virus gevonden in dit bericht.
Gecontroleerd door AVG - www.avg.com
Versie: 2012.0.1873 / Virusdatabase: 2102/4667 - datum van uitgifte:
12/08/11



[web2py] Re: Factoid: How to reset id field in Postgres tables

2011-12-08 Thread nick name
Interesting. DAL has specific reset code for MS SQL and SQLite, but not for 
postgresql (or any of the other databases, it seems)


[web2py] Calirification on plugin_wiki license

2011-12-08 Thread simlan
Hi there,

i am wondering under which license the plugin_wiki is released. In the
web2py book (chapter 13) it is mentioned
that there should be license information under static/plugin_name/
license.html but there is no such file for plugin_wiki. I searched
this group and found a post that states: It is under triple license
(see link at bottom).

I am asking for that because I am interested in parts of the source
code and am interested including some of that code without using the
whole plugin.

Best Simon



http://groups.google.com/group/web2py/browse_thread/thread/db8295cdc48a74fa/fb37d69b9a67bb4e?lnk=gstq=license+plugin_wiki#fb37d69b9a67bb4e


[web2py] Re: Factoid: How to reset id field in Postgres tables

2011-12-08 Thread Alan Etkin
Does it work for sqlite3 or MySQL, etc?

On Dec 8, 5:27 pm, nick name i.like.privacy@gmail.com wrote:
 Interesting. DAL has specific reset code for MS SQL and SQLite, but not for
 postgresql (or any of the other databases, it seems)


[web2py] date(time) picker not working with multiple ajax loaded forms

2011-12-08 Thread selecta
If I load multiple forms as web2py components the date(time) picker only 
works in the first form. Can somebody verify that or is it just a bug in my 
code?


Re: [web2py] Re: Factoid: How to reset id field in Postgres tables

2011-12-08 Thread Richard Vézina
I think you will need to use raw sql for this...

http://web2py.com/book/default/chapter/06?search=raw+sql#Raw-SQL

At least it one way I see that it could work...

But I remember that I have read something about resetting sequence from
web2py...

Richard

On Thu, Dec 8, 2011 at 4:14 PM, Alan Etkin spame...@gmail.com wrote:

 Does it work for sqlite3 or MySQL, etc?

 On Dec 8, 5:27 pm, nick name i.like.privacy@gmail.com wrote:
  Interesting. DAL has specific reset code for MS SQL and SQLite, but not
 for
  postgresql (or any of the other databases, it seems)



[web2py] Re: web2py, amazon ec2 and static pages outside of the application

2011-12-08 Thread howesc
while i don't know the apache directive off the top of my head there most 
certianly is a way to direct requests based on subdomain and i think also 
based on path to different places on disk.  i'm 99% certain that some 
reading on apache conf will be worthwhile!

cfh


Re: [web2py] Re: SQLFORM.factory int() argument must be a string or a number, not 'list' in many-to-many relationship

2011-12-08 Thread Vincenzo Ampolo

On 12/08/2011 07:12 PM, Cliff wrote:

Vincenzo,

Does it still blow up if you comment out these three lines?

  id =
db.users_categories.insert(**db.user_categories._filter_fields(perm_form.va
rs))
  id =
db.users_dictionaries.insert(**db.user_dictionaries._filter_fields(perm_for
m.vars))
  response.flash='Thanks for filling the form'


Yeah. it's related to the multiple=True... i've the same problem in 
database administration if i try to add a single users_dictionary or 
users_categories entry.


I'm now trying to fix it using SQLFORM.factory with a custom 
configuration so i can have more control in storing the submit the right 
way, do you know any better way?


thanks

--
Vincenzo Ampolo
http://vincenzo-ampolo.net
http://goshawknest.wordpress.com



Re: [web2py] Re: Factoid: How to reset id field in Postgres tables

2011-12-08 Thread Richard Vézina
Here a post on stack overflow that could help :
http://stackoverflow.com/questions/244243/how-to-reset-postgres-primary-key-sequence-when-it-falls-out-of-sync

On Thu, Dec 8, 2011 at 4:55 PM, Richard Vézina
ml.richard.vez...@gmail.comwrote:

 I think you will need to use raw sql for this...

 http://web2py.com/book/default/chapter/06?search=raw+sql#Raw-SQL

 At least it one way I see that it could work...

 But I remember that I have read something about resetting sequence from
 web2py...

 Richard


 On Thu, Dec 8, 2011 at 4:14 PM, Alan Etkin spame...@gmail.com wrote:

 Does it work for sqlite3 or MySQL, etc?

 On Dec 8, 5:27 pm, nick name i.like.privacy@gmail.com wrote:
  Interesting. DAL has specific reset code for MS SQL and SQLite, but not
 for
  postgresql (or any of the other databases, it seems)





Re: [web2py] Re: Factoid: How to reset id field in Postgres tables

2011-12-08 Thread Richard Vézina
Also, if you use to create your table in postgres manually (not wrinting
models first in web2py and let web2py create you table for you) it maybe
possible that you have to define your sequence name since web2py don't
follow postgres standard name for sequence creation... So maybe your
sequence name are not defined and not the same as web2py meta data are...
So web2py send wrong order to postgres backend?!

Richard

On Thu, Dec 8, 2011 at 5:00 PM, Richard Vézina
ml.richard.vez...@gmail.comwrote:

 Here a post on stack overflow that could help :
 http://stackoverflow.com/questions/244243/how-to-reset-postgres-primary-key-sequence-when-it-falls-out-of-sync


 On Thu, Dec 8, 2011 at 4:55 PM, Richard Vézina 
 ml.richard.vez...@gmail.com wrote:

 I think you will need to use raw sql for this...

 http://web2py.com/book/default/chapter/06?search=raw+sql#Raw-SQL

 At least it one way I see that it could work...

 But I remember that I have read something about resetting sequence from
 web2py...

 Richard


 On Thu, Dec 8, 2011 at 4:14 PM, Alan Etkin spame...@gmail.com wrote:

 Does it work for sqlite3 or MySQL, etc?

 On Dec 8, 5:27 pm, nick name i.like.privacy@gmail.com wrote:
  Interesting. DAL has specific reset code for MS SQL and SQLite, but
 not for
  postgresql (or any of the other databases, it seems)






[web2py] Re: Factoid: How to reset id field in Postgres tables

2011-12-08 Thread Cliff
If it helps, any parameters you pass to truncate() get passed on to
the database driver.  What happens after that I do not know, except
for Postgres.

I researched the issue because I didn't want to drop and regen my
tables every time I run an acceptance test.

On Dec 8, 5:04 pm, Richard Vézina ml.richard.vez...@gmail.com wrote:
 Also, if you use to create your table in postgres manually (not wrinting
 models first in web2py and let web2py create you table for you) it maybe
 possible that you have to define your sequence name since web2py don't
 follow postgres standard name for sequence creation... So maybe your
 sequence name are not defined and not the same as web2py meta data are...
 So web2py send wrong order to postgres backend?!

 Richard

 On Thu, Dec 8, 2011 at 5:00 PM, Richard Vézina
 ml.richard.vez...@gmail.comwrote:







  Here a post on stack overflow that could help :
 http://stackoverflow.com/questions/244243/how-to-reset-postgres-prima...

  On Thu, Dec 8, 2011 at 4:55 PM, Richard Vézina 
  ml.richard.vez...@gmail.com wrote:

  I think you will need to use raw sql for this...

 http://web2py.com/book/default/chapter/06?search=raw+sql#Raw-SQL

  At least it one way I see that it could work...

  But I remember that I have read something about resetting sequence from
  web2py...

  Richard

  On Thu, Dec 8, 2011 at 4:14 PM, Alan Etkin spame...@gmail.com wrote:

  Does it work for sqlite3 or MySQL, etc?

  On Dec 8, 5:27 pm, nick name i.like.privacy@gmail.com wrote:
   Interesting. DAL has specific reset code for MS SQL and SQLite, but
  not for
   postgresql (or any of the other databases, it seems)


[web2py] read once definitions - development vs. production

2011-12-08 Thread Constantine Vasil
I used the PyDev+Eclipse+ GAE debugger extensively (after making it 
working) 
to see how web2py is working internally.

Bottom line web2py is excellent for rapid development - while it is still 
running,
any change in the model in 0.py (say) is available immediately after 
browser refresh
because 0.py is read every time on browser refresh. 

This is perfect for development but for production kills the speed. 
Actually after 0.py
is tweaked and reaches maturity I need to put it at read 'once mode'.

This is much more important with GAE because for GAE you update all your 
project
on the cloud, not just 0.py if changed, so this feature is useless for GAE 
in production 
environment and slows down the execution.

In 0.py I have GAE models which are already stable and I have to be able to 
put them 
in a read once place. The question is how they would be available globally 
too? 
In ideal scenario if I have a class:

class MyClass(db_google.Model)
 name = dg_google.string(...)
 def profile(self, id)
   some code

I would want to access the model like (the simplest possible way):

myclass = MYClass.profile(id)
name = myclass.name


Is this possible in web2py?

Regards,
--Constantine









[web2py] Re: vCard

2011-12-08 Thread GoldenTiger
I worked with microformats some time ago...and now i am about to back

addresses are rendered as a business card in a view

how are your data stored ?

you need your data in vcard file, web2py includes gluon/contrib/
feedparser.py  , I think feedparser.py makes all the job
you can choose any other python lib, like python-microformats

simplest way is a generic.vcf
to download the vcard file set content-type=text/x-vcard






On 7 dic, 09:45, annet annet.verm...@gmail.com wrote:
 I am working on sort of an address book application. The addresses are
 rendered as a business card in a view:

 div class=ez-mw mw radius_top style=margin-bottom: 12px;

   !-- Layout 1 --
   div class=ez-wr wr style=margin-bottom: 0px;

     {{if logo:}}
       div class=ez-box box style=padding-top: 24px;
         {{=IMG(_src=URL('static','init/images/logos/%s' %
 logo.link))}}
       /div !-- ez-box --
     {{pass}}

     {{if tagline:}}
       div class=ez-box box style=padding-top: 12px; overflow:
 hidden;
         h5{{=tagline.line}}/h5
       /div !-- ez-box --
     {{pass}}

     div class=ez-box box style=margin-bottom: 0px;
       {{if organization:}}
         h5 style=font-weight: bolder; padding-top:
 24px;{{=organization.name}}/h5
       {{pass}}
     /div !-- ez-box --

   /div !-- ez-wr --

   !-- Module 2B --
   div class=ez-wr wr style=margin-top: 0px;

     div class=ez-fr ez-negml ez-50
       div class=ez-box content style=padding-left: 0px; overflow:
 hidden;
         {{if npas:}}
           table style=text-align: left;
             {{for npa in npas:}}
               {{c=npa.NpaType.abbr}}
               {{a=npa.Npa.address}}
               {{if c=='T' or c=='F' or c=='M':}}
                 tr
                   td{{=c}}: /td
                   td{{=a}}/td
                 /tr
               {{elif c=='E':}}
                 tr
                   td{{=c}}: /td
                   td{{=A(a,_href=mailto:+a)}}/td
                 /tr
               {{else:}}
                 tr
                   td{{=c}}: /td
                   td{{=A(a,_href=http://+a)}}/td
                 /tr
               {{pass}}
             {{pass}}
           /table
         {{pass}}
       /div !-- ez-box --
     /div !-- ez-fr --

     div class=ez-last ez-oh
       div class=ez-box content style=overflow: hidden;
         {{if address:}}
           table style=text-align: left;
             tr
               td{{=address.street}} {{=address.houseNumber}} {{if
 address.houseNumberExtension:}}{{=address.houseNumberExtension}}
 {{pass}}/td
             /tr
             tr
               td{{=address.zipcode}} {{=address.city}}/td
             /tr
           /table
         {{pass}}
       /div !-- ez-box --
     /div !-- ez-last --

   /div !-- ez-wr --

 /div !-- ez-mw --

 I would like to add a link to this view which makes the business card
 downloadable as a vCard. Has anyone done this in web2py? What do I
 need to do to make this possible?

 Kind regards,

 Annet.


[web2py] Re: read once definitions - development vs. production

2011-12-08 Thread Anthony
You can move code to modules if you don't want it all executed on every 
request. In that case, you'll either have to use the 'current' object or 
pass global objects (such as 'db') to your module functions and methods. 
See 
http://web2py.com/book/default/chapter/04#Accessing-the-API-from-Python-modules.

Anthony

On Thursday, December 8, 2011 5:30:12 PM UTC-5, Constantine Vasil wrote:

 I used the PyDev+Eclipse+ GAE debugger extensively (after making it 
 working) 
 to see how web2py is working internally.

 Bottom line web2py is excellent for rapid development - while it is still 
 running,
 any change in the model in 0.py (say) is available immediately after 
 browser refresh
 because 0.py is read every time on browser refresh. 

 This is perfect for development but for production kills the speed. 
 Actually after 0.py
 is tweaked and reaches maturity I need to put it at read 'once mode'.

 This is much more important with GAE because for GAE you update all your 
 project
 on the cloud, not just 0.py if changed, so this feature is useless for GAE 
 in production 
 environment and slows down the execution.

 In 0.py I have GAE models which are already stable and I have to be able 
 to put them 
 in a read once place. The question is how they would be available globally 
 too? 
 In ideal scenario if I have a class:

 class MyClass(db_google.Model)
  name = dg_google.string(...)
  def profile(self, id)
some code

 I would want to access the model like (the simplest possible way):

 myclass = MYClass.profile(id)
 name = myclass.name


 Is this possible in web2py?

 Regards,
 --Constantine









[web2py] Re: read once definitions - development vs. production

2011-12-08 Thread Anthony
BTW, do you have a large number of model definitions? Have you measured the 
performance hit? It might not be that big.

Another option is conditional 
models: http://web2py.com/book/default/chapter/04#Workflow. You can define 
models that execute only for a particular controller and even a particular 
function within a controller.

Anthony

On Thursday, December 8, 2011 6:05:18 PM UTC-5, Anthony wrote:

 You can move code to modules if you don't want it all executed on every 
 request. In that case, you'll either have to use the 'current' object or 
 pass global objects (such as 'db') to your module functions and methods. 
 See 
 http://web2py.com/book/default/chapter/04#Accessing-the-API-from-Python-modules
 .

 Anthony

 On Thursday, December 8, 2011 5:30:12 PM UTC-5, Constantine Vasil wrote:

 I used the PyDev+Eclipse+ GAE debugger extensively (after making it 
 working) 
 to see how web2py is working internally.

 Bottom line web2py is excellent for rapid development - while it is still 
 running,
 any change in the model in 0.py (say) is available immediately after 
 browser refresh
 because 0.py is read every time on browser refresh. 

 This is perfect for development but for production kills the speed. 
 Actually after 0.py
 is tweaked and reaches maturity I need to put it at read 'once mode'.

 This is much more important with GAE because for GAE you update all your 
 project
 on the cloud, not just 0.py if changed, so this feature is useless for 
 GAE in production 
 environment and slows down the execution.

 In 0.py I have GAE models which are already stable and I have to be able 
 to put them 
 in a read once place. The question is how they would be available 
 globally too? 
 In ideal scenario if I have a class:

 class MyClass(db_google.Model)
  name = dg_google.string(...)
  def profile(self, id)
some code

 I would want to access the model like (the simplest possible way):

 myclass = MYClass.profile(id)
 name = myclass.name


 Is this possible in web2py?

 Regards,
 --Constantine









[web2py] Re: date(time) picker not working with multiple ajax loaded forms

2011-12-08 Thread Anthony
Which web2py version? Can you try trunk (all you should need is the new 
/views/web2py_ajax.html, /static/js/web2py.js, /static/js/calendar.js, and 
/static/css/calendar.css).

On Thursday, December 8, 2011 4:32:17 PM UTC-5, selecta wrote:

 If I load multiple forms as web2py components the date(time) picker only 
 works in the first form. Can somebody verify that or is it just a bug in my 
 code?



[web2py] Re: read once definitions - development vs. production

2011-12-08 Thread Constantine Vasil
I tried to move to modules but got the following issues:

This is not possible - e.g. to acces the class directly without a prefix - 
when I have a lot of code if I cannot do that it is a lot of work adding
a prefix.

myclass = MyClass.profile(id)
name = myclass.name

Also if I have several related class definitions in a module - how to 
access them? There is a possibility to put every class in a separate module
but it is not practical - my classes are interconnected. Also they use
Google db.Model so the class definition is like: 

class MyClass(db_google.Model)
  

I import Google imports successfully but not sure if every Google Model 
feature is working.

Bottom line - I cannot just copy/paste my working and tested class 
definitions 
in a module(s) without a significant code rewrite, all is already tested 
and I don't 
want to tweak it in order to be accessible from various parts of the code - 
it just
have to be available globally and used like:

myclass = MyClass.profile(id)
name = myclass.name

Otherwise it is not practical - it needs a lot of work.







[web2py] Re: Calirification on plugin_wiki license

2011-12-08 Thread Anthony
Well, the cube2py project page (http://code.google.com/p/cube2py/), which 
includes plugin_wiki, says it has a new BSD license.

Anthony


[web2py] Re: Factoid: How to reset id field in Postgres tables

2011-12-08 Thread lyn2py
Thanks for sharing Cliff!

On Dec 9, 3:53 am, Cliff cjk...@gmail.com wrote:
 db.mytable.truncate() cleans all the data out of the table, but does
 not reset the counter for the id field.  (See Ch 4 of the book.)

 db.products.truncate('RESTART IDENTITY CASCADE') resets the counter
 back to zero, so the first record gets an id of 1.

 Resetting the counter is useful for automated testing.


[web2py] Re: read once definitions - development vs. production

2011-12-08 Thread Constantine Vasil
They are a lot of model definitions - it is a big project which I am porting
to web2py. Django templates were easy to translate. GAE working with 
web2py - took me a lot of time be I did it. Making the PyDev+Ecilpse+GAE
SDK environment to work with debugging - very hard but it is done.

Now the final thing is to extract maximum performance - if CPU cycles a 
wasted
reading over and over the same code - this is not good. My pure GAE class 
definitions - 
well I counted 10,000 lines - no -- this cannot be put in 0.py and read 
every single time
a user hits refresh or changes a view. What will happen if I put them in 
routes.py?
I know it is read once but do they will be accessible globally? 

Something like:

myclass = MyClass.profile(id)
name = myclass.name

Without a code modification - these are another 25,000 lines of code? 

It has to be practical - this porting.





[web2py] Re: Calirification on plugin_wiki license

2011-12-08 Thread simlan
Okay but that is contradictory to the other post i mentioned.  Maybe i
find a way around modifying the plugin itself and just assume that it
is similar to web2py itself.

Thanks for the pointer anyway.

On Dec 8, 5:26 pm, Anthony abasta...@gmail.com wrote:
 Well, the cube2py project page (http://code.google.com/p/cube2py/), which
 includes plugin_wiki, says it has a new BSD license.

 Anthony


[web2py] list:reference table vs standard many-to-many relationship

2011-12-08 Thread Vincenzo Ampolo

Hi

are there any studies about performances on relational dbs of 
list:reference fields?

On the doc i read
 On relational databases they all mapped into text fields which contain 
the list of items separated by||

|||and after i read:
 For|list:type|fields the|contains(value)|operator maps into a non 
trivial query that checks for lists containing the|value|.

||
what is the best way to define a many-to-many relationship in term of 
performances?

||

--
Vincenzo Ampolo
http://vincenzo-ampolo.net
http://goshawknest.wordpress.com



[web2py] Re: How to reuse view functions

2011-12-08 Thread Anthony
I don't think you can put an include before an extend (well, you can, but 
it won't insert the include code before the extended view code, so if your 
call to mysidebar() comes before the {{include}} statement in layout.html, 
this won't work).

Anthony

On Thursday, December 8, 2011 12:14:04 PM UTC-5, Tito Garrido wrote:

 Folks,

 I need to change my sidebar sometimes so I've created a view 
 leftsidebar.html with a function like this:

 {{def mysidebar():}}
 my new sidebar!!!
 {{return}}

 And then on may layout.html I've put:
 {{if 'mysidebar' in globals():}}{{mysidebar()}}{{else:}}
 ...
 {{pass}}

 And on a controller view I've tryed:
 {{include 'leftsidebar.html'}}
 {{extend 'layout.html'}}
 ...

 This doesn't work... but If I put the content of leftsidebar.html in the 
 controller view it works...

 What am I missing here?

 Regards,

 Tito




 --

 Linux User #387870
 .
  _/_õ|__|
 ..º[ .-.___.-._| . . . .
 .__( o)__( o).:___ 



[web2py] Re: How to modify response.write output

2011-12-08 Thread Christopher Steel
:)


[web2py] Re: request reset password

2011-12-08 Thread pbreit
I customize all my user views like this:

{{elif request.args(0)=='request_reset_password':}}
h2Reset Password/h2
div id=user_form
{{=form.custom.begin}}
plabel for=auth_user_email id=auth_user_email__labelEmail: 
/labelbr
{{=form.custom.widget.email}}/p
pinput type=submit value=reset password //p
{{=form.custom.end}}
/div
{{elif request.args(0)=='change_password':}}
h2Change Password/h2
div id=user_form
{{=form.custom.begin}}
plabel for=emailOld Password/labelbr
{{=form.custom.widget.old_password}}/p
plabel for=passwordNew Password/labelbr
{{=form.custom.widget.new_password}}/p
plabel for=passwordRepeat New Password/labelbr
{{=form.custom.widget.new_password2}}/p
pinput type=submit value=save new password //p
{{=form.custom.end}}
/div


[web2py] Re: Calirification on plugin_wiki license

2011-12-08 Thread Anthony
What's the contradiction? That thread says plugin_wiki has a BSD license 
(apparently along with two others). When there are multiple licenses, you 
can choose the one you want. I think the thread mentions that the closed 
source app would have to indicate it is based on plugin_wiki because that 
is a requirement of BSD (you have to include the original copyright notice).

Anthony

On Thursday, December 8, 2011 6:33:56 PM UTC-5, simlan wrote:

 Okay but that is contradictory to the other post i mentioned.  Maybe i
 find a way around modifying the plugin itself and just assume that it
 is similar to web2py itself.

 Thanks for the pointer anyway.

 On Dec 8, 5:26 pm, Anthony abas...@gmail.com wrote:
  Well, the cube2py project page (http://code.google.com/p/cube2py/), 
 which
  includes plugin_wiki, says it has a new BSD license.
 
  Anthony



[web2py] Re: read once definitions - development vs. production

2011-12-08 Thread Anthony
On Thursday, December 8, 2011 6:22:31 PM UTC-5, Constantine Vasil wrote:

 I tried to move to modules but got the following issues:

 This is not possible - e.g. to acces the class directly without a prefix - 
 when I have a lot of code if I cannot do that it is a lot of work adding
 a prefix.


Are you saying:

from mymodule import MyClass
myclass = MyClass.profile(id)

doesn't work?



[web2py] Re: read once definitions - development vs. production

2011-12-08 Thread Constantine Vasil

OK let put it in reverse - how you would do this (GAE)/

in default.py
myaccount = MyAccount.get_profile(user_id)

Please note that 'in module' 

root = MyAccountRoot.get_profile()

does not works - it says 'not available' or something.

in default.py to import custom import you do that:

from main import Main
current.app.myapp = Main()
current.app.myapp.common_services()


So if it even works I have to change all my code to add
current.app.myapp. before every call. Which is a lot of work.

Regards,
--Constantine

=
in module
=
from google.appengine.ext import db as google_db
class MyAccountRoot(google_db.Model):
global_counter = google_db.IntegerProperty(required=True, default=0)
@classmethod
def get_profile(self):
root = Root.get_profile_del_cache()
profile = MyAccountRoot(key_name='user_id',
parent=root.key())

class MyAccount(google_db.Model):
@classmethod
def get_profile(self, user_id):
root = MyAccountRoot.get_profile()
profile = MyAccount.get_by_key_name(user_id,
parent=root.key())













[web2py] Re: Calirification on plugin_wiki license

2011-12-08 Thread Massimo Di Pierro
I can confirm it is BSD. If you read something else it is an error.
Let us know here and I will correct. Some of the js libs that come
with it may have other licenses.

On Dec 8, 5:33 pm, simlan pfeiffersi...@googlemail.com wrote:
 Okay but that is contradictory to the other post i mentioned.  Maybe i
 find a way around modifying the plugin itself and just assume that it
 is similar to web2py itself.

 Thanks for the pointer anyway.

 On Dec 8, 5:26 pm, Anthony abasta...@gmail.com wrote:







  Well, the cube2py project page (http://code.google.com/p/cube2py/), which
  includes plugin_wiki, says it has a new BSD license.

  Anthony


[web2py] Where is the best place to make e-mail by registration and login to be converted always to lower case?

2011-12-08 Thread Constantine Vasil
Where is the best place to make e-mail by registration and login to be 
converted always to lower case?

For example on registration form when everything is
disabled but the email/password, when the user enters:

Email:someb...@gmail.com
and
Email:someb...@gmail.com

web2py creates different accounts.

Now that can easily be changed by forcing the entered email to be only 
lower case and be stored in the database as a lower case.

Later when the user wants to login, again email address he entered to be 
converted to lower case thus to match the database entry.


So this lower case conversion has to be done at two places - 
the question is where is the best place to do that?


Regards,
--Constantine






[web2py] js paypal shopping cart

2011-12-08 Thread Massimo Di Pierro
I came across this and it may be useful to some

http://www.digicrafts.com.hk/components/JSAJAXPayPalCart


[web2py] Re: SQLFORM.factory int() argument must be a string or a number, not 'list' in many-to-many relationship

2011-12-08 Thread Cliff
Vincenzo,

Nope, unless list:reference fields will work.

Maybe they are worth a try.

On Dec 8, 5:00 pm, Vincenzo Ampolo vincenzo.amp...@gmail.com wrote:
 On 12/08/2011 07:12 PM, Cliff wrote:

  Vincenzo,

  Does it still blow up if you comment out these three lines?

            id =
  db.users_categories.insert(**db.user_categories._filter_fields(perm_form.va
  rs))
            id =
  db.users_dictionaries.insert(**db.user_dictionaries._filter_fields(perm_for
  m.vars))
            response.flash='Thanks for filling the form'

 Yeah. it's related to the multiple=True... i've the same problem in
 database administration if i try to add a single users_dictionary or
 users_categories entry.

 I'm now trying to fix it using SQLFORM.factory with a custom
 configuration so i can have more control in storing the submit the right
 way, do you know any better way?

 thanks

 --
 Vincenzo Ampolohttp://vincenzo-ampolo.nethttp://goshawknest.wordpress.com


[web2py] How to create own vocabulary?

2011-12-08 Thread lyn2py
Hi guys,

I have no idea where to start on this, I am grateful for any help.

Like MARKMIN has
**bold** -- bbold/b
''italics'' -- iitalics/i

I would like to add to (or create) a set of vocabulary like MARKMIN,
using square brackets like
[smiley] -- img src=static/images/smiley.gif

Mostly they are image files.

How can I do that in web2py?


[web2py] Re: js paypal shopping cart

2011-12-08 Thread lyn2py
Thank you Massimo!

Does anyone know the difference between the Free plugin and the Paid
version?


On Dec 9, 11:42 am, Massimo Di Pierro massimo.dipie...@gmail.com
wrote:
 I came across this and it may be useful to some

 http://www.digicrafts.com.hk/components/JSAJAXPayPalCart


[web2py] Re: foreign key reference and not null mutually exclusive. by design, or a bug?

2011-12-08 Thread Cliff
Check out IS_IN_DB and IS_NOT_IN_DB here:
http://www.web2py.com/book/default/chapter/07#Database-Validators

Are you creating the tables in native SQLite?


On Dec 8, 3:22 pm, nick name i.like.privacy@gmail.com wrote:
 I want to have a non-null foreign key reference, e.g.

 owner = db.define_table('owner'', Field('name'))
 package = db.define_table('package', Field('owner_id', owner,
 notnull=True), Field('name'))

 SQLite for example has no problem with this:

 sqlite create table owner(id int primary key, name text);
 sqlite create table package(id int primary key, owner_id references owner
 not null, name text);
 sqlite insert into owner values(1, web2py);
 sqlite insert into package values(1, 1, markmin);
 sqlite insert into package values(2, null, hello);
 Error: package.owner_id may not be NULL

 However, web2py will not put a not null qualifier on the foreign key
 reference; there is a specific check to NOT add a not null if the field
 is an id field or it is a reference field. Why is that?

 A bug in my app relating to this was just discovered by a user; I was
 relying on the database to signal an IntegrityError and fail to insert
 records that have a null reference, but they got in anyway.

 validate_and_insert will actually catch this -- but, why doesn't web2py
 append the NOT NULL?


[web2py] Re: Where is the best place to make e-mail by registration and login to be converted always to lower case?

2011-12-08 Thread Constantine Vasil
I tested this:

in registration form - entered lower case email, then in login form
entered email with first letter - a capital. The message was 'Invalid 
login'.



In registration form:
==
auth.settings.table_user.email.requires=[
 IS_LOWER(),
 IS_EMAIL(),

 IS_NOT_IN_DB(db,auth.settings.table_user.email)
 ]
current.app.auth =  auth 
form=current.app.auth.register()


In login form
==

auth.settings.table_user.email.requires=[
 IS_LOWER(),IS_EMAIL(),

 IS_NOT_IN_DB(db,auth.settings.table_user.email)
 ] 
current.app.auth =  auth
form=current.app.auth.login(next=login_next)
==


[web2py] Re: request reset password

2011-12-08 Thread Constantine Vasil
That is a good idea too - I will look at it.

Now I have another issue - I have only email/password as login.

The issue is that when the user registers with email - he can enter
lower case or mixed case. When then he logs in he can enter
a mixed case too. 

The best solution is to convert email entered to lower case before 
registration so the email to be stored as a lower case. Then when the user 
enters his email address in login form the email address to be converted to 
lower case so it will match the email already stored in lower case in the 
database.

I used this on both places but it does not works. It is suggested to use 
IS_LOWER but the name tells IS is checking, not converting:

auth.settings.table_user.email.requires=[IS_LOWER(),IS_EMAIL 
(),IS_NOT_IN_DB(db,auth.settings.table_user.email)] 



[web2py] Re: Where is the best place to make e-mail by registration and login to be converted always to lower case?

2011-12-08 Thread Anthony
What login method are you using? I would think that would work with the 
standard login method, but when using alternative methods, it looks like 
the login() code uses request.vars[username], which would be the 
un-transformed password (i.e., not converted to lowercase).

Anthony

On Thursday, December 8, 2011 11:12:40 PM UTC-5, Constantine Vasil wrote:

 I tested this:

 in registration form - entered lower case email, then in login form
 entered email with first letter - a capital. The message was 'Invalid 
 login'.



 In registration form:
 ==
 auth.settings.table_user.email.requires=[
  IS_LOWER(),
  IS_EMAIL(),
 
  IS_NOT_IN_DB(db,auth.settings.table_user.email)
  ]
 current.app.auth =  auth 
 form=current.app.auth.register()


 In login form
 ==

 auth.settings.table_user.email.requires=[
  IS_LOWER(),IS_EMAIL(),
 
  IS_NOT_IN_DB(db,auth.settings.table_user.email)
  ] 
 current.app.auth =  auth
 form=current.app.auth.login(next=login_next)
 ==



[web2py] Re: request reset password

2011-12-08 Thread Constantine Vasil
I found a better suggested solution and it works

===
auth.settings.register_onvalidation = login_email_lower 
current.app.auth =  auth 
form=current.app.auth.register()

auth.settings.login_onvalidation = login_email_lower
current.app.auth =  auth
form=current.app.auth.login(next=login_next)

def login_email_lower(form): 
form.vars.email = form.vars.email.lower() 
return(form) 

===

Now I need to do the same for:
form=current.app.auth.request_reset_password()

What auth.settings. to use for request_reset_password?




[web2py] Re: request reset password

2011-12-08 Thread Anthony
I replied about this in another thread. Note, though, that IS_LOWER() 
converts to lowercase, it is not checking whether the input is lowercase. 
It is one of several validators that merely transforms the input.

On Thursday, December 8, 2011 11:20:47 PM UTC-5, Constantine Vasil wrote:

 That is a good idea too - I will look at it.

 Now I have another issue - I have only email/password as login.

 The issue is that when the user registers with email - he can enter
 lower case or mixed case. When then he logs in he can enter
 a mixed case too. 

 The best solution is to convert email entered to lower case before 
 registration so the email to be stored as a lower case. Then when the user 
 enters his email address in login form the email address to be converted to 
 lower case so it will match the email already stored in lower case in the 
 database.

 I used this on both places but it does not works. It is suggested to use 
 IS_LOWER but the name tells IS is checking, not converting:

 auth.settings.table_user.email.requires=[IS_LOWER(),IS_EMAIL 
 (),IS_NOT_IN_DB(db,auth.settings.table_user.email)] 



[web2py] Re: request reset password

2011-12-08 Thread Constantine Vasil
IS_LOWER is not working, but the code 
below is working fine:

===
auth.settings.register_onvalidation = login_email_lower 
current.app.auth =  auth 
form=current.app.auth.register()

auth.settings.login_onvalidation = login_email_lower
current.app.auth =  auth
form=current.app.auth.login(next=login_next)

def login_email_lower(form): 
form.vars.email = form.vars.email.lower() 
return(form) 

===

I believe I have to use this code for request_reset_password?

auth.settings.reset_password_onvalidation = login_email_lower 
current.app.auth =  auth

form=current.app.auth.request_reset_password()



[web2py] Re: read once definitions - development vs. production

2011-12-08 Thread Anthony
On Thursday, December 8, 2011 9:29:42 PM UTC-5, Constantine Vasil wrote:


 OK let put it in reverse - how you would do this (GAE)/

 in default.py
 myaccount = MyAccount.get_profile(user_id)


What happens when you do:

from module_that_defines_MyAccount import MyAccount
myaccount = MyAccount.get_profile(user_id)

Anthony


[web2py] Re: How to create own vocabulary?

2011-12-08 Thread Massimo Di Pierro
the proper way is using a parer but the shortcut (used in markmin) is
using regular expressions

def process(text):
   import re
   text = re.compile('\[(?Pkey.+?)\]).sub('img src=static/images/
\gkey.gif',text)
   # ... more for other rules
   return text

but you have to make sure rules do not conflict with each other
(nested matches).


On Dec 8, 10:01 pm, lyn2py lyn...@gmail.com wrote:
 Hi guys,

 I have no idea where to start on this, I am grateful for any help.

 Like MARKMIN has
 **bold** -- bbold/b
 ''italics'' -- iitalics/i

 I would like to add to (or create) a set of vocabulary like MARKMIN,
 using square brackets like
 [smiley] -- img src=static/images/smiley.gif

 Mostly they are image files.

 How can I do that in web2py?


[web2py] Re: js paypal shopping cart

2011-12-08 Thread Massimo Di Pierro
I have not found out yet.

On Dec 8, 10:03 pm, lyn2py lyn...@gmail.com wrote:
 Thank you Massimo!

 Does anyone know the difference between the Free plugin and the Paid
 version?

 On Dec 9, 11:42 am, Massimo Di Pierro massimo.dipie...@gmail.com
 wrote:







  I came across this and it may be useful to some

 http://www.digicrafts.com.hk/components/JSAJAXPayPalCart


[web2py] Question on compute field

2011-12-08 Thread Joseph Jude
Hi all,
I am just starting to use compute field. Here is my db definition looks 
like (it is in a module)
class Entries(object):
 .

  def define_tables(self,db):
  
  Field('permalink',type='text',required=True,compute = lambda row: 
self.get_permalink(row)),
  .

def get_permalink(self,row):

permalink = '/test/'
return permalink

This throws the error:

SyntaxError: Table: missing required field: permalink

What am I doing wrong here?


Thank you,

Joseph



[web2py] Re: Question on compute field

2011-12-08 Thread Anthony
I'm not sure you're supposed to use required=True with a computed field. I 
think required=True requires an actual value be provided with the insert. 
With a computed field, it's probably not needed because if no value is 
provided, the value will be computed, so the field won't end up empty 
either way.

Anthony

On Friday, December 9, 2011 12:40:14 AM UTC-5, Joseph Jude wrote:

 Hi all,
 I am just starting to use compute field. Here is my db definition looks 
 like (it is in a module)
 class Entries(object):
  .

   def define_tables(self,db):
   
   Field('permalink',type='text',required=True,compute = lambda row: 
 self.get_permalink(row)),
   .
 
 def get_permalink(self,row):

 permalink = '/test/'
 return permalink

 This throws the error:

 SyntaxError: Table: missing required field: permalink

 What am I doing wrong here?


 Thank you,

 Joseph



[web2py] Re: Where is the best place to make e-mail by registration and login to be converted always to lower case?

2011-12-08 Thread Constantine Vasil
OK - this is working

auth.settings.login_onvalidation = login_email_lower
current.app.auth =  auth
form=current.app.auth.login(next=login_next)

it works also for registration:

auth.settings.register_onvalidation = login_email_lower 
current.app.auth =  auth 
form=current.app.auth.register()

def login_email_lower(form): 
form.vars.email = form.vars.email.lower() 
return(form) 

I registered with lower caps email.

But when I try to enter mixed caps email in request_reset_password, it does 
not works and it does not shows an error message:

auth.settings.reset_password_onvalidation = login_email_lower 
current.app.auth =  auth
form=current.app.auth.request_reset_password()

What is the correct way to use it?


[web2py] Re: Where is the best place to make e-mail by registration and login to be converted always to lower case?

2011-12-08 Thread Anthony
Not sure why that's not working. Regarding IS_LOWER not working for login, 
I think the problem might be that the login() function temporarily replaces 
the username field's 'requires' with just an IS_EMAIL validator.

Anthony

On Friday, December 9, 2011 1:23:22 AM UTC-5, Constantine Vasil wrote:

 OK - this is working

 auth.settings.login_onvalidation = login_email_lower
 current.app.auth =  auth
 form=current.app.auth.login(next=login_next)

 it works also for registration:

 auth.settings.register_onvalidation = login_email_lower 
 current.app.auth =  auth 
 form=current.app.auth.register()

 def login_email_lower(form): 
 form.vars.email = form.vars.email.lower() 
 return(form) 

 I registered with lower caps email.

 But when I try to enter mixed caps email in request_reset_password, it 
 does not works and it does not shows an error message:

 auth.settings.reset_password_onvalidation = login_email_lower 
 current.app.auth =  auth
 form=current.app.auth.request_reset_password()

 What is the correct way to use it?



Re: [web2py] Re: web2py, amazon ec2 and static pages outside of the application

2011-12-08 Thread José Luis Redrejo Rodríguez
2011/12/8 Marco Tulio Cicero de M. Porto mtcpo...@gmail.com:
 I was wondering if there was any configuration on Apache that could help on
 that, so that I could set the php application on www root and the web2py
 applications on www-data ...



That's exactly what explains the recipe
http://www.web2pyslices.com/slices/take_slice/56 that I suggested you
in my previous email.


 2011/12/8 Marco Tulio Cicero de M. Porto mtcpo...@gmail.com

 I'd appreciate, (that's what I was going to say when the mail was sent by
 itself... :P :)

 Thanks in advanced,
 Marco Tulio

 2011/12/8 Marco Tulio Cicero de M. Porto mtcpo...@gmail.com

 well, about this: I created an application called maps and moved the
 whole php application to
 /home/www-data/web2py/applications/maps/static/i3geo so that, now instead of
 http://servername.com/i3geo I have http://servername.com/maps/static/i3geo
 wich ends up working since I can see the static files and they seem to be
 running fine. On the other hand, I'll have to configure that application
 (php one), in order to work with the new path... If anyone thinks of another
 way of making this work, I

 2011/12/8 Marco Tulio Cicero de M. Porto mtcpo...@gmail.com

 Hi there!

 ok, here's the deal:

 I installed web2py on ec2 following the instructions on the attached
 file.
 So far so good. I had it installed and working perfectly.

 Thing is that now, I want to use on that same server a geoprocessing
 application that will read from the databases I created with my web2py
 applications.
 This geoprocessing tool (i3geo), was made with PHP and works well when
 installed on another server.

 But on when I try to put them togheter, I won't be able to see the
 geoprocessing tool.

 At first, I thought I should put the application on /var/www
 (/var/www/i3geo for ex), but it wouldn't read the pages there... then I
 remembered that when I was installing web2py there, I placed it on
 /home/www-data/web2py and that all of it's applications are under that (
 /home/www-data/web2py/applications/app_name for ex) then I tried to create 
 a
 directory with a hello world on it and place it there. Couldn't read it.

 Well, problem: I can make applications with web2py that'll run smoothly
 on ec2. But I'm not beeing able to publish anything else (not a single 
 html)
 on that server.

 Any hints?

 Thanks in advanced,
 Marco Tulio

 --
 []'s
 Marco Tulio




 --
 []'s
 Marco Tulio




 --
 []'s
 Marco Tulio




 --
 []'s
 Marco Tulio