[web2py] Re: Consuming a web2py web service in C#?

2011-05-24 Thread ron_m
If you go to the web2py server admin app e.g. http://127.0.0.1:8000/admin 
and login you should see the name of the app containing the service and an 
errors link after the name. Click that and you will see the errors page and 
be able to see the stack trace.

When running as a Python process you can put print statements in your 
controller to get an idea of what the parameters look like coming into the 
request. The output should go out on the terminal you ran python web2py.py 
from. Be sure to comment out the print statements before embedding in a web 
server such as apache with WSGI or you will get tickets from the print 
statement.


[web2py] How to make a constant for list of fields in select()?

2011-05-24 Thread pbreit
To optimize a query I wanted to create a constant that represented the list 
of fields to select(). I ended up doing a join like I saw in the web2py 
source for SQLALL. Is this the best way? I tried a bunch of different other 
ways but none worked.

item_summary_fields = ', '.join([str(field) for field in [db.item.id, 
db.item.title, db.item.image_thumb, db.item.currency, 
db.item.shipping_method, db.item.start_price, db.item.drops, 
db.item.duration, db.item.price_change, db.item.created_on]])

rows = db(db.item.id0).select(item_summary_fields)


[web2py] Re: Two fields with autocomplete in a single form fail

2011-05-24 Thread annet
Hi,

Have you been able to solve this problem? I had the same problem:
http://groups.google.com/group/web2py/browse_thread/thread/b7c4b87444718e59/6cf267534775f128?q=#6cf267534775f128

I eventually solved it by using a third party auto complete widget,
apparently it's a naming issue.


Kind regards,

Annet


[web2py] Problem starting cron job

2011-05-24 Thread Marcel Luethi
Hi everybody!

I'm trying to start a cron job, which fails:

2011-05-24 10:40:00,517 - web2py.cron - WARNING - WEB2PY CRON Call
returned code 1:
web2py Enterprise Web Framework
Created by Massimo Di Pierro, Copyright 2007-2011
Version 1.95.1 (2011-04-25 15:04:14)
Database drivers available: SQLite3, pymysql, Oracle
Traceback (most recent call last):
  File /opt/ecc/web2py/web2py.py, line 19, in module
gluon.widget.start(cron=True)
  File /opt/ecc/web2py/gluon/widget.py, line 804, in start
import_models=options.import_models, startfile=options.run)
  File /opt/ecc/web2py/gluon/shell.py, line 203, in run
execfile(startfile, _env)
IOError: [Errno 2] No such file or directory: 'applications/ecc/cron/
ecc_importer.py'


This is my contab entry:
0-59/5   ****eswsys *applications/ecc/
cron/ecc_importer.py


With a logger.warning call and os.getcwd() just before the execfile I
get:
2011-05-24 10:40:00,468 - web2py - WARNING - EXECFILE: applications/
ecc/cron/ecc_importer.py, working dir: /opt/ecc/web2py

The curent working directory seems to be ok and ecc_importer.py is in
the right place with 755 rights.

The job run fine on my Windows development machine but now doesn't
work when I moved it to our Linux server (Red Hat 5.2 (Tikanga) /
CentOS, 64bit).

Any ideas what I'm doing wrong?
Do I have to use PYTHONSTARTUP somehow?

TIA -.- Marcel


[web2py] Re: Problem starting cron job

2011-05-24 Thread Marcel Luethi
This is so embarrassing...!

Sorry for the last post - I found the problem:
I changed the name of the script slighly before the deployment to the
server.

Now it works perfectly. ;-)

Have a nice day.
Marcel



On 24 Mai, 10:52, Marcel Luethi marcel.lue...@gmail.com wrote:
 Hi everybody!

 I'm trying to start a cron job, which fails:

 2011-05-24 10:40:00,517 - web2py.cron - WARNING - WEB2PY CRON Call
 returned code 1:
 web2py Enterprise Web Framework
 Created by Massimo Di Pierro, Copyright 2007-2011
 Version 1.95.1 (2011-04-25 15:04:14)
 Database drivers available: SQLite3, pymysql, Oracle
 Traceback (most recent call last):
   File /opt/ecc/web2py/web2py.py, line 19, in module
     gluon.widget.start(cron=True)
   File /opt/ecc/web2py/gluon/widget.py, line 804, in start
     import_models=options.import_models, startfile=options.run)
   File /opt/ecc/web2py/gluon/shell.py, line 203, in run
     execfile(startfile, _env)
 IOError: [Errno 2] No such file or directory: 'applications/ecc/cron/
 ecc_importer.py'

 This is my contab entry:
 0-59/5   *        *        *        *        eswsys *applications/ecc/
 cron/ecc_importer.py

 With a logger.warning call and os.getcwd() just before the execfile I
 get:
 2011-05-24 10:40:00,468 - web2py - WARNING - EXECFILE: applications/
 ecc/cron/ecc_importer.py, working dir: /opt/ecc/web2py

 The curent working directory seems to be ok and ecc_importer.py is in
 the right place with 755 rights.

 The job run fine on my Windows development machine but now doesn't
 work when I moved it to our Linux server (Red Hat 5.2 (Tikanga) /
 CentOS, 64bit).

 Any ideas what I'm doing wrong?
 Do I have to use PYTHONSTARTUP somehow?

 TIA -.- Marcel


[web2py] Strange autocomplete behaviour

2011-05-24 Thread Johann Spies
Truncated model:

db.define_table('akb_doccenter',
Field('doc_nr', type='string', length=50,
  requires=IS_NOT_IN_DB(db, 'doccenter.doc_nr')),
Field('location'))

db.akb_doccenter.doc_nr.widget =SQLFORM.widgets.autocomplete(
request, db.akb_doccenter.doc_nr, limitby=(0,20),min_length=2)


I use an autocomplete-widget to help the user to enter a unique doc_nr.

It works to a certain extend in the sense that it shows the doc_nr's in the
database except for those recently added.  The database was prepopulated
with data from an older version.  All the records entered after that will
not show up in the list shown by autocomplete.  But if you search for it
they are there amongst the other data.

At first I thought creating an index on doc_nr would change this behaviour
but it didn't.

I have appended the screenshot.  Compare that with the result of the query:

select doc_nr from akb_doccenter where doc_nr like 'wood5%'

wood591
wood5224
wood5225


Any idea how to fix this?

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
attachment: Screenshot - 24052011 - 11:47:30.png

[web2py] Re: Subdomain Duplicates Content

2011-05-24 Thread Francisco Costa
Sorry if I didn't explain this well...
Imagine a scenario of a web company..

The company website is in the main app
The clients sites are in different apps like client1, client2, etc

In routes.py you redirect the domain to the respective app (ex.
client1.com - client1)

The problem is that from client1.com you still able to access other
clients through the link http://client1.com/client2/default/index

This is bad because client1 just want his website on his domain.

Did I make myself clear this time?


On May 24, 2:06 am, Bruno Rocha rochacbr...@gmail.com wrote:
 I guess Francisco wants to explain a different behaviour.

 Having 2 or more apps on the same web2py instance, web2py should prevent the
 app to be requested by other domain than its own domain.

 www.app1.com- /app1  #allowedwww.app2.com- /app2  #allowed

 www.app1.com/app2- /app2 # deniedwww.app2.com/app1- app1 # denied

 I agree with him, sometimes search robots finds apps under different
 domains...

 --
 Bruno Rocha
 [ About me:http://zerp.ly/rochacbruno]

 On Mon, May 23, 2011 at 9:40 PM, Jonathan Lundell jlund...@pobox.comwrote:







  On May 23, 2011, at 6:10 PM, Francisco Costa wrote:

   The URL calling is fine.. the problem is how web2py manages different
   apps from different domains/subdomains

   I really believe that they should be improved!

  web2py (URL) isn't generating a domain *at all* in the URL unless you
  explicitly specify one; the domain is normally provided by the browser, and
  that's how it should be, at least by default. If you want to override the
  domain the browser is using, you need to do it explicitly.

   On May 23, 11:02 pm, Jonathan Lundell jlund...@pobox.com wrote:
   What's your URL() call for the example below? Have you looked at the
  HTML? I wouldn't expect to see a domain there at all.

   On May 23, 2011, at 12:00 PM, Francisco Costa m...@franciscocosta.com
  wrote:

   Hello,
   I have a main app and a blog app

   My routes.py are like this:
   routers = dict(
      BASE = dict(
          default_application = 'main',
          default_controller = 'default',
          default_function = 'index',
          domains = {
              domain.com : main,
              blog.domain.com : blog,
          }
      )
   )

   While I'm browsing through the subdomain blog.domain.com I have some
   links that point to the main app.
   Those links are generated like this:
  http://blog.domain.com/main/test

   If I click on it it works, but I would like the link to be generated
   as
  http://domain.com/main/test

   This is bad because 2 different domains urls shouldn't target the same
   page and it also duplicates data which is bad for SEO

   Any help?


[web2py] Re: How to implement background processes elegantly..

2011-05-24 Thread Nite
Here's an abstraction from my code. There may be better ways to do it,
but it works.

Let's say you wanted to start a miner to watch the system log...

from subprocess import *
from multiprocessing import Process, Queue

def doSomething(self, q):
p1 = Popen([ 'tail', '-f', '/var/log/messages'), stdout=PIPE)
p2 = Popen(['grep', '-i', 'foo'], stdin=p1.stdout, stdout=PIPE)
q.put(dict(pid=p1.pid))

def startDoSomething(self):
q = Queue()
p = Process(target=doSomething, args=(q,))
p.start()
db.settings.insert(pid=q.get()['pid'],
timestamp=datetime.datetime.now())
db.commit()

The reason I did it this way is that I need to control the start/stop
of this secondary process. There will only be one instance of it
running at any given time and special permissions are needed to access
the control functions.

--Nite

(Note, this example doesn't really make sense since we aren't doing
anything with the stdout from the grep command, but illustrates the
point of how to start a secondary process which was the purpose)

On May 23, 11:26 pm, Massimo Di Pierro massimo.dipie...@gmail.com
wrote:
 write a normal python program using multiprocessing...

 within each process do

 from gluon.shell import env
 globals().update(env('appname',import_models=True))

 and now you have your own db, request, response, etc.

 I did not try it but it should work fine.
 There may be a path issue since this expects to find applications in
 ther current working folder.

 Massimo

 On May 23, 9:47 pm, pbreit pbreitenb...@gmail.com wrote:







  Use the multiprocessing library (to implement background processes).


[web2py] Re: Strange autocomplete behaviour (Solved)

2011-05-24 Thread Johann Spies
On 24 May 2011 11:54, Johann Spies johann.sp...@gmail.com wrote:

 Truncated model:

 db.define_table('akb_doccenter',
 Field('doc_nr', type='string', length=50,
   requires=IS_NOT_IN_DB(db, 'doccenter.doc_nr')),


Copy and paste mistake:

This line should refer to akb_doccenter.doc_nr and not doccenter.doc_nr
which belongs to a different table.

Apologies for the noise.

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: Plugin wiki attachaments not working

2011-05-24 Thread Tito Garrido
Yes, I got the latest last night

On Mon, May 23, 2011 at 11:41 PM, Massimo Di Pierro 
massimo.dipie...@gmail.com wrote:

 This should be fixed in plugin wiki. Do you have the latest?

 Mind that I do not promise backward compatibility for plugin-wiki but
 I try to update it as web2py core changes.

 Massimo

 On May 23, 6:13 pm, Tito Garrido titogarr...@gmail.com wrote:
  Is it expected?
 
 
 
 
 
 
 
 
 
  On Sun, May 22, 2011 at 4:02 PM, Tito Garrido titogarr...@gmail.com
 wrote:
   web2py™ Version 1.96.0 (2011-05-22 09:34:40)  Python Python 2.6.1:
   /usr/bin/python  Traceback
 
   1.
   2.
   3.
   4.
   5.
   6.
   7.
   8.
   9.
   10.
 
   Traceback (most recent call last):
 File
 /Users/titogarrido/Documents/Projetos/web2py/gluon/restricted.py, line
 184, in restricted
 
   exec ccode in environment
 File
 /Users/titogarrido/Documents/Projetos/web2py/applications/secmon/views/plu
 gin_wiki/attachments.html, line 67, in module
 
 File /Users/titogarrido/Documents/Projetos/web2py/gluon/dal.py,
 line 3656, in __getattr__
 
   return self[key]
 File /Users/titogarrido/Documents/Projetos/web2py/gluon/dal.py,
 line 3647, in __getitem__
 
   return dict.__getitem__(self, key)
 
   KeyError: 'file'
 
  --
 
  Linux User #387870
  .
   _/_õ|__|
  ..º[ .-.___.-._| . . . .
  .__( o)__( o).:___




-- 

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


[web2py] Ang.: Re: Getting started with appliances for web2py on GAE

2011-05-24 Thread Niklas Rosencrantz
Thanks for your answers. I've tried running the app locally but when I try 
to access these URL
http://localhost:8080/admin
https://localhost:8080/admin
I receive error messages (Insecure channel and SSL received a record that 
exceeded the maximum permissible length.(Error code: 
ssl_error_rx_record_too_long))

So I couldn't get the local admin part to work. On production I can access 
the /admin via https. 

Niklas




[web2py] Re: How to implement background processes elegantly..

2011-05-24 Thread Kimmo

Hi,

For anyone else that might be wondering this issue,
I tried Ross Peoples solution:

db_thread = DAL(db._uri)
for k, v in db.items():
db_thread[k] = v

And it did not work properly (it did feel a bit hack anyway).

One pretty bad solution to this issue is to use threading.Lock() in
every single db query / commit etc.

I will however look into multiprocessing and on the advice from
Massimo.

Thanks to everybody that helped with this issue!

Kimmo


On 24 touko, 06:26, Massimo Di Pierro massimo.dipie...@gmail.com
wrote:
 write a normal python program using multiprocessing...

 within each process do

 from gluon.shell import env
 globals().update(env('appname',import_models=True))

 and now you have your own db, request, response, etc.

 I did not try it but it should work fine.
 There may be a path issue since this expects to find applications in
 ther current working folder.

 Massimo

 On May 23, 9:47 pm, pbreit pbreitenb...@gmail.com wrote:







  Use the multiprocessing library (to implement background processes).


[web2py] Cannot open MYSQL database

2011-05-24 Thread peter
I get this error message when trying to connect to an MYSQL database


dbp = DAL('mysql://admin:password@localhost:3306/postcodes2')
 File /opt/web-apps/web2py/gluon/dal.py, line 3720, in __init__
raise
RuntimeError, Failure to connect, tried 5 times:\n%s %
errorRuntimeError:
Failure to connect, tried 5 times:
(1049, uUnknown database 'postcodes2')

I get the error with or without the port number.
I can telnet to port 3306.

If I change the password to an incorrect one, it gives a different
error, so it connecting to the host.
If I use mysql at the command line it shows this database as present.

Does anyone have any ideas?
Thanks




[web2py] [1/2 OT] Access Control

2011-05-24 Thread Jose
Hello

I have a web application (third party) in php. I can not even get into
php or touch anything of this application.

I need to implement access control to php app:

Profile o Role A - http://mydomain.com/index.php?config=A
Profile o Role B - http://mydomain.com/index.php?config=B

The idea is to make an app web2py the entry point (and a few other
things) the application, and according to user role for directions to
the url.

I want to confirm is that if a user belonging to role A copy and
paste the url into the browser belongs to the role B do not let it
go.

I saw the file /scripts/access.wsgi

It can work for what I need?
How do I set with Cherokee or nginx?

Best regards
Jose


[web2py] Re: How to make a constant for list of fields in select()?

2011-05-24 Thread Philip
Use the python * operator to unpack the list, like this:

item_summary_fields =  [db.item.id, db.item.title, db.item.image_thumb, 
db.item.currency, db.item.shipping_method, db.item.start_price, 
db.item.drops, db.item.duration, db.item.price_change, db.item.created_on]

rows = db(db.item.id0).select(*item_summary_fields)

In Python, if my_list is a list, *my_list unpacks the list. Similarly, if 
my_dict is a dict, **my_dict unpacks it.

so, if we want to use orderby or groupby, we can use the dict unpacking like 
this:

kw ={'orderby':'db.item.title'}

rows = db().select(*item_summary_fields,**kw)


[web2py] Re: Plugin wiki attachaments not working

2011-05-24 Thread Massimo Di Pierro
Please try download it again. I think I fixed it.
In any case there will be a new version of plugin wiki next week. The
current one has a vulnerability in jqgrid.

On May 24, 7:23 am, Tito Garrido titogarr...@gmail.com wrote:
 Yes, I got the latest last night

 On Mon, May 23, 2011 at 11:41 PM, Massimo Di Pierro 









 massimo.dipie...@gmail.com wrote:
  This should be fixed in plugin wiki. Do you have the latest?

  Mind that I do not promise backward compatibility for plugin-wiki but
  I try to update it as web2py core changes.

  Massimo

  On May 23, 6:13 pm, Tito Garrido titogarr...@gmail.com wrote:
   Is it expected?

   On Sun, May 22, 2011 at 4:02 PM, Tito Garrido titogarr...@gmail.com
  wrote:
web2py™ Version 1.96.0 (2011-05-22 09:34:40)  Python Python 2.6.1:
/usr/bin/python  Traceback

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.

Traceback (most recent call last):
  File
  /Users/titogarrido/Documents/Projetos/web2py/gluon/restricted.py, line
  184, in restricted

    exec ccode in environment
  File
  /Users/titogarrido/Documents/Projetos/web2py/applications/secmon/views/plu
  gin_wiki/attachments.html, line 67, in module

  File /Users/titogarrido/Documents/Projetos/web2py/gluon/dal.py,
  line 3656, in __getattr__

    return self[key]
  File /Users/titogarrido/Documents/Projetos/web2py/gluon/dal.py,
  line 3647, in __getitem__

    return dict.__getitem__(self, key)

KeyError: 'file'

   --

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

 --

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


[web2py] Re: How to implement background processes elegantly..

2011-05-24 Thread Massimo Di Pierro
What is this supposed to do? Because I do not think it does it
anyway. :-)

On May 24, 1:02 am, Kimmo ktupp...@gmail.com wrote:
 Hi,

 For anyone else that might be wondering this issue,
 I tried Ross Peoples solution:

 db_thread = DAL(db._uri)
 for k, v in db.items():
     db_thread[k] = v

 And it did not work properly (it did feel a bit hack anyway).

 One pretty bad solution to this issue is to use threading.Lock() in
 every single db query / commit etc.

 I will however look into multiprocessing and on the advice from
 Massimo.

 Thanks to everybody that helped with this issue!

 Kimmo

 On 24 touko, 06:26, Massimo Di Pierro massimo.dipie...@gmail.com
 wrote:







  write a normal python program using multiprocessing...

  within each process do

  from gluon.shell import env
  globals().update(env('appname',import_models=True))

  and now you have your own db, request, response, etc.

  I did not try it but it should work fine.
  There may be a path issue since this expects to find applications in
  ther current working folder.

  Massimo

  On May 23, 9:47 pm, pbreit pbreitenb...@gmail.com wrote:

   Use the multiprocessing library (to implement background processes).


[web2py] Re: Cannot open MYSQL database

2011-05-24 Thread Massimo Di Pierro
The error is clear: Unknown database 'postcodes2'

did you create the database?

On May 24, 4:52 am, peter peterchutchin...@gmail.com wrote:
 I get this error message when trying to connect to an MYSQL database

     dbp = DAL('mysql://admin:password@localhost:3306/postcodes2')
  File /opt/web-apps/web2py/gluon/dal.py, line 3720, in __init__
 raise
 RuntimeError, Failure to connect, tried 5 times:\n%s %
 errorRuntimeError:
 Failure to connect, tried 5 times:
 (1049, uUnknown database 'postcodes2')

 I get the error with or without the port number.
 I can telnet to port 3306.

 If I change the password to an incorrect one, it gives a different
 error, so it connecting to the host.
 If I use mysql at the command line it shows this database as present.

 Does anyone have any ideas?
 Thanks


[web2py] Youtube api json help

2011-05-24 Thread JagChris
I am using the youtube api to try and show the most rated videos from
the feed and i have concerted it to json and i can display the json
for such feed on my page but how do i convert this into the video
itself n displays videos from this feed on my page


[web2py] alias field names

2011-05-24 Thread Plumo
the database I use (GAE) has a big overhead for long field names.
So I want to change Field('my_descriptive_field_name') to Field('a') and use 
an alias to keep accessing with 'my_descriptive_field_name'.
Can this be done?


[web2py] Re: alias field names

2011-05-24 Thread Massimo Di Pierro
How about

my_descriptive_field_name = db.a

On May 24, 9:06 am, Plumo richar...@gmail.com wrote:
 the database I use (GAE) has a big overhead for long field names.
 So I want to change Field('my_descriptive_field_name') to Field('a') and use
 an alias to keep accessing with 'my_descriptive_field_name'.
 Can this be done?


Re: [web2py] Re: alias field names

2011-05-24 Thread Richard Baron Penman
would this work?
db.table_name.my_descriptive_field_name = db.table_name.a

I would rather avoid extra global variables and changing my database
queries.


On Wed, May 25, 2011 at 12:21 AM, Massimo Di Pierro 
massimo.dipie...@gmail.com wrote:

 How about

 my_descriptive_field_name = db.a

 On May 24, 9:06 am, Plumo richar...@gmail.com wrote:
  the database I use (GAE) has a big overhead for long field names.
  So I want to change Field('my_descriptive_field_name') to Field('a') and
 use
  an alias to keep accessing with 'my_descriptive_field_name'.
  Can this be done?



Re: [web2py] Re: alias field names

2011-05-24 Thread Vinicius Assef
I think he is talking about this, if it would be SQL:
SELECT my_descriptive_name as a FROM my_table

In web2py, something near:
Field('my_descriptive_field_name', 'string', alias='a')

And, in code:
print db.my_table.a

--
Vinicius Assef.



On Tue, May 24, 2011 at 11:21 AM, Massimo Di Pierro
massimo.dipie...@gmail.com wrote:
 How about

 my_descriptive_field_name = db.a

 On May 24, 9:06 am, Plumo richar...@gmail.com wrote:
 the database I use (GAE) has a big overhead for long field names.
 So I want to change Field('my_descriptive_field_name') to Field('a') and use
 an alias to keep accessing with 'my_descriptive_field_name'.
 Can this be done?


[web2py] get last visited page

2011-05-24 Thread Richard Vézina
Hello,

I would like to know if there is a built vars to know what was the last page
a user had visited?

I would like to build a basic navigation bar that will contain a back button
and I would like to know what was the last visited page so I could write
rule for different view depending from where the user come from the back
button will redirect at the rigth place.

Thanks

Richard


Re: [web2py] Re: alias field names

2011-05-24 Thread Richard Baron Penman
For space reasons I want the database to internally store 'a', but be able
to use the longer name in code for readability.

So I think your example should instead be:
Field('a', 'string', alias='my_descriptive_field_name')

But does that alias parameter exist? Not according to docs:
http://web2py.com/book/default/chapter/06#Record-Representation

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

On Wed, May 25, 2011 at 1:18 AM, Vinicius Assef vinicius...@gmail.comwrote:

 I think he is talking about this, if it would be SQL:
 SELECT my_descriptive_name as a FROM my_table

 In web2py, something near:
 Field('my_descriptive_field_name', 'string', alias='a')

 And, in code:
 print db.my_table.a

 --
 Vinicius Assef.



 On Tue, May 24, 2011 at 11:21 AM, Massimo Di Pierro
 massimo.dipie...@gmail.com wrote:
  How about
 
  my_descriptive_field_name = db.a
 
  On May 24, 9:06 am, Plumo richar...@gmail.com wrote:
  the database I use (GAE) has a big overhead for long field names.
  So I want to change Field('my_descriptive_field_name') to Field('a') and
 use
  an alias to keep accessing with 'my_descriptive_field_name'.
  Can this be done?



Re: [web2py] Re: alias field names

2011-05-24 Thread Vinicius Assef
Richard,
I didn't understand your space reasons, but alias param does not exist today.

Massimo can tell us if it will be implemented.
IMHO it is a good idea, mainly for legacy tables, with legacy names.

--
Vinicius Assef.



On Tue, May 24, 2011 at 12:36 PM, Richard Baron Penman
richar...@gmail.com wrote:
 For space reasons I want the database to internally store 'a', but be able
 to use the longer name in code for readability.
 So I think your example should instead be:
 Field('a', 'string', alias='my_descriptive_field_name')
 But does that alias parameter exist? Not according to docs:
 http://web2py.com/book/default/chapter/06#Record-Representation


 On Wed, May 25, 2011 at 1:18 AM, Vinicius Assef vinicius...@gmail.com
 wrote:

 I think he is talking about this, if it would be SQL:
 SELECT my_descriptive_name as a FROM my_table

 In web2py, something near:
 Field('my_descriptive_field_name', 'string', alias='a')

 And, in code:
 print db.my_table.a

 --
 Vinicius Assef.



 On Tue, May 24, 2011 at 11:21 AM, Massimo Di Pierro
 massimo.dipie...@gmail.com wrote:
  How about
 
  my_descriptive_field_name = db.a
 
  On May 24, 9:06 am, Plumo richar...@gmail.com wrote:
  the database I use (GAE) has a big overhead for long field names.
  So I want to change Field('my_descriptive_field_name') to Field('a')
  and use
  an alias to keep accessing with 'my_descriptive_field_name'.
  Can this be done?




[web2py] Re: Problem with Ubuntu init script

2011-05-24 Thread ron_m
I found out the DAEMON_ARGS change should not be applied. The start branch 
of the script needs both pid file options.

The --pidfile option prevents start-stop-daemon from behaving like killall 
as mentioned in the Description section of the start-stop-daemon man page. 
This will allow start-stop-daemon to run python if it finds another copy of 
python on the system doing some other task.

The --pid_filename option to web2py is needed to actually get the 
/var/run/web2py/web2py.pid file written otherwise the service web2py stop 
command or the init state change will fail to find the copy of python 
running web2py and kill it.

Please use only the line 65 patch from above. I sent Massimo the correct 
patch file so he is looking at it.

Ron


[web2py] get last visited page

2011-05-24 Thread pbreit
Request.ENV.referer but it's not super reliable.


Re: [web2py] Re: alias field names

2011-05-24 Thread pbreit
Massimo's example gets you roughly the same result. Having a constant or an 
alias is pretty much the same.


[web2py] Re: get last visited page

2011-05-24 Thread Mathew Grabau
Is the back track contained to inside the app or including sites
external to your app?

On May 24, 10:34 am, Richard Vézina ml.richard.vez...@gmail.com
wrote:
 Hello,

 I would like to know if there is a built vars to know what was the last page
 a user had visited?

 I would like to build a basic navigation bar that will contain a back button
 and I would like to know what was the last visited page so I could write
 rule for different view depending from where the user come from the back
 button will redirect at the rigth place.

 Thanks

 Richard


Re: [web2py] get last visited page

2011-05-24 Thread Richard Vézina
I thougth this :

In view I can get active url or function or what ever... :

{{session.last_visited_url=request.url}}

Last visited url : {{=session.last_visited_url}}


But then I would need to actualize these session variables on any events
that when the user make action... But I am blocked if the user use the
navigator button...

Richard

On Tue, May 24, 2011 at 12:14 PM, pbreit pbreitenb...@gmail.com wrote:

 Request.ENV.referer but it's not super reliable.


Re: [web2py] Re: get last visited page

2011-05-24 Thread Richard Vézina
Just inside tracking is enough.

Richard

On Tue, May 24, 2011 at 12:21 PM, Mathew Grabau mgra...@seccuris.comwrote:

 Is the back track contained to inside the app or including sites
 external to your app?

 On May 24, 10:34 am, Richard Vézina ml.richard.vez...@gmail.com
 wrote:
  Hello,
 
  I would like to know if there is a built vars to know what was the last
 page
  a user had visited?
 
  I would like to build a basic navigation bar that will contain a back
 button
  and I would like to know what was the last visited page so I could write
  rule for different view depending from where the user come from the
 back
  button will redirect at the rigth place.
 
  Thanks
 
  Richard



Re: [web2py] get last visited page

2011-05-24 Thread ron_m
a href=javascript:void(history.go(-1))img src={{URL('static', 
)}}/a

puts an image link that simulates the back button on the page. You could 
convert it to button and use the jQuery alternative

Too much of a hack? The web2py framework is very good with history 
integration.


Re: [web2py] get last visited page

2011-05-24 Thread pbreit
You could put this at the top of your controller files (outside a def():) 
and it would happen on every page visit:

session.last_visited_url=request.url


[web2py] Re: How to make a constant for list of fields in select()?

2011-05-24 Thread pbreit
Ah, cool, thanks. I always wondered what * and ** were for. Since my only 
formal computer education was C I was frightened they were pointers!

[web2py] Re: [1/2 OT] Access Control

2011-05-24 Thread pbreit
If your PHP code has no access control then, yes, people will just be able 
to copy/paste URLs to gain access and I'm not sure Web2py can help you out.

But you should be able to set up passwords on the web server. For example, 
Cherokee: http://www.cherokee-project.com/doc/modules_validators.html


Re: [web2py] get last visited page

2011-05-24 Thread Richard Vézina
Thanks for the hint pbreit!

I think the : javascript:void(history.go(-1)) will do it for now...

Thanks all for your help.

Richard

On Tue, May 24, 2011 at 12:42 PM, pbreit pbreitenb...@gmail.com wrote:

 You could put this at the top of your controller files (outside a def():)
 and it would happen on every page visit:

 session.last_visited_url=request.url



[web2py] Strange Flashing of Elements

2011-05-24 Thread David J.

Hi List,

I was wondering why I see the css 'hidden' elements flash quickly on the 
page when the page is reloaded; then do the animation?


For example when I submit an invalid form I see the hidden form error 
fields flash quickly then disappear then do the normal animation.


I was wondering if maybe I did something to the default css that is 
causing this problem.


Thanks.

David.




[web2py] Problem storing Storage objects in sessions

2011-05-24 Thread Ross Peoples
For whatever reason, after running for 24 hours, web2py throws an exception 
when trying to log in. I have to stop web2py, and restart it, then the error 
goes away and my application starts working again. Any ideas?

Traceback (most recent call last):
  File /media/psf/Python/web2py/gluon/main.py, line 511, in wsgibase
session._try_store_on_disk(request, response)
  File /media/psf/Python/web2py/gluon/globals.py, line 469, in 
_try_store_on_disk
cPickle.dump(dict(self), response.session_file)
PicklingError: Can't pickle class 'gluon.storage.Storage': it's not the same 
object as gluon.storage.Storage



[web2py] Re: Strange Flashing of Elements

2011-05-24 Thread Ross Peoples
Some elements are set to display: none, like the .flash and .hidden CSS 
classs. The reason for this is to prevent exactly what you are describing. 
You don't want those elements to be displayed before JavaScript has a chance 
to load. Once the page is fully loaded, then JavaScript makes these elements 
visible.

Re: [web2py] Re: Strange Flashing of Elements

2011-05-24 Thread David J.

Thanks Ross;

So I suspect because I changed it to 'block' its flashing quickly;

But I made the element a block so perhaps I have to write another div 
around the element to make it display correctly.


Thanks.

On 5/24/11 1:16 PM, Ross Peoples wrote:
Some elements are set to display: none, like the .flash and .hidden 
CSS classs. The reason for this is to prevent exactly what you are 
describing. You don't want those elements to be displayed before 
JavaScript has a chance to load. Once the page is fully loaded, then 
JavaScript makes these elements visible. 




[web2py] Trouble updating with SQLFORM.factory and two tables

2011-05-24 Thread Ross Peoples
I am trying to make a user editor and running into trouble. I have the 
standard auth_user table, and I also have an auth_user_extended table that 
stores a bunch of other information, using auth_user as the reference 
between the two tables. I set my controller up like this:

def update():
id = request.vars.id or request.args(0) or error()
row = db((db.auth_user.id==db.auth_user_extended.id)  
(db.auth_user.id==id)).select().first()
if row is None:
error()

form = SQLFORM.factory(db.auth_user, db.auth_user_extended
hidden: {'id': id}
)

form.vars.id = id
form.vars.auth_user = id
form.vars.username = row.auth_user.username
form.vars.first_name = row.auth_user.first_name
... etc ...

if form.accepts(request.vars, session, keepvalues=True):
# do the database update manually

However, my problem is that when submitting the form for an update, it fails 
validation on username because value already in database. Am I doing 
something wrong or does SQLFORM.factory not support updates? Thanks.


Re: [web2py] Trouble updating with SQLFORM.factory and two tables

2011-05-24 Thread contatogilson...@gmail.com
I use like this: http://web2pyslices.com/main/slices/take_slice/133
_
*Gilson Filho*
*Web Developer
http://gilsondev.com*



2011/5/24 Ross Peoples ross.peop...@gmail.com

 I am trying to make a user editor and running into trouble. I have the
 standard auth_user table, and I also have an auth_user_extended table that
 stores a bunch of other information, using auth_user as the reference
 between the two tables. I set my controller up like this:

 def update():
 id = request.vars.id or request.args(0) or error()
 row = db((db.auth_user.id==db.auth_user_extended.id)  (
 db.auth_user.id==id)).select().first()
 if row is None:
 error()

 form = SQLFORM.factory(db.auth_user, db.auth_user_extended
 hidden: {'id': id}
 )

 form.vars.id = id
 form.vars.auth_user = id
 form.vars.username = row.auth_user.username
 form.vars.first_name = row.auth_user.first_name
 ... etc ...

 if form.accepts(request.vars, session, keepvalues=True):
 # do the database update manually

 However, my problem is that when submitting the form for an update, it
 fails validation on username because value already in database. Am I doing
 something wrong or does SQLFORM.factory not support updates? Thanks.



Re: [web2py] Trouble updating with SQLFORM.factory and two tables

2011-05-24 Thread Ross Peoples
So you basically do:

form = SQLFORM(db.auth_user, id)
form2 = SQLFORM(db.auth_user_extended, row.auth_user_extended.id)

form.append(form2)

Interesting. I'll have to give this a shot...thanks!


[web2py] trunk - missing 'reset_password' in Auth.__call__ in tools.py

2011-05-24 Thread Carlos
Hi,

The 'reset_password' option is missing in tools.py, line # 1048 in 
Auth.__call__.

   Carlos



Re: [web2py] trunk - missing 'reset_password' in Auth.__call__ in tools.py

2011-05-24 Thread contatogilson...@gmail.com
I don't understand. Show me the code.
_
*Gilson Filho*
*Web Developer
http://gilsondev.com*



2011/5/24 Carlos carlosgali...@gmail.com

 Hi,

 The 'reset_password' option is missing in tools.py, line # 1048 in
 Auth.__call__.

Carlos




Re: [web2py] trunk - missing 'reset_password' in Auth.__call__ in tools.py

2011-05-24 Thread Carlos
Hi,

The missing 'reset_password' option is shown in the below code ...

def __call__(self):

usage:

def authentication(): return dict(form=auth())


request = current.request
args = request.args
if not args:
redirect(self.url(args='login',vars=request.vars))
elif args[0] in self.settings.actions_disabled:
raise HTTP(404)
if args[0] in ('login','logout','register','verify_email',
   'retrieve_username','retrieve_password',
   'reset_password', 
'request_reset_password','change_password',
   'profile','groups','impersonate','not_authorized',
   'cas_login','cas_check'):
return getattr(self,args[0])()
else:
raise HTTP(404)

Regards,

   Carlos



Re: [web2py] Trouble updating with SQLFORM.factory and two tables

2011-05-24 Thread Ross Peoples
This is the code I have:

form = SQLFORM(db.auth_user, row.auth_user)
form.append(SQLFORM(db.auth_user_extended, row.auth_user_extended))

My view requires that I manually build the form, and for some reason, when I 
look at the resulting form object via PDB, the form object has two items:

gluon.html.TABLE object at 0
gluon.sqlhtml.SQLFORM object at 0

So when I call form.fields, it only returns the auth_user fields. I actually 
have to call form[1].fields to get auth_user_extended fields. Is this right?


Re: [web2py] Trouble updating with SQLFORM.factory and two tables

2011-05-24 Thread Ross Peoples
I've gotten much closer with this, however, I am still hitting a snag:

One of the fields in my auth_user_extended is set to 
requires=IS_NOT_IN_DB(). And when form.accepts is called, I'm still getting 
a value already in database error.


[web2py] Re: Trouble updating with SQLFORM.factory and two tables

2011-05-24 Thread pbreit
Is this the right comparison?

db.auth_user.id==db.auth_user_extended.id

In another post you have:

db.define_table('auth_user_extended',
  Field('auth_user', db.auth_user),

Which means the relation is db.auth_user.id==db.auth_user_extended.auth_user


Re: [web2py] trunk - missing 'reset_password' in Auth.__call__ in tools.py

2011-05-24 Thread pbreit
reset_password is deprecated:
http://code.google.com/p/web2py/source/browse/gluon/tools.py#1929


[web2py] Re: Problem storing Storage objects in sessions

2011-05-24 Thread pbreit
Do you have any logs running, background processes, cron jobs? Are you doing 
any caching to disk?

[web2py] Re: Problem storing Storage objects in sessions

2011-05-24 Thread pbreit
Also, check your sessions folder to see if it's getting filled up.

Re: [web2py] trunk - missing 'reset_password' in Auth.__call__ in tools.py

2011-05-24 Thread Carlos
ok, good to know - thanks!

Re: [web2py] trunk - missing 'reset_password' in Auth.__call__ in tools.py

2011-05-24 Thread Carlos
Wait, immediately after reset_password_deprecated, there's a reset_password:

http://code.google.com/p/web2py/source/browse/gluon/tools.py#2010

Also, if reset_password is effectively deprecated, then what should I use to 
replace the behavior in /user/request_reset_password ?.

Please clarify - thanks,

   Carlos



Re: [web2py] trunk - missing 'reset_password' in Auth.__call__ in tools.py

2011-05-24 Thread pbreit
Possibly for backwards compatibility? Are you getting some sort of error or 
experiencing a problem?

[web2py] Another interesting NoSQL DB: ThriftDB

2011-05-24 Thread pbreit
Another interesting NoSQL DB: ThriftDB. Especially for search.

http://www.thriftdb.com/


[web2py] teaching email links to respect https

2011-05-24 Thread Andrew Thompson
Does this seem like a reasonable way to handle the 
auth.messages.verify_email/reset_password links?


if request.env.https == 'on':
  url_prefix = 'https'
else:
  url_prefix = 'http'
auth.messages.verify_email = 'Click on the link 
'+url_prefix+'://'+request.env.http_host+URL(r=request,c='default',f='user',args=['verify_email'])+'/%(key)s 
to verify your email'

auth.settings.reset_password_requires_verification = True
auth.messages.reset_password = 'Click on the link 
'+url_prefix+'://'+request.env.http_host+URL(r=request,c='default',f='user',args=['reset_password'])+'/%(key)s 
to reset your password'


--
Andrew Thompson
http://aktzero.com/



[web2py] Re: teaching email links to respect https

2011-05-24 Thread pbreit
Does request.env.https exist? I don't see it in my environment.

I don't think https is necessary for those links. And if it is, your web 
server or code should be enforcing SSL on the URLs.


Re: [web2py] trunk - missing 'reset_password' in Auth.__call__ in tools.py

2011-05-24 Thread Carlos
Yes, I'm getting errors.

When I go to the lost password? link, user/request_reset_password is 
called, which on submit sends an email message with the following link:

... user/reset_password/*

And when this link is clicked, I get a 404 (Not Found) error.

This can be fixed by adding 'reset_password' to the list I describe in my 
original message.

Furthermore, if this is to be deprecated, then what's the new way to reset 
passwords?.

Thanks,

   Carlos



Re: [web2py] trunk - missing 'reset_password' in Auth.__call__ in tools.py

2011-05-24 Thread pbreit
Yeah, you might be right. It looks like it was dropped in this changeset:
http://code.google.com/p/web2py/source/detail?r=f2c246ff0367b235d3e057c42a9cdf743c5ee3bapath=/gluon/tools.py

Not sure if by accident or on purpose. Massimo may need to weigh in.


Re: [web2py] Re: teaching email links to respect https

2011-05-24 Thread Andrew Thompson

On 5/24/2011 5:02 PM, pbreit wrote:

Does  request.env.https exist? I don't see it in my environment.


It does for me, running web2py behind lighttpd.

I also found a reference to request.env.wsgi_url_scheme, but I wasn't 
sure if it's content could be 99+% predicted.


http://comments.gmane.org/gmane.comp.python.web2py/44684



I don't think https is necessary for those links. And if it is, your 
web server or code should be enforcing SSL on the URLs.

That'd work too. My dev sites exist only as https sites, zero http access.

--
Andrew Thompson
http://aktzero.com/



Re: [web2py] Problem storing Storage objects in sessions

2011-05-24 Thread Jonathan Lundell
Reading this makes my head hurt, but I wonder if it might not also apply to 
web2py: 
http://code.google.com/p/modwsgi/wiki/IssuesWithPickleModule

If so, I can think of some ugly workarounds. 

On May 24, 2011, at 12:13 PM, Ross Peoples ross.peop...@gmail.com wrote:

 For whatever reason, after running for 24 hours, web2py throws an exception 
 when trying to log in. I have to stop web2py, and restart it, then the error 
 goes away and my application starts working again. Any ideas?
 
 Traceback (most recent call last):
   File /media/psf/Python/web2py/gluon/main.py, line 511, in wsgibase
 session._try_store_on_disk(request, response)
   File /media/psf/Python/web2py/gluon/globals.py, line 469, in 
 _try_store_on_disk
 cPickle.dump(dict(self), response.session_file)
 PicklingError: Can't pickle class 'gluon.storage.Storage': it's not the 
 same object as gluon.storage.Storage


[web2py] Re: Problem storing Storage objects in sessions

2011-05-24 Thread Massimo Di Pierro
This does apply to web2py. In fact I believe the book says something
like this quote from the article

In order to ensure that no strange problems at all are likely to
occur, it is suggested that only basic builtin Python types, ie.,
scalars, tuples, lists and dictionaries, be stored using the pickle
module from a WSGI application script file. That is, avoid any type of
object which has user defined code associated with it.

Do we know that the new importer does not conflict with the custom
mod_wsgi import mechanism described in the article? Has anybody tried
trunk with mod_wsgi?

Massimo

On May 24, 4:42 pm, Jonathan Lundell jlund...@pobox.com wrote:
 Reading this makes my head hurt, but I wonder if it might not also apply to 
 web2py:http://code.google.com/p/modwsgi/wiki/IssuesWithPickleModule

 If so, I can think of some ugly workarounds.

 On May 24, 2011, at 12:13 PM, Ross Peoples ross.peop...@gmail.com wrote:







  For whatever reason, after running for 24 hours, web2py throws an exception 
  when trying to log in. I have to stop web2py, and restart it, then the 
  error goes away and my application starts working again. Any ideas?

  Traceback (most recent call last):
    File /media/psf/Python/web2py/gluon/main.py, line 511, in wsgibase
      session._try_store_on_disk(request, response)
    File /media/psf/Python/web2py/gluon/globals.py, line 469, in 
  _try_store_on_disk
      cPickle.dump(dict(self), response.session_file)
  PicklingError: Can't pickle class 'gluon.storage.Storage': it's not the 
  same object as gluon.storage.Storage


[web2py] Re: teaching email links to respect https

2011-05-24 Thread Massimo Di Pierro
In trunk we have

request.is_https

Massimo

On May 24, 4:33 pm, Andrew Thompson andre...@aktzero.com wrote:
 On 5/24/2011 5:02 PM, pbreit wrote:

  Does  request.env.https exist? I don't see it in my environment.

 It does for me, running web2py behind lighttpd.

 I also found a reference to request.env.wsgi_url_scheme, but I wasn't
 sure if it's content could be 99+% predicted.

 http://comments.gmane.org/gmane.comp.python.web2py/44684



  I don't think https is necessary for those links. And if it is, your
  web server or code should be enforcing SSL on the URLs.

 That'd work too. My dev sites exist only as https sites, zero http access.

 --
 Andrew Thompsonhttp://aktzero.com/


[web2py] Re: teaching email links to respect https

2011-05-24 Thread Anthony
On Tuesday, May 24, 2011 6:34:15 PM UTC-4, Massimo Di Pierro wrote: 

 In trunk we have 

 request.is_https

 
Which checks whether request.env.wsgi_url_scheme is https (or HTTPS) or 
request.env.https is on.
 


[web2py] Re: Problem storing Storage objects in sessions

2011-05-24 Thread Anthony
Yes, in http://web2py.com/book/default/chapter/09#Custom-Formats, the book 
says:
 

Not all objects are pickleable, and not all pickled objects can be un-
pickled. It is safe to stick to primitive Python objects and combinations of 
them. Objects that do not contain references to file streams or database 
connections are usually pickleable, but they can only be un-pickled in an 
environment where the classes of all pickled objects are already defined.

 

On Tuesday, May 24, 2011 6:29:10 PM UTC-4, Massimo Di Pierro wrote:

 This does apply to web2py. In fact I believe the book says something 
 like this quote from the article 

 In order to ensure that no strange problems at all are likely to 
 occur, it is suggested that only basic builtin Python types, ie., 
 scalars, tuples, lists and dictionaries, be stored using the pickle 
 module from a WSGI application script file. That is, avoid any type of 
 object which has user defined code associated with it. 

 Do we know that the new importer does not conflict with the custom 
 mod_wsgi import mechanism described in the article? Has anybody tried 
 trunk with mod_wsgi? 

 Massimo 

 On May 24, 4:42 pm, Jonathan Lundell jlun...@pobox.com wrote: 
  Reading this makes my head hurt, but I wonder if it might not also apply 
 to web2py:http://code.google.com/p/modwsgi/wiki/IssuesWithPickleModule 
  
  If so, I can think of some ugly workarounds. 
  
  On May 24, 2011, at 12:13 PM, Ross Peoples ross.p...@gmail.com wrote: 
  
  
  
  
  
  
  
   For whatever reason, after running for 24 hours, web2py throws an 
 exception when trying to log in. I have to stop web2py, and restart it, then 
 the error goes away and my application starts working again. Any ideas? 
  
   Traceback (most recent call last): 
 File /media/psf/Python/web2py/gluon/main.py, line 511, in wsgibase 
   session._try_store_on_disk(request, response) 
 File /media/psf/Python/web2py/gluon/globals.py, line 469, in 
 _try_store_on_disk 
   cPickle.dump(dict(self), response.session_file) 
   PicklingError: Can't pickle class 'gluon.storage.Storage': it's not 
 the same object as gluon.storage.Storage



[web2py] xml to string or json

2011-05-24 Thread Resa
Specifically i have data that is in XML (grade) in my controller and i
wanted to parse it. eg grade.find(.).. however this would clearly
not work.. are there any suggestions as to how i can convert this XML
data in the controller to a format that is parse-able


Re: [web2py] Re: alias field names

2011-05-24 Thread Vinicius Assef
Right, pbreit.

But if it could be addressed by the DAL, it would demand less
programmer's effort and DRY would be an ally.

I vote for an alias param in Field(). Who is in?

Just a suggestion.

--
Vinicius Assef.


On Tue, May 24, 2011 at 1:13 PM, pbreit pbreitenb...@gmail.com wrote:
 Massimo's example gets you roughly the same result. Having a constant or an 
 alias is pretty much the same.


Re: [web2py] Re: alias field names

2011-05-24 Thread Richard Baron Penman
On Wed, May 25, 2011 at 1:50 AM, Vinicius Assef vinicius...@gmail.comwrote:

 I didn't understand your space reasons


see first post


Re: [web2py] Re: alias field names

2011-05-24 Thread Richard Baron Penman
On Wed, May 25, 2011 at 2:13 AM, pbreit pbreitenb...@gmail.com wrote:

 Massimo's example gets you roughly the same result.


so are you saying this would work too?

db.table_name.my_descriptive_field_name = db.table_name.a


 Having a constant or an alias is pretty much the same.


main drawback is additional global variables, which may accidentally be
overridden elsewhere


[web2py] Re: Another interesting NoSQL DB: ThriftDB

2011-05-24 Thread DenesL

Currently, ThriftDB is offered as a hosted service at
api.thriftdb.com but we are working on a way for developers to run
ThriftDB locally.
but otherwise looks good.


On May 24, 4:48 pm, pbreit pbreitenb...@gmail.com wrote:
 Another interesting NoSQL DB: ThriftDB. Especially for search.

 http://www.thriftdb.com/


[web2py] Dynamic Table Generation

2011-05-24 Thread Ialejandro
Hi everyone, I'm trying to make an app where a user can create its own
tables bases in some attributes, I have this:

View:

{{extend 'layout.html'}}

form enctype=multipart/form-data
  action={{=URL()}} method=post
Project Name:
input name=projname /
br /Number Of Fields:
input name=numfields /
br /Name of Fields:
input name=namfields /
br /input type=submit /
/form
h2Submitted variables/h2
{{=BEAUTIFY(request.vars)}}


Controller:

def config():

if request.vars:
proj_name = session.projname = request.vars.projname
num_fields= session.numfields= request.vars.numfields
nam_fields= session.namfields= request.vars.namfields

tblname = proj_name + _custom
response.flash = tblname


createtable(tblname)

return dict()


And in utils.py (inside models folder)

def createtable(tablename):
tbl = db.define_table(tablename,Field('a'))


But it doesn't work :(
The form works, I can get the variables by request.vars, but the table
is not created, how could I create dynamic tables??
If an user needs a table called project1 with 2 fields F1 and F2
and another user needs more different fields and table name, how could
I make this??

Thanks!


[web2py] Re: xml to string or json

2011-05-24 Thread DenesL

elementTree is an option, available in Python itself, depending on
your version.

On May 24, 7:03 pm, Resa taratbr...@gmail.com wrote:
 Specifically i have data that is in XML (grade) in my controller and i
 wanted to parse it. eg grade.find(.).. however this would clearly
 not work.. are there any suggestions as to how i can convert this XML
 data in the controller to a format that is parse-able


[web2py] Re: Dynamic Table Generation

2011-05-24 Thread DenesL

The problem is that you are not saving your model (the table
definitions) and web2py starts from scratch on every request, so your
table is being created in the DB but web2py does not know about it.
That is what models do, they define the tables that are visible in
web2py.

Save that db.define_table... code in a file under the models folder,
then web2py will pick it up on all subsequent requests.


On May 24, 8:39 pm, Ialejandro ialejandr...@gmail.com wrote:
 Hi everyone, I'm trying to make an app where a user can create its own
 tables bases in some attributes, I have this:

 View:

 {{extend 'layout.html'}}

 form enctype=multipart/form-data
       action={{=URL()}} method=post
 Project Name:
 input name=projname /
 br /Number Of Fields:
 input name=numfields /
 br /Name of Fields:
 input name=namfields /
 br /input type=submit /
 /form
 h2Submitted variables/h2
 {{=BEAUTIFY(request.vars)}}

 Controller:

 def config():

     if request.vars:
         proj_name = session.projname = request.vars.projname
         num_fields= session.numfields= request.vars.numfields
         nam_fields= session.namfields= request.vars.namfields

         tblname = proj_name + _custom
         response.flash = tblname

         createtable(tblname)

     return dict()

 And in utils.py (inside models folder)

 def createtable(tablename):
     tbl = db.define_table(tablename,Field('a'))

 But it doesn't work :(
 The form works, I can get the variables by request.vars, but the table
 is not created, how could I create dynamic tables??
 If an user needs a table called project1 with 2 fields F1 and F2
 and another user needs more different fields and table name, how could
 I make this??

 Thanks!


Re: [web2py] Re: Plugin wiki attachaments not working

2011-05-24 Thread Tito Garrido
It's working now... thanks!

On Tue, May 24, 2011 at 10:20 AM, Massimo Di Pierro 
massimo.dipie...@gmail.com wrote:

 Please try download it again. I think I fixed it.
 In any case there will be a new version of plugin wiki next week. The
 current one has a vulnerability in jqgrid.

 On May 24, 7:23 am, Tito Garrido titogarr...@gmail.com wrote:
  Yes, I got the latest last night
 
  On Mon, May 23, 2011 at 11:41 PM, Massimo Di Pierro 
 
 
 
 
 
 
 
 
 
  massimo.dipie...@gmail.com wrote:
   This should be fixed in plugin wiki. Do you have the latest?
 
   Mind that I do not promise backward compatibility for plugin-wiki but
   I try to update it as web2py core changes.
 
   Massimo
 
   On May 23, 6:13 pm, Tito Garrido titogarr...@gmail.com wrote:
Is it expected?
 
On Sun, May 22, 2011 at 4:02 PM, Tito Garrido titogarr...@gmail.com
 
   wrote:
 web2py™ Version 1.96.0 (2011-05-22 09:34:40)  Python Python 2.6.1:
 /usr/bin/python  Traceback
 
 1.
 2.
 3.
 4.
 5.
 6.
 7.
 8.
 9.
 10.
 
 Traceback (most recent call last):
   File
   /Users/titogarrido/Documents/Projetos/web2py/gluon/restricted.py,
 line
   184, in restricted
 
 exec ccode in environment
   File
  
 /Users/titogarrido/Documents/Projetos/web2py/applications/secmon/views/plu
   gin_wiki/attachments.html, line 67, in module
 
   File /Users/titogarrido/Documents/Projetos/web2py/gluon/dal.py,
   line 3656, in __getattr__
 
 return self[key]
   File /Users/titogarrido/Documents/Projetos/web2py/gluon/dal.py,
   line 3647, in __getitem__
 
 return dict.__getitem__(self, key)
 
 KeyError: 'file'
 
--
 
Linux User #387870
.
 _/_õ|__|
..º[ .-.___.-._| . . . .
.__( o)__( o).:___
 
  --
 
  Linux User #387870
  .
   _/_õ|__|
  ..º[ .-.___.-._| . . . .
  .__( o)__( o).:___




-- 

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


[web2py] How to use plugin_wiki mediaplayer widget

2011-05-24 Thread Tito Garrido
I've tried:
``
name: mediaplayer
src: http://127.0.0.1:8000/secmon/plugin_wiki/attachment/2
width: 400
height: 250
``:widget

``
name: mediaplayer
src: attachment:2.flv
width: 400
height: 250
``:widget


but neither worked... what am I doing wrong?

-- 

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


Re: [web2py] Re: plugins for plugin_wiki

2011-05-24 Thread Tito Garrido
How to install it?

On Tue, May 10, 2011 at 12:12 PM, Pablo Angulo pablo.ang...@uam.es wrote:

 I'm attaching the web2py code for the two widgets, and a zip file that
 may not pass the mailing list filter. It contains the javascript and css
 libraries. You can also find it at:

 http://web.uam.es/personal_pdi/ciencias/pangulo/etc/plugin_wiki_extra.zip




-- 

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


[web2py] reponse.js Update 2 Targets.

2011-05-24 Thread David J.

I was wondering how I can update 2 targets with reponse.js?

I tried this

response.js = 
'web2py_component(url,target);web2py_component(other_url,other_target);'


Seems only the first updated.

Any ideas?




Re: [web2py] Dynamic Table Generation

2011-05-24 Thread Stifan Kristi
i think the logic is same like wizard, have you tried it?

On Wed, May 25, 2011 at 7:39 AM, Ialejandro ialejandr...@gmail.com wrote:

 Hi everyone, I'm trying to make an app where a user can create its own
 tables bases in some attributes, I have this:

 View:

 {{extend 'layout.html'}}

 form enctype=multipart/form-data
  action={{=URL()}} method=post
 Project Name:
 input name=projname /
 br /Number Of Fields:
 input name=numfields /
 br /Name of Fields:
 input name=namfields /
 br /input type=submit /
 /form
 h2Submitted variables/h2
 {{=BEAUTIFY(request.vars)}}


 Controller:

 def config():

if request.vars:
proj_name = session.projname = request.vars.projname
num_fields= session.numfields= request.vars.numfields
nam_fields= session.namfields= request.vars.namfields

tblname = proj_name + _custom
response.flash = tblname


createtable(tblname)

return dict()


 And in utils.py (inside models folder)

 def createtable(tablename):
tbl = db.define_table(tablename,Field('a'))


 But it doesn't work :(
 The form works, I can get the variables by request.vars, but the table
 is not created, how could I create dynamic tables??
 If an user needs a table called project1 with 2 fields F1 and F2
 and another user needs more different fields and table name, how could
 I make this??

 Thanks!


[web2py] db.table.insert() doesn't always validate data types? (Bug?)

2011-05-24 Thread Brian M
I just found what might be a bug, when using db.table.insert(field = value) 
it appears that the type of value isn't checked against the declared type of 
field. So for example you can declare a field to be of the date type, but 
then insert a record with a non-date value (at least in sqlite).  I would 
have expected the DAL to give an error when attempting to do something like 
this, but it does not. However, when you then attempt to retrieve the 
inserted record, an error does occur.  If you separate the db insert from 
the retrieval query and check in the database, you can see that invalid 
data has been stored in the database.

Granted, if you're using forms  validators then the data type conflict is 
caught before the insert, but I thought it may be something that should be 
pointed out - it isn't enough just to define data types in your model  
expect web2py to always automatically enforce them.

Sample Code:

model.py
---
db.define_table('mytable',
Field('a_date_field', 'date')
)

controllers/default.py

def date_insert():
my_date = '05/24/2011' #note, this is a string not a date type.  Should 
have done datetime.strptime('05/24/2011','%m/%d/%Y) or date(2011,5,24)

record = db.mytable.insert(a_date_field = my_date)

results = db(db.mytable.id0).select()
   
return dict(results = results, record = record)

Error Ticket:
-

Traceback (most recent call last):
  File C:\Users\Brian\Documents\development\web2py\stable\web2py_src 
(1.95.1)\web2py\gluon\restricted.py, line 181, in restricted
exec ccode in environment
  File C:/Users/Brian/Documents/development/web2py/stable/web2py_src 
(1.95.1)/web2py/applications/date_test/controllers/default.py 
http://localhost:8000/admin/default/edit/date_test/controllers/default.py, 
line 80, in module
  File C:\Users\Brian\Documents\development\web2py\stable\web2py_src 
(1.95.1)\web2py\gluon\globals.py, line 133, in lambda
self._caller = lambda f: f()
  File C:/Users/Brian/Documents/development/web2py/stable/web2py_src 
(1.95.1)/web2py/applications/date_test/controllers/default.py 
http://localhost:8000/admin/default/edit/date_test/controllers/default.py, 
line 41, in date_insert_test
results = db(db.mytable.id0).select()
  File C:\Users\Brian\Documents\development\web2py\stable\web2py_src 
(1.95.1)\web2py\gluon\dal.py, line 5164, in select
return self.db._adapter.select(self.query,fields,attributes)
  File C:\Users\Brian\Documents\development\web2py\stable\web2py_src 
(1.95.1)\web2py\gluon\dal.py, line 1082, in select
return self.parse(rows,self._colnames)
  File C:\Users\Brian\Documents\development\web2py\stable\web2py_src 
(1.95.1)\web2py\gluon\dal.py, line 1291, in parse
str(value)[:10].strip().split('-')]
ValueError: invalid literal for int() with base 10: '05/24/2011'



[web2py] Re: Cubrid?

2011-05-24 Thread CUBRID RDBMS
CUBRID Python 8.4.0 driver for Python 2.7, 2.6 are also uploaded. Like I 
said, the API docs and release notes will be ready at the beginning of June.

[web2py] Re: db.table.insert() doesn't always validate data types? (Bug?)

2011-05-24 Thread Massimo Di Pierro
insert NEVER validates data types. FORMs and SQLFORMs validate input.
That is for speed.

You can call

r = db.table.validate_and_insert(**fields)

which returns r.id and r.errors

On May 24, 8:47 pm, Brian M bmere...@gmail.com wrote:
 I just found what might be a bug, when using db.table.insert(field = value)
 it appears that the type of value isn't checked against the declared type of
 field. So for example you can declare a field to be of the date type, but
 then insert a record with a non-date value (at least in sqlite).  I would
 have expected the DAL to give an error when attempting to do something like
 this, but it does not. However, when you then attempt to retrieve the
 inserted record, an error does occur.  If you separate the db insert from
 the retrieval query and check in the database, you can see that invalid
 data has been stored in the database.

 Granted, if you're using forms  validators then the data type conflict is
 caught before the insert, but I thought it may be something that should be
 pointed out - it isn't enough just to define data types in your model 
 expect web2py to always automatically enforce them.

 Sample Code:

 model.py
 ---
 db.define_table('mytable',
     Field('a_date_field', 'date')
     )

 controllers/default.py
 
 def date_insert():
     my_date = '05/24/2011' #note, this is a string not a date type.  Should
 have done datetime.strptime('05/24/2011','%m/%d/%Y) or date(2011,5,24)

     record = db.mytable.insert(a_date_field = my_date)        

     results = db(db.mytable.id0).select()

     return dict(results = results, record = record)

 Error Ticket:
 -

 Traceback (most recent call last):
   File C:\Users\Brian\Documents\development\web2py\stable\web2py_src 
 (1.95.1)\web2py\gluon\restricted.py, line 181, in restricted
     exec ccode in environment
   File C:/Users/Brian/Documents/development/web2py/stable/web2py_src 
 (1.95.1)/web2py/applications/date_test/controllers/default.py 
 http://localhost:8000/admin/default/edit/date_test/controllers/defaul..., 
 line 80, in module
   File C:\Users\Brian\Documents\development\web2py\stable\web2py_src 
 (1.95.1)\web2py\gluon\globals.py, line 133, in lambda
     self._caller = lambda f: f()
   File C:/Users/Brian/Documents/development/web2py/stable/web2py_src 
 (1.95.1)/web2py/applications/date_test/controllers/default.py 
 http://localhost:8000/admin/default/edit/date_test/controllers/defaul..., 
 line 41, in date_insert_test
     results = db(db.mytable.id0).select()
   File C:\Users\Brian\Documents\development\web2py\stable\web2py_src 
 (1.95.1)\web2py\gluon\dal.py, line 5164, in select
     return self.db._adapter.select(self.query,fields,attributes)
   File C:\Users\Brian\Documents\development\web2py\stable\web2py_src 
 (1.95.1)\web2py\gluon\dal.py, line 1082, in select
     return self.parse(rows,self._colnames)
   File C:\Users\Brian\Documents\development\web2py\stable\web2py_src 
 (1.95.1)\web2py\gluon\dal.py, line 1291, in parse
     str(value)[:10].strip().split('-')]
 ValueError: invalid literal for int() with base 10: '05/24/2011'


[web2py] Re: reponse.js Update 2 Targets.

2011-05-24 Thread Massimo Di Pierro
There is no reason why it should not work. Are you using trunk? There
was in bug in stable about response.js.

On May 24, 8:25 pm, David J. da...@styleflare.com wrote:
 I was wondering how I can update 2 targets with reponse.js?

 I tried this

 response.js =
 'web2py_component(url,target);web2py_component(other_url,other_target);'

 Seems only the first updated.

 Any ideas?


Re: [web2py] Re: Problem storing Storage objects in sessions

2011-05-24 Thread Jonathan Lundell
On May 24, 2011, at 5:58 PM, Anthony wrote:
 Yes, in http://web2py.com/book/default/chapter/09#Custom-Formats, the book 
 says:
  
 Not all objects are pickleable, and not all pickled objects can be 
 un-pickled. It is safe to stick to primitive Python objects and combinations 
 of them. Objects that do not contain references to file streams or database 
 connections are usually pickleable, but they can only be un-pickled in an 
 environment where the classes of all pickled objects are already defined.
 

The session Storage object itself is copied to a dictionary before pickling; 
it'd be reasonable to do that (and the equivalent for List) for Storage objects 
stored in the session.



Re: [web2py] Re: teaching email links to respect https

2011-05-24 Thread Jonathan Lundell
On May 24, 2011, at 5:47 PM, Anthony wrote:
 On Tuesday, May 24, 2011 6:34:15 PM UTC-4, Massimo Di Pierro wrote:
 In trunk we have 
 
 request.is_https
  
 Which checks whether request.env.wsgi_url_scheme is https (or HTTPS) or 
 request.env.https is on.
 

...and of course doesn't necessarily tell the truth in a proxied installation.

Re: [web2py] Re: teaching email links to respect https

2011-05-24 Thread pbreit
It might not be 100%. For example, on Nginx, you have to include this 
config:

uwsgi_param UWSGI_SCHEME $scheme;

But I still don't really understand why you need this.


Re: [web2py] Re: alias field names

2011-05-24 Thread pbreit
An alias would be global too?

I don't think this would work:
db.table_name.my_descriptive_field_name = db.table_name.a

But these would:
db_table_name_my_descriptive_field_name = db.table_name.a

db_table_name = Storage()
db_table_name.my_descriptive_field_name = db.table_name.a


Re: [web2py] Re: reponse.js Update 2 Targets.

2011-05-24 Thread David J.


I am using Trunk;

Is my syntax correct?

should it be a ',' instead of a ';'

response.js =
'web2py_component(url,target),web2py_component(other_url,other_target);'




On 5/24/11 11:40 PM, Massimo Di Pierro wrote:

There is no reason why it should not work. Are you using trunk? There
was in bug in stable about response.js.

On May 24, 8:25 pm, David J.da...@styleflare.com  wrote:

I was wondering how I can update 2 targets with reponse.js?

I tried this

response.js =
'web2py_component(url,target);web2py_component(other_url,other_target);'

Seems only the first updated.

Any ideas?




[web2py] Re: How to make a constant for list of fields in select()?

2011-05-24 Thread ron_m
Ah C, pointers and pointers to pointers for **
I used to like pointers in C but then I used to work on operating systems 
written in assembler during my early years in computers (70s, early 80s).
Results in a different mindset.


Re: [web2py] Re: alias field names

2011-05-24 Thread Anthony
On Tuesday, May 24, 2011 11:57:00 PM UTC-4, pbreit wrote: 

 An alias would be global too? 

 I don't think this would work:
 db.table_name.my_descriptive_field_name = db.table_name.a

 
As far as I can tell, the above does appear to work, at least for some 
purposes.
 
Anthony