[web2py] Re: Unable to write to file error in GAE

2011-11-07 Thread Joseph Jude
Massimo,
Since it is on GAE, I don't have the full traceback (if there is another 
way to get the traceback, pl let me know). I got only the below two types 
of errors:

routes_out: [/init/default/index] not rewritten

Unable to write to file 
/base/data/home/apps/s~123-check/1.354481446592778594/applications/init/languages/fr-fr.py



Both of these are repeated many times.
Thanks again,
Joseph



[web2py] Re: new web site

2011-11-07 Thread luismurciano
The idea of using their joke is fun, its like a joke inside a joke...

But I really think if Web2py is a Web Framework the Home Page should
be more fancy not too much but it should represents what Web2py can
do.

IMHO the best way to do it is doing a contest and Massimo decides
which one to use. For the web designers in our community be the
designer of the web2py home page can be a big price it self.

I would like to try one my self. You could put the home page app in a
reposotory so any want could clone it and try.

BTW the quotes from http://web2pyramid.pylonsproject.org/ are
hilarious "...one tool to rule them all!"


[web2py] Please help met to see the mistake causing this Valueerror

2011-11-07 Thread Johann Spies
ValueError: invalid literal for int() with base 10: 'abcd'


>From SQLForm.grid, when clicked on the ' View'  button I get the following



When I click on the 'Edit'  button, I get a ticket:

File "/home/js/web2py/gluon/dal.py", line 1378, in represent
return str(int(obj))
ValueError: invalid literal for int() with base 10: 'abcd'



The model clearly states doc_nr as a string:

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

So why does DAL try to convert it to an integer when going to
http://localhost:8000/akb/doccenter/browse/edit/akb_doccenter/9466?_signature=996e7d38423b987884e85c09ae85f2e62f2137b9

Regards
Johann

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


[web2py] Re: Please help met to see the mistake causing this Valueerror

2011-11-07 Thread Johann Spies
Apologies, the screenshot did not show up in the email.  I have attached it
here.

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

[web2py] Re: Please help met to see the mistake causing this Valueerror

2011-11-07 Thread Johann Spies
This also happens in the appadmin interface. A bug perhaps?

I have updated my web2py version from the trunk this morning.

Previously this worked without a problem.

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


Re: [web2py] Re: Problem with using a method from a module

2011-11-07 Thread Sathvik Ponangi
Thank you Bruno!
I added  commons.db = db to my controller to make db globally available in
that module.
Thanks again!

With Regards,
Sathvik

On Mon, Nov 7, 2011 at 10:54 AM, Bruno Rocha  wrote:

>
>
> On Mon, Nov 7, 2011 at 2:55 AM, Sathvik Ponangi wrote:
>
>> Dear Massimo,
>> Restarting AppEngine seems to have fixed this as well.
>> But now I get an error saying that
>>
>>> NameError: global name 'db' is not defined
>>
>> How do import db.py onto the module?
>>
>
> You cant import db onto a module, db is not seriazable.
>
> You have to pass it explicitly to the class instance
>
> class Foo(object):
> def __init__(self, db):
> self.db = db
>
> in controller
>
> from module import Foo
> foo = Foo(db)
>



-- 
Sathvik Ponangi


[web2py] Custom URLs for user profiles

2011-11-07 Thread Sathvik Ponangi
 Is there someway that could display each of my user's profile as a custom
URL like http://my_site.com/user_name ?

I'm using Web2Py(1.99.2_Stable) on GAE (SDKv1.5.5) on Python2.5
-- 
Sathvik Ponangi


[web2py] form.validate().accepted ?

2011-11-07 Thread Vinicius Assef
I tryed this construction:
if form.validate().accepted:
   print "accepted"

But I got this error:
AttributeError: 'NoneType' object has no attribute 'accepted'

In book, chapter 7, "SQLFORM without database IO" section has 2
examples using form.validate().accepted.
Is it an error or didn't I get something?

--
Vinicius Assef.


[web2py] How to add a readonly field in a SQLFORM?

2011-11-07 Thread Vinicius Assef
Hi guys.

I have this construction:

form = SQLFORM(db.my_table,
fields=[
'description',
'date'],
submit_button='Add data')

my_person_data = TR(LABEL('Customer'),
INPUT(value=other_table.customer_id.name, name='customer_name'))
form[0].insert(0, my_person_data)


How can I make the new added field (aka, customer_name) readonly?
I tried to set a writable=False parameter in INPUT, but it didn't worked.

--
Vinicius Assef.


Re: [web2py] Re: Displaying custom error message instead of the ticketing system

2011-11-07 Thread Anthony
On Sunday, November 6, 2011 11:51:23 PM UTC-5, Sathvik Ponangi wrote:
>
> Restarting my AppEngine server has fixed this issue. Thank you all for 
> your help.


Yes, you always need to do a restart whenever you change routes.py. 


[web2py] Re: How to add a readonly field in a SQLFORM?

2011-11-07 Thread Anthony
Have you tried INPUT(..., _readonly="readonly")? That adds an HTML 
"readonly" attribute to the INPUT field, so the readonly display is 
controlled by the browser (it should appear as a regular input field, but 
the value will not be editable). If you just want to display the value 
itself, but not in an input field, then don't use INPUT() at all -- just 
display the value inside the table cell.

Anthony

On Monday, November 7, 2011 7:33:00 AM UTC-5, viniciusban wrote:
>
> Hi guys.
>
> I have this construction:
>
> form = SQLFORM(db.my_table,
> fields=[
> 'description',
> 'date'],
> submit_button='Add data')
>
> my_person_data = TR(LABEL('Customer'),
> INPUT(value=other_table.customer_id.name, name='customer_name'))
> form[0].insert(0, my_person_data)
>
>
> How can I make the new added field (aka, customer_name) readonly?
> I tried to set a writable=False parameter in INPUT, but it didn't worked.
>
> --
> Vinicius Assef.
>
>

[web2py] Re: form.validate().accepted ?

2011-11-07 Thread Anthony
Yes, that's an error in the book. form.validate() returns True or False. 
form.process() returns the form itself, so you have to check the status via 
form.process().accepted.

Anthony

On Monday, November 7, 2011 7:15:54 AM UTC-5, viniciusban wrote:
>
> I tryed this construction:
> if form.validate().accepted:
>print "accepted"
>
> But I got this error:
> AttributeError: 'NoneType' object has no attribute 'accepted'
>
> In book, chapter 7, "SQLFORM without database IO" section has 2
> examples using form.validate().accepted.
> Is it an error or didn't I get something?
>
> --
> Vinicius Assef.
>
>

[web2py] Escaping HTML

2011-11-07 Thread horridohobbyist
Is there a way to insert HTML into a database text field so that when
the text is displayed (say, in a SQLTABLE), the browser renders the
HTML? For example, I insert:

http://psychovisual.com";>Psychovisual.com

into a database text field, but it's not rendered.

Thanks,
Richard


[web2py] Can't get remote read only mysql database to

2011-11-07 Thread Matt Simpson
Hi,

I have been trying to connect to a remote read only mysql database. This is 
an existing production database,  I want to use web2py to display it's data 
graphically .  

I can read from it using  dby.executesql('SELECT * FROM test;') but not 
using  dby().select(dby.test.ALL). 

The example is 
dby = DAL('mysql://guest@10.113.131.67/newdb', pool_size=0)
dby.define_table('test', Field('test_id', 'string'), Field('title', 
'string'), Field('description', 'string'), migrate=False)
 
I get the following error

>>> print dby().select(dby.test.ALL)
Traceback (most recent call last):
  File "", line 1, in 
  File "C:\Users\msimpson\Downloads\web2py_src 1_99_2\web2py\gluon\dal.py", 
lin
 5697, in select
return self.db._adapter.select(self.query,fields,attributes)
  File "C:\Users\msimpson\Downloads\web2py_src 1_99_2\web2py\gluon\dal.py", 
lin
 1233, in select
rows = response(sql)
  File "C:\Users\msimpson\Downloads\web2py_src 1_99_2\web2py\gluon\dal.py", 
lin
 1223, in response
self.execute(sql)
  File "C:\Users\msimpson\Downloads\web2py_src 1_99_2\web2py\gluon\dal.py", 
lin
 1309, in execute
return self.log_execute(*a, **b)
  File "C:\Users\msimpson\Downloads\web2py_src 1_99_2\web2py\gluon\dal.py", 
lin
 1304, in log_execute
ret = self.cursor.execute(*a,**b)
  File "C:\Users\msimpson\Downloads\web2py_src 
1_99_2\web2py\gluon\contrib\pymy
ql\cursors.py", line 108, in execute
self.errorhandler(self, exc, value)
  File "C:\Users\msimpson\Downloads\web2py_src 
1_99_2\web2py\gluon\contrib\pymy
ql\connections.py", line 184, in defaulterrorhandler
raise errorclass, errorvalue
InternalError: (1054, u"Unknown column 'test.id' in 'field list'")
>>>

it's mysql schema is

CREATE TABLE test
  (
  test_id VARCHAR(64) NOT NULL,
  title   VARCHAR(1024),
  description VARCHAR(1024),
  PRIMARY KEY (test_id)
  );

Has anyone seen this before, what am I doing wrong

Regards

Matt  



Re: [web2py] Re: How to add a readonly field in a SQLFORM?

2011-11-07 Thread Vinicius Assef
Thank you Anthony.

_readonly="readonly" solved my problem.



On Mon, Nov 7, 2011 at 10:52 AM, Anthony  wrote:
> Have you tried INPUT(..., _readonly="readonly")? That adds an HTML
> "readonly" attribute to the INPUT field, so the readonly display is
> controlled by the browser (it should appear as a regular input field, but
> the value will not be editable). If you just want to display the value
> itself, but not in an input field, then don't use INPUT() at all -- just
> display the value inside the table cell.
> Anthony
>
> On Monday, November 7, 2011 7:33:00 AM UTC-5, viniciusban wrote:
>>
>> Hi guys.
>>
>> I have this construction:
>>
>>     form = SQLFORM(db.my_table,
>>         fields=[
>>             'description',
>>             'date'],
>>         submit_button='Add data')
>>
>>     my_person_data = TR(LABEL('Customer'),
>> INPUT(value=other_table.customer_id.name, name='customer_name'))
>>     form[0].insert(0, my_person_data)
>>
>> How can I make the new added field (aka, customer_name) readonly?
>> I tried to set a writable=False parameter in INPUT, but it didn't worked.
>>
>> --
>> Vinicius Assef.
>


Re: [web2py] Re: form.validate().accepted ?

2011-11-07 Thread Vinicius Assef
Anthony, and if I just want the form validation, without updating the database?

Isn't what form.validate().accepted is supposed to do?



On Mon, Nov 7, 2011 at 11:01 AM, Anthony  wrote:
> Yes, that's an error in the book. form.validate() returns True or False.
> form.process() returns the form itself, so you have to check the status via
> form.process().accepted.
> Anthony
>
> On Monday, November 7, 2011 7:15:54 AM UTC-5, viniciusban wrote:
>>
>> I tryed this construction:
>> if form.validate().accepted:
>>    print "accepted"
>>
>> But I got this error:
>> AttributeError: 'NoneType' object has no attribute 'accepted'
>>
>> In book, chapter 7, "SQLFORM without database IO" section has 2
>> examples using form.validate().accepted.
>> Is it an error or didn't I get something?
>>
>> --
>> Vinicius Assef.
>


[web2py] Re: SQLFORM.factory and Select functionalities

2011-11-07 Thread Kostas M
Omi,

there was a mistype "db.m_Maker.ALL" instead of "db.Maker.ALL", which
I corrected.

Anyway, my main issue with your solution is that the FORM object is
not used, and so no Form validation is possible. On the other hand,
Freeze's solution with cascading fields in web2pyslices, seems too
advance for me too =))

On Nov 3, 3:44 pm, Omi Chiba  wrote:
> Kostas,
>
> I'm glad you did it !
>
> I tried your code this morning but some how it does not function
> (second pull dropdown doesn't show when first one is changed :(
>
> Anyway,
> your code looks a little bit too advance for me so I will keep the
> current one.
>
> On Nov 3, 6:59 am, Kostas M  wrote:
>
> > Omi,
>
> > Thanks for the hint!
> > I managed to adjust your solution to my case.
>
> > Also, I made some small recommendations, posted in web2pyslices.
>
> > On Oct 18, 9:00 pm, Omi Chiba  wrote:
>
> > > Kostas,
>
> > > This could be your alternatives.
>
> > > slice:http://www.web2pyslices.com/slices/take_slice/144
>
>


[web2py] Re: SQLFORM.factory and Select functionalities

2011-11-07 Thread Kostas M
Omi,

there was a mistype "db.m_Maker.ALL" instead of "db.Maker.ALL", which
I corrected.

Anyway, my main issue with your solution is that the FORM object is
not used, and so no Form validation is possible. On the other hand,
Freeze's solution with cascading fields in web2pyslices, seems too
advance for me too =))

On Nov 3, 3:44 pm, Omi Chiba  wrote:
> Kostas,
>
> I'm glad you did it !
>
> I tried your code this morning but some how it does not function
> (second pull dropdown doesn't show when first one is changed :(
>
> Anyway,
> your code looks a little bit too advance for me so I will keep the
> current one.
>
> On Nov 3, 6:59 am, Kostas M  wrote:
>
> > Omi,
>
> > Thanks for the hint!
> > I managed to adjust your solution to my case.
>
> > Also, I made some small recommendations, posted in web2pyslices.
>
> > On Oct 18, 9:00 pm, Omi Chiba  wrote:
>
> > > Kostas,
>
> > > This could be your alternatives.
>
> > > slice:http://www.web2pyslices.com/slices/take_slice/144
>
>


[web2py] Re: web(2/3)-based CMS (was Re: Mixing/supporting CMS with Web2py)

2011-11-07 Thread Ross Peoples
We REALLY need a CMS. I regularly develop sites that may have one or two 
pages that need web2py's power, but the rest of the pages only need basic 
CMS/Blog functionality. So I end up writing the those pages by hand in 
HTMLseems like such a waste.

Since I would regularly use and CMS/Blog functionality, I would be happy to 
contribute code and test it, as I would probably be using it every day. I 
would also have regular users play with it and incorporate their feedback 
into it to make something that is better than WordPress and Drupal 
combined. I think we have a lot of the pieces. I wrote plugin_ckeditor for 
inline editing (though maybe we should make our own inline editor. I tried 
to make an Aloha plugin, but didn't like their licensing).

Anyways, I would be happy to contribute whatever is needed to make this 
happen. Preferably as a plugin. Doing it as only a plugin is difficult, as 
I have tried before, and ended up having to do what Instant Press did, and 
make an "app" for it. But we should really figure out how to make it a 
plugin.


[web2py] Re: we need some good web2py quotes ....

2011-11-07 Thread Ross Peoples
I spent months evaluating different web frameworks written in Java, Python, 
PHP, and several others. I found that web2py was the easiest and most 
productive of them all. Being Python-based, web2py combines ease-of-use and 
fast performance with an incredible amount of power. Put simply, I have 
done things in web2py that were not possible or practical in other 
frameworks.

Re: [web2py] Re: form.validate().accepted ?

2011-11-07 Thread Anthony
process() calls validate(), and validate() calls accepts(), so they all do 
mostly the same thing. They all take a dbio argument, which determines 
whether to update the db in the case of SQLFORM. dbio defaults to True in 
process() and accepts() and False in validate(), so yes, by default, 
form.validate() will not update the db -- though form.validate(dbio=True)will 
update the db.

If you want validation without dbio, you can do form.validate() or 
form.process(dbio=False).accepted -- both of those are equivalent and will 
return a True|False value indicating the outcome.

Anthony

On Monday, November 7, 2011 8:10:30 AM UTC-5, viniciusban wrote:
>
> Anthony, and if I just want the form validation, without updating the 
> database?
>
> Isn't what form.validate().accepted is supposed to do?
>
> On Mon, Nov 7, 2011 at 11:01 AM, Anthony  wrote:
> > Yes, that's an error in the book. form.validate() returns True or False.
> > form.process() returns the form itself, so you have to check the status 
> via
> > form.process().accepted.
> > Anthony
> >
> > On Monday, November 7, 2011 7:15:54 AM UTC-5, viniciusban wrote:
> >>
> >> I tryed this construction:
> >> if form.validate().accepted:
> >>print "accepted"
> >>
> >> But I got this error:
> >> AttributeError: 'NoneType' object has no attribute 'accepted'
> >>
> >> In book, chapter 7, "SQLFORM without database IO" section has 2
> >> examples using form.validate().accepted.
> >> Is it an error or didn't I get something?
> >>
> >> --
> >> Vinicius Assef.
> >
>
>

Re: [web2py] Re: SQLFORM.grid columnas a mostrar

2011-11-07 Thread Marcelo Martinez
the question is:

to define
columns=['accountcode.ani','llamados.destino','llamados.answeredtime','llamados.inicio','llamados.valor']


I only show the columns that correspond to the table is llamados I need to
display and just as the column of the table accountcode



2011/11/2 Massimo Di Pierro 

> what is the question?
>
> On Nov 2, 9:09 am, mmartinez  wrote:
> > Hello list.
> >
> > My question is this, I have a join in my query to the database, you
> > need to show the columns belonging to tables and routes accountcode,
> > here is my code:
> >
> > left =
> > (db.accountcode.on(db.llamados.id_accountcode==db.accountcode.id),db.rutapr
> oveedor.on(db.llamados.id_rutaproveedor==db.rutaproveedor.id),db.rutas.on(d
> b.rutaproveedor.id_rutas==db.rutas.id))
> >
> > query = (db.llamados.dialstatus=='ANSWER') & (db.llamados.inicio>=dt1)
> > & (db.llamados.inicio<=dt2)
> >
> > ##
> > rows=db(query).select(b.ani,a.destino,r.nombre,a.answeredtime,a.inicio,
> a.va lor,
> > left=left)
> >
> > rws=SQLFORM.grid(
> >
> > query,
> >
> > left = left,
> >
> > deletable=False,
> >
> > editable=False,
> >
> > create=False,
> >
> > csv=False,
> >
> > details=False,
> >
> > showbuttontext=False,
> >
> >
> columns=['accountcode.ani','llamados.destino','llamados.answeredtime','llam
> ados.inicio','llamados.valor'] )
>


[web2py] Re: web2py with SAE Python

2011-11-07 Thread Massimo Di Pierro
Try this:

import sae
import gluon.main
from gluon.settings import global_settings
global_settings.web2py_runtime_gae = True
application = gluon.main.wsgibase


On Nov 7, 1:57 am, chinakr  wrote:
> SAE means Sina App Engine, which is a public cloud computing platform
> like GAE. It's the most mature and famous public cloud in China, where
> people can't access GAE freely. SAE only supports PHP in the last 3
> years.
>
> Recently, SAE started internal testing with Python support, with code
> name SAE Python.
>
> I would like to deploy web2py on SAE Python. And as GAE, SAE Python
> doesn't provide local file I/O, etc. I have to modify a lot of things
> manually.
>
> As lack of experience and time, it seems a hard task for me. So anyone
> can help?
>
> http://3.web2py.sinaapp.com/welcome/default/index
> will get 'invalid request' message with following index.wsgi:
>
> import sae
> import gluon.main
>
> app = gluon.main.wsgibase
> application = sae.create_wsgi_app(app)
>
> I also comment mkdir and open code in main.py.
>
> SAE Python 
> documents:http://appstack.sinaapp.com/static/doc/release/testing/index.html


[web2py] Re: Can't get remote read only mysql database to

2011-11-07 Thread Massimo Di Pierro
try

dby.define_table('test', Field('test_id', 'string'), Field('title',
'string'), Field('description', 'string'), migrate=False,
primarykey=['test_id'])

On Nov 7, 2:10 am, Matt Simpson  wrote:
> Hi,
>
> I have been trying to connect to a remote read only mysql database. This is
> an existing production database,  I want to use web2py to display it's data
> graphically .
>
> I can read from it using  dby.executesql('SELECT * FROM test;') but not
> using  dby().select(dby.test.ALL).
>
> The example is
> dby = DAL('mysql://gu...@10.113.131.67/newdb', pool_size=0)
> dby.define_table('test', Field('test_id', 'string'), Field('title',
> 'string'), Field('description', 'string'), migrate=False)
>
> I get the following error
>
> >>> print dby().select(dby.test.ALL)
>
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "C:\Users\msimpson\Downloads\web2py_src 1_99_2\web2py\gluon\dal.py",
> lin
>  5697, in select
>     return self.db._adapter.select(self.query,fields,attributes)
>   File "C:\Users\msimpson\Downloads\web2py_src 1_99_2\web2py\gluon\dal.py",
> lin
>  1233, in select
>     rows = response(sql)
>   File "C:\Users\msimpson\Downloads\web2py_src 1_99_2\web2py\gluon\dal.py",
> lin
>  1223, in response
>     self.execute(sql)
>   File "C:\Users\msimpson\Downloads\web2py_src 1_99_2\web2py\gluon\dal.py",
> lin
>  1309, in execute
>     return self.log_execute(*a, **b)
>   File "C:\Users\msimpson\Downloads\web2py_src 1_99_2\web2py\gluon\dal.py",
> lin
>  1304, in log_execute
>     ret = self.cursor.execute(*a,**b)
>   File "C:\Users\msimpson\Downloads\web2py_src
> 1_99_2\web2py\gluon\contrib\pymy
> ql\cursors.py", line 108, in execute
>     self.errorhandler(self, exc, value)
>   File "C:\Users\msimpson\Downloads\web2py_src
> 1_99_2\web2py\gluon\contrib\pymy
> ql\connections.py", line 184, in defaulterrorhandler
>     raise errorclass, errorvalue
> InternalError: (1054, u"Unknown column 'test.id' in 'field list'")
>
>
>
> it's mysql schema is
>
> CREATE TABLE test
>   (
>   test_id         VARCHAR(64) NOT NULL,
>   title           VARCHAR(1024),
>   description     VARCHAR(1024),
>   PRIMARY KEY (test_id)
>   );
>
> Has anyone seen this before, what am I doing wrong
>
> Regards
>
> Matt


[web2py] Re: Unable to write to file error in GAE

2011-11-07 Thread Massimo Di Pierro
None of these are errors but warning. The first is telling you that
you are using routes_out. It only displays the message in DEBUG mode.
The latter tells you that you have a T("something") and "something"
does not appear in the language file. It tries to add the entry and it
cannot because readonly. I remove the printing of the warning on GAE,
in trunk now.

On Nov 7, 2:39 am, Joseph Jude  wrote:
> Massimo,
> Since it is on GAE, I don't have the full traceback (if there is another
> way to get the traceback, pl let me know). I got only the below two types
> of errors:
>
> routes_out: [/init/default/index] not rewritten
>
> Unable to write to file 
> /base/data/home/apps/s~123-check/1.354481446592778594/applications/init/lan 
> guages/fr-fr.py
>
> Both of these are repeated many times.
> Thanks again,
> Joseph


[web2py] Re: Escaping HTML

2011-11-07 Thread Anthony
The HTML is probably being escaped in the view when it is displayed. Try 
putting the content inside XML() when you display it. If you want the 
content to display properly in a SQLTABLE, you should be able to use XML() 
in the field's "represent" attribute:

db.define_table('your_table',
Field('html_content', represent=lambda v, r: XML(v)))

Note, if this is user-entered HTML, you probably want to use XML(..., 
sanitize=True) to protect against XSS 
attacks. See http://web2py.com/book/default/chapter/05#XML.

Anthony

On Monday, November 7, 2011 8:04:58 AM UTC-5, horridohobbyist wrote:
>
> Is there a way to insert HTML into a database text field so that when 
> the text is displayed (say, in a SQLTABLE), the browser renders the 
> HTML? For example, I insert: 
>
> http://psychovisual.com";>Psychovisual.com 
>
> into a database text field, but it's not rendered. 
>
> Thanks, 
> Richard



[web2py] Re: Custom URLs for user profiles

2011-11-07 Thread Massimo Di Pierro
Given

auth.define_tables(username=True)

def proflle():
 return
dict(form=SQLFORM(db.auth_user,db_auth_user(username=request.args(0)),readonly=True))

then in routes.py

routes_in = [('/$username','/yourapp/default/profile/$username')]
routes_in = [('/yourapp/default/profile/$username','/$username')]

On Nov 7, 6:04 am, Sathvik Ponangi  wrote:
>  Is there someway that could display each of my user's profile as a custom
> URL likehttp://my_site.com/user_name?
>
> I'm using Web2Py(1.99.2_Stable) on GAE (SDKv1.5.5) on Python2.5
> --
> Sathvik Ponangi


[web2py] Re: Please help met to see the mistake causing this Valueerror

2011-11-07 Thread Massimo Di Pierro
Can you post a minimalist model/controller to reproduce it?

On Nov 7, 5:17 am, Johann Spies  wrote:
> ValueError: invalid literal for int() with base 10: 'abcd'
>
> From SQLForm.grid, when clicked on the ' View'  button I get the following
>
> When I click on the 'Edit'  button, I get a ticket:
>
> File "/home/js/web2py/gluon/dal.py", line 1378, in represent
>     return str(int(obj))
> ValueError: invalid literal for int() with base 10: 'abcd'
>
> The model clearly states doc_nr as a string:
>
>                 Field('doc_nr', type = 'string', length =
> 50,
>                      requires = IS_NOT_IN_DB(db, 'akb_doccenter.doc_nr')),
>
> So why does DAL try to convert it to an integer when going 
> tohttp://localhost:8000/akb/doccenter/browse/edit/akb_doccenter/9466?_s...
>
> Regards
> Johann
>
> --
> Because experiencing your loyal love is better than life itself,
> my lips will praise you.  (Psalm 63:3)


[web2py] Re: Displaying custom error message instead of the ticketing system

2011-11-07 Thread Massimo Di Pierro
You can also try call:

http://.../admin/default/reload_routes

On Nov 7, 6:47 am, Anthony  wrote:
> On Sunday, November 6, 2011 11:51:23 PM UTC-5, Sathvik Ponangi wrote:
>
> > Restarting my AppEngine server has fixed this issue. Thank you all for
> > your help.
>
> Yes, you always need to do a restart whenever you change routes.py.


Re: [web2py] Re: Displaying custom error message instead of the ticketing system

2011-11-07 Thread Sathvik Ponangi
Thanks!

On Mon, Nov 7, 2011 at 8:21 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> You can also try call:
>
> http://.../admin/default/reload_routes
>
> On Nov 7, 6:47 am, Anthony  wrote:
> > On Sunday, November 6, 2011 11:51:23 PM UTC-5, Sathvik Ponangi wrote:
> >
> > > Restarting my AppEngine server has fixed this issue. Thank you all for
> > > your help.
> >
> > Yes, you always need to do a restart whenever you change routes.py.
>



-- 
Sathvik Ponangi


Re: [web2py] Re: After modifying routes.py, GAE still routing to Welcome rather than my app

2011-11-07 Thread Jonathan Lundell
On Nov 6, 2011, at 10:44 PM, Spring wrote:

> Hi Jonathan,
> 
> I checked the debug logs on GAE as you suggested, and here is the
> detail after I hit "www.mydomain.com":
> 
> 2011-11-06 22:35:29.090 /favicon.ico 404 22ms 0cpu_ms 0kb
> W 2011-11-06 22:35:29.090 Static file referenced by handler not found:
> applications/go2chongqing/static/favicon.ico
> 2011-11-06 22:35:28.674 /welcome/default/index 404 34ms 46cpu_ms 0kb
> Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.2 (KHTML, like Gecko)
> Chrome/15.0.874.106 Safari/535.2
> D 2011-11-06 22:35:28.667 routes_app: [182.54.127.197:http://
> www.go2chongqing.com:get /welcome/default/index] [go2chongqing] ->
> go2chongqing

So routes_app is working. But it's not important unless you have app-specific 
routers, which you don't.

> D 2011-11-06 22:35:28.667 select routing parameters: BASE
> D 2011-11-06 22:35:28.667 routes_in: [182.54.127.197:http://
> www.go2chongqing.com:get /welcome/default/index] -> /welcome/default/
> index (not rewritten)

This is the interesting line. It says that the *incoming* URL (before routing) 
is http://www.go2chongqing.com:/welcome/default/index, which is why it's 
resolving to the welcome app.

> I 2011-11-06 22:35:28.671 Saved; key: __appstats__:028600, part: 39
> bytes, full: 1488 bytes, overhead: 0.000 + 0.003; link:
> http://www.go2chongqing.com/_ah/stats/details?time=1
> =
> Base routes.py:
> default_application = 'init'# ordinarily set in base routes.py
> default_controller = 'default'  # ordinarily set in app-specific
> routes.py
> default_function = 'index'  # ordinarily set in app-specific
> routes.py
> 
> routes_app = ((r'/(?Pgo2chongqing)\b.*', r'\g'),
>  (r'(.*)', r'go2chongqing'),
>  (r'/?(.*)', r'go2chongqing'))
> routes_in = ((r'.*:/favicon.ico', r'/examples/static/favicon.ico'),
> (r'.*:/robots.txt', r'/examples/static/robots.txt'),
> ((r'.*http://otherdomain.com.* (?P.*)', r'/app/ctr
> \g')))
> routes_out = ((r'.*http://otherdomain.com.* /app/ctr(?P.*)',
> r'\g'),
>  (r'/app(?P.*)', r'\g'))
> ==
> routes.py under application/myapp/:
> 
> default_application = 'go2chongqing'# ordinarily set in base
> routes.py
> default_controller = 'default'  # ordinarily set in app-specific
> routes.py
> default_function = 'index'  # ordinarily set in app-specific
> routes.py
> 
> routes_app = ((r'/(?Pgo2chongqing)\b.*', r'\g'),
>  (r'(.*)', r'go2chongqing'),
>  (r'/?(.*)', r'go2chongqing'))
> 
> routes_in = ((r'/static/(?P[\w./-]+)', r'/go2chongqing/static/
> \g'))
> routes_in = ((r'.*:/favicon.ico', r'/go2chongqing/static/
> favicon.ico'),
> (r'.*:/robots.txt', r'/go2chongqing/static/robots.txt'),
> ((r'.*http://go2chongqing.com.* (?P.*)', r'/app/ctr
> \g')))
> routes_out = ((r'.*http://go2chongqing.com.* /app/ctr(?P.*)',
> r'\g'),
>  (r'/app(?P.*)', r'\g'))
> ==
> 
> The only "welcome" I can find out in both routes.py is udner
> __routes_doctest(). Have no idea how GEA redirects to welcome/default/
> index.
> 
> Spring
> 
> 
> 
> On 11月6日, 下午11时26分, Jonathan Lundell  wrote:
>> On Nov 6, 2011, at 5:28 AM, Spring wrote:
>> 
>> 
>> 
>> 
>> 
>>> I'm facing a problem with GAE deployment. GAE still routes to Welcome
>>> rather than my app when hittingwww.myapp.com. And because I skipped
>>> the Welcome app in app.yaml, it gives "invalid request". Tried
>>> manually to go to "www.myapp.com/myapp/default/index", still "invalid
>>> request". Things seem to be fine when running the app locally with
>>> both web2py and GAE launcher. I even tried to give a new version
>>> number and re-deploy, but the same happened.
>> 
>>> Contents of routes.py modified as follows:
>> 
>>> default_application = 'go2chongqing'# ordinarily set in base
>>> routes.py
>>> default_controller = 'default'  # ordinarily set in app-specific
>>> routes.py
>>> default_function = 'index'  # ordinarily set in app-specific
>>> routes.py
>> 
>>> routes_app = ((r'/(?Pgo2chongqing|welcome|admin|app)\b.*',
>>> r'\g'),
>>>  (r'(.*)', r'go2chongqing'),
>>>  (r'/?(.*)', r'go2chongqing'))
>> 
>>> routes_in and routes_out remain unchanged.
>>> =
>>> Can anybody help on this. Thanks in advance.
>> 
>> Do you see anything routing-related in the GAE logs? You'll need to set the 
>> log viewing level to DEBUG.- 隐藏被引用文字 -
>> 
>> - 显示引用的文字 -




[web2py] Redirecting back to the caller controller

2011-11-07 Thread Abhishek Gupta
There are two controllers say A and B. A calls B from within. Now, I want
to redirect back to the controller A on return from B. In my case both A
and B are variable. What is the best way to do this? One way is to maintain
a session variable such as session.prev_url.

Abhishek
http://abhishekgupta92.info


[web2py] Re: Custom URLs for user profiles

2011-11-07 Thread Sathvik Ponangi
Thank you Massimo.
I'm using a DAL table for users

db.define_table('users', 
> db.Field('name', 'string'),
> db.Field('password', 'password')
> )


How should I go about it?

Also I'd like the same for non user-pages like http://my_site.com/my_page


[web2py] Re: SQLFORM.factory and Select functionalities

2011-11-07 Thread Omi Chiba
> there was a mistype "db.m_Maker.ALL" instead of "db.Maker.ALL", which> I 
> corrected.Yeah, it works now !

In my case all I need were two lists and they are mandatory so that I
don't need any validation. I assume you have other fields or allow to
input something not in the list...

I haven't tried but how about using with custom forms  ?
http://www.web2py.com/book/default/chapter/07#Custom-forms

You can create your form object, place them with
{{=form.custom.widget.xxx}} and also put the cascading drop down with
in the {{=form.custom.begin}} ~ {{=form.custom.end}}.




On Nov 7, 7:19 am, Kostas M  wrote:
> Omi,
>
> there was a mistype "db.m_Maker.ALL" instead of "db.Maker.ALL", which
> I corrected.
>
> Anyway, my main issue with your solution is that the FORM object is
> not used, and so no Form validation is possible. On the other hand,
> Freeze's solution with cascading fields in web2pyslices, seems too
> advance for me too =))
>
> On Nov 3, 3:44 pm, Omi Chiba  wrote:
>
>
>
>
>
>
>
> > Kostas,
>
> > I'm glad you did it !
>
> > I tried your code this morning but some how it does not function
> > (second pull dropdown doesn't show when first one is changed :(
>
> > Anyway,
> > your code looks a little bit too advance for me so I will keep the
> > current one.
>
> > On Nov 3, 6:59 am, Kostas M  wrote:
>
> > > Omi,
>
> > > Thanks for the hint!
> > > I managed to adjust your solution to my case.
>
> > > Also, I made some small recommendations, posted in web2pyslices.
>
> > > On Oct 18, 9:00 pm, Omi Chiba  wrote:
>
> > > > Kostas,
>
> > > > This could be your alternatives.
>
> > > > slice:http://www.web2pyslices.com/slices/take_slice/144


[web2py] Re: 500 Internal Server Error

2011-11-07 Thread Hong-Khoan Quach
Hi thodoris,

do you use the latest trunk version?

Am 03.11.2011 13:12, schrieb thodoris:
> I have the following configuration
> 
> auth.settings.allow_basic_login=True
> 
> db.define_table( 'files',
> Field('file','upload'))
> 
> @auth.requires_login()
> def upload():
> form = crud.create(db.files)
> return dict(form=form)
> 
> and i applied the PATCH mentioned here 
> https://groups.google.com/forum/#!topic/web2py/CDHOUqtICn8
> 
> I executed the setup-web2py-ubuntu.sh script and the everything works
> ok from the webpage.
> 
> What i want to do is upload a file using curl.
> 
> If i don't use authentication, using the following command the file is
> uploaded:
> 
> curl -F file=@/home/thodoris/Documents/test.jpg.rtp -F _formname=files/
> None  http://192.168.1.75/test/default/upload
> 
> If i use authentication and use the command
> 
> curl --verbose -u t...@nowhere.com: -F file=@/home/thodoris/
> Documents/test.jpg.rtp -F _formname=files/None  
> http://192.168.1.75/test/default/upload
> 
> i get the following error:
> 
> * About to connect() to 192.168.1.75 port 80 (#0)
> *   Trying 192.168.1.75... connected
> * Connected to 192.168.1.75 (192.168.1.75) port 80 (#0)
> * Server auth using Basic with user 't...@nowhere.com'
>> POST /test/default/upload HTTP/1.1
>> Authorization: Basic dGVzdEBub3doZXJlLmNvbToxMTEx
>> User-Agent: curl/7.21.3 (x86_64-pc-linux-gnu) libcurl/7.21.3 OpenSSL/0.9.8o 
>> zlib/1.2.3.4 libidn/1.18
>> Host: 192.168.1.75
>> Accept: */*
>> Content-Length: 60669
>> Expect: 100-continue
>> Content-Type: multipart/form-data; 
>> boundary=dd827f333b42
>>
> < HTTP/1.1 100 Continue
> < HTTP/1.1 500 Internal Server Error
> < Date: Thu, 03 Nov 2011 11:24:32 GMT
> < Server: Apache/2.2.17 (Ubuntu)
> < Vary: Accept-Encoding
> < Content-Length: 592
> < Connection: close
> < Content-Type: text/html; charset=iso-8859-1
> <
> 
> 
> 303 SEE OTHER
> 
> SEE OTHER
> The server encountered an internal error or
> misconfiguration and was unable to complete
> your request.
> Please contact the server administrator,
>  [no address given] and inform them of the time the error occurred,
> and anything you might have done that may have
> caused the error.
> More information about this error may be available
> in the server error log.
> 
> Apache/2.2.17 (Ubuntu) Server at 192.168.1.75 Port 80 address>
> 
> * Closing connection #0
> 
> And the error in apache log is:
> 
> [Thu Nov 03 12:24:32 2011] [error] [client 192.168.1.75] malformed
> header from script. Bad header=x98%255Cxa0%255CxdaKk4Ht%255Cx:
> wsgihandler.py
> 
> When i use the internal server from web2py and not Apache i use the
> exact same configuration and it WORKS. Could someone give me some
> advice of how to solve this???
> 



signature.asc
Description: OpenPGP digital signature


[web2py] Re: Custom URLs for user profiles

2011-11-07 Thread Sathvik Ponangi
I mean http://my_site/user_name/page_name & 
http://my_site/user_name/page_name/link1/... 

[web2py] Re: crud update problem with 1.99.2?

2011-11-07 Thread David Manns
I don't think its to do with the model (the table in question has no
float or decimal in any case).

I think it has to do with the handling of next= in crud.

The controller code (somewhat simplified, but still reproduces the
problem) is:

def memberform():
if request.vars.membid:
next = URL('memberform', vars=dict(membid=request.vars.membid,
next=request.vars.next))
form = crud.update(db.Members, request.vars.membid, next=next)
else:
form = crud.create(db.Members, next=request.vars.next)
return dict(form=form, next=request.vars.next,
membid=request.vars.membid)

The first time in, with membid the ID of an existing record, the
record is correctly displayed via the crud.update() form.  When a
field is edited and the form submitted, the failure occurs.

On Oct 28, 7:59 am, Richard Vézina 
wrote:
> Without model I think it difficult to debug...
>
> But the problem come from a float type error, so there must be a failing
> constrain on one of your field... Look at you member model if there is a
> double type field or decimal and make sure you have a validator with
> appropriate constraining domain...
>
> doubleIS_FLOAT_IN_RANGE(-1e100, 1e100)decimal(n,m)IS_DECIMAL_IN_RANGE(-1e100,
> 1e100)
> Richard
>
>
>
>
>
>
>
> On Sat, Oct 15, 2011 at 10:15 AM, David Manns  wrote:
> > This problem appeared when I moved my application from x to 1.99.2.
>
> > I use crud.update to display and modify a member directory record.
> > Selecting and displaying the record works, but when submitting an updated
> > record I get a failure:
>
> > TRACEBACK
>
> > 1.
> > 2.
> > 3.
> > 4.
> > 5.
> > 6.
> > 7.
> > 8.
> > 9.
> > 10.
> > 11.
> > 12.
>
> > Traceback (most recent call last):
> >   File "C:\Documents and Settings\David Manns\My 
> > Documents\ocsnedb\gluon\restricted.py", line 194, in restricted
> >     raise
> >   File "C:/Documents and Settings/David Manns/My Documents/ocsnedb 
> > saved/applications/init/controllers/default.py" 
> > , 
> > line 889, in 
> >   File "C:\Documents and Settings\David Manns\My 
> > Documents\ocsnedb\gluon\globals.py", line 149, in 
> >   File "C:/Documents and Settings/David Manns/My Documents/ocsnedb 
> > saved/applications/init/controllers/default.py" 
> > , 
> > line 273, in memberform
> >     deletable = False, next=next, onvalidation=setmodified)
> >   File "C:\Documents and Settings\David Manns\My 
> > Documents\ocsnedb\gluon\tools.py", line 2994, in update
> >     formname=DEFAULT,
> >   File "C:\Documents and Settings\David Manns\My 
> > Documents\ocsnedb\gluon\tools.py", line 79, in replace_id
> > TypeError: float argument required
>
> > The controller code looks like:
>
> > def memberform():
> >  chkurlreader()
> >  if request 
> > .vars.membid:
> >      member=db.Members[request 
> > .vars.membid]
> >      db.Members.Email.comment = A 
> > ('Add/Edit/Delete Email 
> > Address(es)',
> >          _href=URL 
> > ('memberemail', 
> > vars=dict(membid=request 
> > .vars.membid, 
> > next=request 
> > .vars.next)))
> >      db.Members.Affiliation.comment = A 
> > ('Add/Edit/Delete 
> > Affiliation(s)',
> >          _href=URL 
> > ('memberaffiliation', 
> > vars=dict(membid=request 
> > .vars.membid, 
> > next=request 
> > .vars.next)))
> >      if member.Status in ('Full', 'Student'):
> >          db.Members.Paiddate.comment = A 
> > ('Process dues payment',
> >              _href=URL 
> > ('memberdues', 
> > vars=dict(membid=request 
> > .vars.membid, 
> > next=request 
> > .vars.next)))
> >      else:
> >          db.Members.Paiddate.comment = 'Only for Full & Student Members'
> >      next = URL 
> > ('memberform', 
> > vars=dict(membid=request 
> > .vars.membid, 
> > next=request 
> > .vars.next))
> >      form = crud.update(db.Members, request 
> > .vars.membid,
> >                  deletable = False, next=next, onvalidation=setmodified)
> >      form[0][-1][1].append(INPUT 
> > 

[web2py] GAE and logging

2011-11-07 Thread Jonathan Lundell
This recent patch:

> @@ -93,7 +93,8 @@
>  try:
>  fp = open(filename, 'w')
>  except IOError:
> -logging.error('Unable to write to file %s' % filename)
> +if not is_gae:
> +logging.warning('Unable to write to file %s' % filename)
>  return
>  portalocker.lock(fp, portalocker.LOCK_EX)
>  fp.write('# coding: utf8\n{\n')

reminded me of another patch I've been thinking about, and gave me an idea for 
a grander design.

The problem is that GAE logs *everything* (ignoring the current loglevel); they 
want you to filter in the log viewer rather than the logger. They may be right, 
but as in the above example it leads to a lot of noise and discourages the use 
of even debug-level logging. 

The patch I've been thinking about is for rewrite, which routinely logs some 
top-level information (logging.debug) about what it's doing to assist in 
debugging router files. A long time ago I had added a logging-control parameter 
to routes.py, so that you could turn routing logs on and off that way. When we 
added support for logging.conf (see logging.example.conf), I gave routing its 
own logger and took out the parameter: control it the way you control 
everything else, through logging.conf.

Except for GAE...

The patch I was thinking originally (and still am) is to reintroduce the 
logging parameter to routes.py and make its logging conditional on that 
(details tbd; maybe it wants to mention a level instead of being simply a 
boolean).

But now I'm thinking that a more universal solution would be to enhance 
web2py's logging capability to make this kind of solution available to any app 
or module.

Right now, a module like gluon.rewrite logs this way:

logger = logging.getLogger('web2py.rewrite')
...
logger.debug('some debug message')

(where web2py.rewrite is parameterized in logging.conf)

Suppose we replace the call to logging.getLogger with a function that returns 
logger in a wrapper. The wrapper would somehow know (tbd) what level we're 
logging at, and because it wraps methods like .debug simply doesn't call 
logger.debug if unless it really wants to log. 

This is all rather fuzzy, since I'm not sure how we'd want to control it; the 
logic might want to look at whether we're running on GAE. But it seems wasteful 
to sprinkle GAE-specific workarounds throughout web2py, especially in places 
(like rewrite) where sometimes we really *do* want to see the logs.



Re: [web2py] Re: crud update problem with 1.99.2?

2011-11-07 Thread Richard Vézina
Did you have a look of what is coming out request.vars.membid and
request.vars.next... I maybe not what you expect that you get and it may
cause the problem...

If you test your controller manually does it work properly? If so, it must
be a wrong type coming from your request.vars, you can try to convert to
the proper type int(request.vars.membid) for example.

Richard

On Mon, Nov 7, 2011 at 10:44 AM, David Manns  wrote:

> I don't think its to do with the model (the table in question has no
> float or decimal in any case).
>
> I think it has to do with the handling of next= in crud.
>
> The controller code (somewhat simplified, but still reproduces the
> problem) is:
>
> def memberform():
>if request.vars.membid:
> next = URL('memberform',
> vars=dict(membid=request.vars.membid,
> next=request.vars.next))
> form = crud.update(db.Members, request.vars.membid,
> next=next)
>else:
>form = crud.create(db.Members, next=request.vars.next)
>return dict(form=form, next=request.vars.next,
> membid=request.vars.membid)
>
> The first time in, with membid the ID of an existing record, the
> record is correctly displayed via the crud.update() form.  When a
> field is edited and the form submitted, the failure occurs.
>
> On Oct 28, 7:59 am, Richard Vézina 
> wrote:
> > Without model I think it difficult to debug...
> >
> > But the problem come from a float type error, so there must be a failing
> > constrain on one of your field... Look at you member model if there is a
> > double type field or decimal and make sure you have a validator with
> > appropriate constraining domain...
> >
> > doubleIS_FLOAT_IN_RANGE(-1e100,
> 1e100)decimal(n,m)IS_DECIMAL_IN_RANGE(-1e100,
> > 1e100)
> > Richard
> >
> >
> >
> >
> >
> >
> >
> > On Sat, Oct 15, 2011 at 10:15 AM, David Manns  wrote:
> > > This problem appeared when I moved my application from x to 1.99.2.
> >
> > > I use crud.update to display and modify a member directory record.
> > > Selecting and displaying the record works, but when submitting an
> updated
> > > record I get a failure:
> >
> > > TRACEBACK
> >
> > > 1.
> > > 2.
> > > 3.
> > > 4.
> > > 5.
> > > 6.
> > > 7.
> > > 8.
> > > 9.
> > > 10.
> > > 11.
> > > 12.
> >
> > > Traceback (most recent call last):
> > >   File "C:\Documents and Settings\David Manns\My
> Documents\ocsnedb\gluon\restricted.py", line 194, in restricted
> > > raise
> > >   File "C:/Documents and Settings/David Manns/My Documents/ocsnedb
> saved/applications/init/controllers/default.py" <
> http://127.0.0.1:8000/admin/default/edit/init/controllers/default.py>,
> line 889, in 
> > >   File "C:\Documents and Settings\David Manns\My
> Documents\ocsnedb\gluon\globals.py", line 149, in 
> > >   File "C:/Documents and Settings/David Manns/My Documents/ocsnedb
> saved/applications/init/controllers/default.py" <
> http://127.0.0.1:8000/admin/default/edit/init/controllers/default.py>,
> line 273, in memberform
> > > deletable = False, next=next, onvalidation=setmodified)
> > >   File "C:\Documents and Settings\David Manns\My
> Documents\ocsnedb\gluon\tools.py", line 2994, in update
> > > formname=DEFAULT,
> > >   File "C:\Documents and Settings\David Manns\My
> Documents\ocsnedb\gluon\tools.py", line 79, in replace_id
> > > TypeError: float argument required
> >
> > > The controller code looks like:
> >
> > > def memberform():
> > >  chkurlreader()
> > >  if request  >.vars.membid:
> > >  member=db.Members[request <
> http://127.0.0.1:8000/examples/global/vars/request>.vars.membid]
> > >  db.Members.Email.comment = A <
> http://127.0.0.1:8000/examples/global/vars/A>('Add/Edit/Delete Email
> Address(es)',
> > >  _href=URL 
> > > ('memberemail',
> vars=dict(membid=request <
> http://127.0.0.1:8000/examples/global/vars/request>.vars.membid,
> next=request  >.vars.next)))
> > >  db.Members.Affiliation.comment = A <
> http://127.0.0.1:8000/examples/global/vars/A>('Add/Edit/Delete
> Affiliation(s)',
> > >  _href=URL 
> > > ('memberaffiliation',
> vars=dict(membid=request <
> http://127.0.0.1:8000/examples/global/vars/request>.vars.membid,
> next=request  >.vars.next)))
> > >  if member.Status in ('Full', 'Student'):
> > >  db.Members.Paiddate.comment = A <
> http://127.0.0.1:8000/examples/global/vars/A>('Process dues payment',
> > >  _href=URL 
> > > ('memberdues',
> vars=dict(membid=request <
> http://127.0.0.1:8000/examples/global/vars/request>.vars.membid,
> next=request  >.vars.next)))
> > >  else:
> > >  db.Members.Paiddate.comment = 'Only for Full & Student
> 

[web2py] Re: patch for web2py socket timeout

2011-11-07 Thread ron_m
I am trying to understand why the socket timeout would be set so low at 1 
second as a default. 

I believe this change is the solution to a problem I have been chasing off 
and on time permitting where the pages won't render properly when using the 
rocket server with a browser over the WAN. Local LAN always works. I 
probably won't use rocket for deployment but was testing a prototype. Some 
browsers worked like Firefox but Safari on Snow Leopard failed while Safari 
on Lion worked. On the same LAN they all worked. The failure looked like 
the jQuery Javascript never ran with the page load.

I will see later if this change fixes my problem as well.

Thanks
Ron


[web2py] Re: Escaping HTML

2011-11-07 Thread horridohobbyist
Thanks! Works like a charm!

Richard

On Nov 7, 9:39 am, Anthony  wrote:
> The HTML is probably being escaped in the view when it is displayed. Try
> putting the content inside XML() when you display it. If you want the
> content to display properly in a SQLTABLE, you should be able to use XML()
> in the field's "represent" attribute:
>
> db.define_table('your_table',
>     Field('html_content', represent=lambda v, r: XML(v)))
>
> Note, if this is user-entered HTML, you probably want to use XML(...,
> sanitize=True) to protect against XSS
> attacks. Seehttp://web2py.com/book/default/chapter/05#XML.
>
> Anthony
>
>
>
>
>
>
>
> On Monday, November 7, 2011 8:04:58 AM UTC-5, horridohobbyist wrote:
>
> > Is there a way to insert HTML into a database text field so that when
> > the text is displayed (say, in a SQLTABLE), the browser renders the
> > HTML? For example, I insert:
>
> > http://psychovisual.com";>Psychovisual.com
>
> > into a database text field, but it's not rendered.
>
> > Thanks,
> > Richard


[web2py] Re: new web site

2011-11-07 Thread TheSweetlink
Good upgrade!

I particularly like the Bossie Award at the top, the detailed
web2py_vs_others.pdf (needs a few minor corrections noted below), and /
what but I don't understand why the link is titled 3rd party tools.

Slide notes:
Slides 36 and 40 say SQLField instead of Field like in the Book.

94 says "allow allow"

All in all I really liked the tactfully explained, as per usual,
comparisons.

Well done.

David

On Nov 6, 3:02 pm, Massimo Di Pierro 
wrote:
> We have a new web site
>
>    http://web2py.com/new_examples
>
> Please check it out before we replace the old one.


Re: [web2py] Re: Custom URLs for user profiles

2011-11-07 Thread Sathvik Ponangi
I finally got it to work! Its nice that request.args holds all additional
parameters. Thank you for your time, Massimo!
-- 
Sathvik Ponangi


Re: [web2py] Re: crud update problem with 1.99.2?

2011-11-07 Thread Richard Vézina
This thread might interest you :

http://groups.google.com/group/web2py/browse_thread/thread/f35eeb3c78b90fbd/3c57edf44009d62d?lnk=gst&q=Re%3A+1.99+gluon%2Ftools.py+replace_id+mishandling+url+%5BSOLVED%5D#3c57edf44009d62d

Richard



On Mon, Nov 7, 2011 at 11:38 AM, Richard Vézina  wrote:

> Did you have a look of what is coming out request.vars.membid and
> request.vars.next... I maybe not what you expect that you get and it may
> cause the problem...
>
> If you test your controller manually does it work properly? If so, it must
> be a wrong type coming from your request.vars, you can try to convert to
> the proper type int(request.vars.membid) for example.
>
> Richard
>
>
> On Mon, Nov 7, 2011 at 10:44 AM, David Manns  wrote:
>
>> I don't think its to do with the model (the table in question has no
>> float or decimal in any case).
>>
>> I think it has to do with the handling of next= in crud.
>>
>> The controller code (somewhat simplified, but still reproduces the
>> problem) is:
>>
>> def memberform():
>>if request.vars.membid:
>> next = URL('memberform',
>> vars=dict(membid=request.vars.membid,
>> next=request.vars.next))
>> form = crud.update(db.Members, request.vars.membid,
>> next=next)
>>else:
>>form = crud.create(db.Members, next=request.vars.next)
>>return dict(form=form, next=request.vars.next,
>> membid=request.vars.membid)
>>
>> The first time in, with membid the ID of an existing record, the
>> record is correctly displayed via the crud.update() form.  When a
>> field is edited and the form submitted, the failure occurs.
>>
>> On Oct 28, 7:59 am, Richard Vézina 
>> wrote:
>> > Without model I think it difficult to debug...
>> >
>> > But the problem come from a float type error, so there must be a failing
>> > constrain on one of your field... Look at you member model if there is a
>> > double type field or decimal and make sure you have a validator with
>> > appropriate constraining domain...
>> >
>> > doubleIS_FLOAT_IN_RANGE(-1e100,
>> 1e100)decimal(n,m)IS_DECIMAL_IN_RANGE(-1e100,
>> > 1e100)
>> > Richard
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > On Sat, Oct 15, 2011 at 10:15 AM, David Manns 
>> wrote:
>> > > This problem appeared when I moved my application from x to 1.99.2.
>> >
>> > > I use crud.update to display and modify a member directory record.
>> > > Selecting and displaying the record works, but when submitting an
>> updated
>> > > record I get a failure:
>> >
>> > > TRACEBACK
>> >
>> > > 1.
>> > > 2.
>> > > 3.
>> > > 4.
>> > > 5.
>> > > 6.
>> > > 7.
>> > > 8.
>> > > 9.
>> > > 10.
>> > > 11.
>> > > 12.
>> >
>> > > Traceback (most recent call last):
>> > >   File "C:\Documents and Settings\David Manns\My
>> Documents\ocsnedb\gluon\restricted.py", line 194, in restricted
>> > > raise
>> > >   File "C:/Documents and Settings/David Manns/My Documents/ocsnedb
>> saved/applications/init/controllers/default.py" <
>> http://127.0.0.1:8000/admin/default/edit/init/controllers/default.py>,
>> line 889, in 
>> > >   File "C:\Documents and Settings\David Manns\My
>> Documents\ocsnedb\gluon\globals.py", line 149, in 
>> > >   File "C:/Documents and Settings/David Manns/My Documents/ocsnedb
>> saved/applications/init/controllers/default.py" <
>> http://127.0.0.1:8000/admin/default/edit/init/controllers/default.py>,
>> line 273, in memberform
>> > > deletable = False, next=next, onvalidation=setmodified)
>> > >   File "C:\Documents and Settings\David Manns\My
>> Documents\ocsnedb\gluon\tools.py", line 2994, in update
>> > > formname=DEFAULT,
>> > >   File "C:\Documents and Settings\David Manns\My
>> Documents\ocsnedb\gluon\tools.py", line 79, in replace_id
>> > > TypeError: float argument required
>> >
>> > > The controller code looks like:
>> >
>> > > def memberform():
>> > >  chkurlreader()
>> > >  if request > >.vars.membid:
>> > >  member=db.Members[request <
>> http://127.0.0.1:8000/examples/global/vars/request>.vars.membid]
>> > >  db.Members.Email.comment = A <
>> http://127.0.0.1:8000/examples/global/vars/A>('Add/Edit/Delete Email
>> Address(es)',
>> > >  _href=URL 
>> > > ('memberemail',
>> vars=dict(membid=request <
>> http://127.0.0.1:8000/examples/global/vars/request>.vars.membid,
>> next=request > >.vars.next)))
>> > >  db.Members.Affiliation.comment = A <
>> http://127.0.0.1:8000/examples/global/vars/A>('Add/Edit/Delete
>> Affiliation(s)',
>> > >  _href=URL 
>> > > ('memberaffiliation',
>> vars=dict(membid=request <
>> http://127.0.0.1:8000/examples/global/vars/request>.vars.membid,
>> next=request > >.vars.next)))
>> > >  if member.Status in ('Full', 'Student'):
>> > >  db.Members.Paiddate.comment = A <
>> http

[web2py] Re: we need some good web2py quotes ....

2011-11-07 Thread Christopher Steel
Web2py is the "can do"  web development framework for "can do" developers.



Re: [web2py] Re: new web site

2011-11-07 Thread Richard Vézina
:)

Richard

On Sun, Nov 6, 2011 at 11:26 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> The layout is derived from this April's fool joke they played on us:
> http://web2pyramid.pylonsproject.org/
>
> The content is the same the old site.
>
> The quotes are taken from twitter #web2py.
>
> Massimo
>
> On Nov 6, 9:03 pm, "Andrew Thompson"  wrote:
> > Is the content being pulled from existing data, or was it re-entered?
> > In the third-party code section of the staff page, the markdown2 link is
> old, they moved to github.
> > The feedparser website is 410 Gone(not sure how long, or if it moved).
> > The fcgi.py link is dead as well.
> > Can someone else check with a tablet turned portrait? On my touchpad, it
> squeezes the layout strange.--
> > Andrew Thompson
> > http://aktzero.com/
>


[web2py] Re: new web site

2011-11-07 Thread mikech
Just clicking thru some links - Scanme looks like its moved from 
http://www.scanme.co.za/  to http://www.scanme.com/ 

[web2py] SyntaxError: Set: no tables selected on select statement.

2011-11-07 Thread Matthew Young
Hello I am using the Version 1.99.3 (2011-11-07 17:41:19) dev version
of web2py.

I am having an issue with this view function:
def check_room_availability():
room = db.room(request.args(0)) or redirect(URL('view_rooms'))
reservations = db().select(db.reservation.room.name==room.name)
return dict(room=room, reservations=reservations)

I get the following error when this page is viewed with a room number
passed as an argument:
Traceback (most recent call last):
  File "/home/mattosaurus/web2py/gluon/restricted.py", line 194, in
restricted
in code it raises a RestrictedError containing the traceback.
layer is
  File "/home/mattosaurus/web2py/applications/roomReserve/controllers/
default.py", line 121, in 
  File "/home/mattosaurus/web2py/gluon/globals.py", line 149, in

self.files = []# used by web2py_ajax.html
  File "/home/mattosaurus/web2py/applications/roomReserve/controllers/
default.py", line 85, in check_room_availability
reservations = db().select(db.reservation.room.name==room.name)
  File "/home/mattosaurus/web2py/gluon/dal.py", line 5697, in select
db,
  File "/home/mattosaurus/web2py/gluon/dal.py", line 1225, in select
sql_t += ' %s %s' % (icommand, str(t))
  File "/home/mattosaurus/web2py/gluon/dal.py", line 1128, in _select
tablenames = self.tables(query)
SyntaxError: Set: no tables selected

My table definitions in db.py look like this:
db.define_table('room',
Field('name'),
Field('description','text'),
Field('location','text'),
format='%(name)s')

db.define_table('reservation',
Field('room','references room'),
Field('start_date','datetime'),
Field('end_date','datetime'),
Field('special_requirements','text'),
Field('approved','boolean'),
auth.signature)

db.reservation.room.requires = IS_IN_DB(db,db.room.id,'%(name)s')
db.room.name.requires = IS_NOT_EMPTY()
db.room.description.requires = IS_NOT_EMPTY()
db.room.location.requires = IS_NOT_EMPTY()
db.reservation.start_date.requires = IS_NOT_EMPTY()
db.reservation.end_date.requires = IS_NOT_EMPTY()


Has anyone seen this error before? Is my select incorrect? I am
finding the documentation a little confusing in this area.


[web2py] Re: Online Book Typo

2011-11-07 Thread Andrew
Hi Mike,
I'm going through each of the chapters and sending my changes to
Massimo.  I hope I catch everything, but I'll be looking at your posts
here to make sure I've got them.

Andrew W

On Nov 7, 4:46 pm, mikech  wrote:
> I would be glad to help clean up the book if you need it.  Otherwise I will
> post the issues here.
>
> Mike


[web2py] RSS newbie

2011-11-07 Thread Paul
I do not see the right-hand side menu shown in the book Overview page
shortly after the start of RSS feed discussion. It seems to vary by
browser.

Also, viewing this RSS fied with Google Chrome 15.0.874.106 m displays
raw XML. Is there a setting that I need to change?


[web2py] Re: SyntaxError: Set: no tables selected on select statement.

2011-11-07 Thread Limedrop
A couple of obvious thing.  First, the query goes with the db() not
the select().  Second, the reference to room is via room.id rather
than room.name.  So you could try:

reservations = db(db.reservation.room==room.id).select()


On Nov 8, 8:49 am, Matthew Young  wrote:
> Hello I am using the Version 1.99.3 (2011-11-07 17:41:19) dev version
> of web2py.
>
> I am having an issue with this view function:
> def check_room_availability():
>     room = db.room(request.args(0)) or redirect(URL('view_rooms'))
>     reservations = db().select(db.reservation.room.name==room.name)
>     return dict(room=room, reservations=reservations)
>
> I get the following error when this page is viewed with a room number
> passed as an argument:
> Traceback (most recent call last):
>   File "/home/mattosaurus/web2py/gluon/restricted.py", line 194, in
> restricted
>     in code it raises a RestrictedError containing the traceback.
> layer is
>   File "/home/mattosaurus/web2py/applications/roomReserve/controllers/
> default.py", line 121, in 
>   File "/home/mattosaurus/web2py/gluon/globals.py", line 149, in
> 
>     self.files = []            # used by web2py_ajax.html
>   File "/home/mattosaurus/web2py/applications/roomReserve/controllers/
> default.py", line 85, in check_room_availability
>     reservations = db().select(db.reservation.room.name==room.name)
>   File "/home/mattosaurus/web2py/gluon/dal.py", line 5697, in select
>     db,
>   File "/home/mattosaurus/web2py/gluon/dal.py", line 1225, in select
>     sql_t += ' %s %s' % (icommand, str(t))
>   File "/home/mattosaurus/web2py/gluon/dal.py", line 1128, in _select
>     tablenames = self.tables(query)
> SyntaxError: Set: no tables selected
>
> My table definitions in db.py look like this:
> db.define_table('room',
>     Field('name'),
>     Field('description','text'),
>     Field('location','text'),
>     format='%(name)s')
>
> db.define_table('reservation',
>     Field('room','references room'),
>     Field('start_date','datetime'),
>     Field('end_date','datetime'),
>     Field('special_requirements','text'),
>     Field('approved','boolean'),
>     auth.signature)
>
> db.reservation.room.requires = IS_IN_DB(db,db.room.id,'%(name)s')
> db.room.name.requires = IS_NOT_EMPTY()
> db.room.description.requires = IS_NOT_EMPTY()
> db.room.location.requires = IS_NOT_EMPTY()
> db.reservation.start_date.requires = IS_NOT_EMPTY()
> db.reservation.end_date.requires = IS_NOT_EMPTY()
>
> Has anyone seen this error before? Is my select incorrect? I am
> finding the documentation a little confusing in this area.


Re: [web2py] Re: SQLFORM.smartgrid query/search don't work for related tables

2011-11-07 Thread Jim Steil

Massimo

Here is a little demo app to display the problem.  I tested against 
trunk updated about noon central time today.


Added this to db.py:


contact = db.define_table('contact',
Field('contactId', 'id'),
Field('name', length=50, required=True),
format='%(name)s')
contact._plural = 'Contacts'

tag = db.define_table('tag',
Field('tagId', 'id'),
Field('name', length=50, required=True),
format='%(name)s')
tag._plural = 'Tags'

contactTag = db.define_table('contactTag',
Field('contactTagId', 'id'),
Field('contactId', db.contact, readable=False, writable=False, 
required=True, label='Contact'),

Field('tagId', db.tag, required=True, label='Tag'))

contactTag.contactId.requires = IS_IN_DB(db, db.contact.id,
 '%(name)s', zero=('select contact'))
contactTag.tagId.requires = IS_IN_DB(db, db.tag.tagId,
  '%(name)s', zero=('select tag'))


Added this to default.py:

def contacts():
columns = ['contact.name', 'contactTag.tagId']
orderBy = dict(contact=[db.contact.name])

contactTag._plural = 'Tags'
grid = SQLFORM.smartgrid(db.contact, columns=columns, 
details=False, orderby=orderBy,csv=False,paginate=15, maxtextlength=45)


return dict(grid=grid)

def tags():
columns = ['tag.name', 'contactTag.contactId']
orderBy = dict(tag=[db.tag.name])

contactTag._plural = 'Contacts'
grid = SQLFORM.smartgrid(db.tag, columns=columns, details=False, 
orderby=orderBy,csv=False,paginate=15, maxtextlength=45)


return dict(grid=grid)

I then went to http://127.0.0.1:8000/testapp/default/tags and added a 
few tags...
Then went to http://127.0.0.1:8000/testapp/default/contacts and added a 
contact


then go back to http://127.0.0.1:8000/testapp/default/contacts and click 
on Tags.  Then click on the query button.  In the field drop-down, 
nothing appears:



-Jim


On 11/4/2011 10:39 PM, Massimo Di Pierro wrote:

Can you post your code? I cannot reproduce your problem. Which web2py
version?

On Nov 4, 4:26 pm, Jim Steil  wrote:

Hi

Testing some stuff with SQLFORM.smartgrid.  When using the query/search
on a related table, the query doesn't present any fields in the dropdown
list and no matter what I put in the search field, it returns 'Invalid
query'.

Is anyone else seeing this problem as well?

  -Jim

--
Jim Steil
VP of Information Technology
Quality Liquid Feeds, Inc.
608.935.2345 office
608.341.9896 cell
<>

[web2py] Re: new web site

2011-11-07 Thread mikech
Looks real good!

[web2py] Re: new web site

2011-11-07 Thread Omi Chiba
Looks great !

Can you add the link to web2py Japan under Documentation - Community
sources - Sites ?

web2py Japan
https://sites.google.com/site/web2pyjapan/

Thanks

On Nov 6, 2:02 pm, Massimo Di Pierro 
wrote:
> We have a new web site
>
>    http://web2py.com/new_examples
>
> Please check it out before we replace the old one.


[web2py] Book formatting error

2011-11-07 Thread Kevin Ivarsen
Hi folks,

I spotted a couple formatting errors in the online book today. In
chapter 7, under the section about the process and validate methods:

1. The formatting of the section header is a little strange - the
words "process" and "methods" are smaller than the rest of the text. I
assume that "validate", rather than "methods", should be a different
font size - this would indicate that the words "process" and
"validate" are function names. (Though from an aesthetic standpoint
I'd say the smaller font is too small for a section header.)

2. The bullet list describing "message_onsuccess",
"message_onfailure", and "next" is a little screwed up and difficult
to read. I suspect it's just a syntax problem in the book markup
that's throwing things off.


FWIW - back in March I had been given access as a book editor through
my gmail account, and I'd be happy to make these corrections, but it
seems that I'm no longer able to made edits. Does this permission
expire after some period of time?

Thanks,
Kevin


[web2py] Numbers Format

2011-11-07 Thread Franklin Freitas
In order to format numbers with thousands separator and custom number
of decimals, I created the following function and included it in my
"db.py" model so it could be accessed through the entire application.

def number_format(num, places=0):
return locale.format("%.*f", (places, num), True)

I use it my views like:

{{=number_format(x.vebamt,2)}}

It works great in my development environment, but after migrating it
to production (I am using a linode vps) the function doesn't work, I
doesn't give me an error, it just doesn't format the numbers.

Any ideas what could be wrong ? I searched the group for a solution
for formatting numbers and didn't find a previous post on this matter

Thanks for your help

Franklin


[web2py] Re: Online Book Typo

2011-11-07 Thread mikech
Ok I'm reading thru that chapter, and forward.  So I'll report what I find.

[web2py] Virtual Fields and usual database's Views

2011-11-07 Thread Daniel Aguayo
Hi all,

I'm confuse with this two questions:

1) Create Virtual Fields are similar to create usual Views in database
(mysql, postgres)?

2) What/How would you recommend to use for a search function? (just the
idea could be enough)

I haven't much experience with neither of both. I never used virtual fields
yet and I only created some database views in the university, but I think
that creating Views in the database would be better for performance, and
then using those views for building my virtual fields could be more
efficient than just making all operations in the virtual field (now sound a
kind of obvious ;O).

Can you help me with your point of view?

Thank you in advance.


[web2py] Re: we need some good web2py quotes ....

2011-11-07 Thread Cliff
As an independent software developer, I need to deliver quickly
without creating a trail of bugs to bite me later.  My first outing
with Web2py enabled me to meet these requirements and more.  I'm very
happy with Web2py, especially its fantastic community of developers
and users.

On Nov 7, 2:01 pm, Christopher Steel  wrote:
> Web2py is the "can do"  web development framework for "can do" developers.


Re: [web2py] Numbers Format

2011-11-07 Thread Vinicius Assef
Possibly the python version in your production server.

str.format() is available since python 2.6.

--
Vinicius Assef.


On Mon, Nov 7, 2011 at 7:41 PM, Franklin Freitas
 wrote:
> In order to format numbers with thousands separator and custom number
> of decimals, I created the following function and included it in my
> "db.py" model so it could be accessed through the entire application.
>
> def number_format(num, places=0):
>    return locale.format("%.*f", (places, num), True)
>
> I use it my views like:
>
> {{=number_format(x.vebamt,2)}}
>
> It works great in my development environment, but after migrating it
> to production (I am using a linode vps) the function doesn't work, I
> doesn't give me an error, it just doesn't format the numbers.
>
> Any ideas what could be wrong ? I searched the group for a solution
> for formatting numbers and didn't find a previous post on this matter
>
> Thanks for your help
>
> Franklin


[web2py] Re: SyntaxError: Set: no tables selected on select statement.

2011-11-07 Thread Cliff
Field('room','references room'),
should be
Field('room', db.room),


On Nov 7, 3:39 pm, Limedrop  wrote:
> A couple of obvious thing.  First, the query goes with the db() not
> the select().  Second, the reference to room is via room.id rather
> than room.name.  So you could try:
>
> reservations = db(db.reservation.room==room.id).select()
>
> On Nov 8, 8:49 am, Matthew Young  wrote:
>
>
>
>
>
>
>
> > Hello I am using the Version 1.99.3 (2011-11-07 17:41:19) dev version
> > of web2py.
>
> > I am having an issue with this view function:
> > def check_room_availability():
> >     room = db.room(request.args(0)) or redirect(URL('view_rooms'))
> >     reservations = db().select(db.reservation.room.name==room.name)
> >     return dict(room=room, reservations=reservations)
>
> > I get the following error when this page is viewed with a room number
> > passed as an argument:
> > Traceback (most recent call last):
> >   File "/home/mattosaurus/web2py/gluon/restricted.py", line 194, in
> > restricted
> >     in code it raises a RestrictedError containing the traceback.
> > layer is
> >   File "/home/mattosaurus/web2py/applications/roomReserve/controllers/
> > default.py", line 121, in 
> >   File "/home/mattosaurus/web2py/gluon/globals.py", line 149, in
> > 
> >     self.files = []            # used by web2py_ajax.html
> >   File "/home/mattosaurus/web2py/applications/roomReserve/controllers/
> > default.py", line 85, in check_room_availability
> >     reservations = db().select(db.reservation.room.name==room.name)
> >   File "/home/mattosaurus/web2py/gluon/dal.py", line 5697, in select
> >     db,
> >   File "/home/mattosaurus/web2py/gluon/dal.py", line 1225, in select
> >     sql_t += ' %s %s' % (icommand, str(t))
> >   File "/home/mattosaurus/web2py/gluon/dal.py", line 1128, in _select
> >     tablenames = self.tables(query)
> > SyntaxError: Set: no tables selected
>
> > My table definitions in db.py look like this:
> > db.define_table('room',
> >     Field('name'),
> >     Field('description','text'),
> >     Field('location','text'),
> >     format='%(name)s')
>
> > db.define_table('reservation',
> >     Field('room','references room'),
> >     Field('start_date','datetime'),
> >     Field('end_date','datetime'),
> >     Field('special_requirements','text'),
> >     Field('approved','boolean'),
> >     auth.signature)
>
> > db.reservation.room.requires = IS_IN_DB(db,db.room.id,'%(name)s')
> > db.room.name.requires = IS_NOT_EMPTY()
> > db.room.description.requires = IS_NOT_EMPTY()
> > db.room.location.requires = IS_NOT_EMPTY()
> > db.reservation.start_date.requires = IS_NOT_EMPTY()
> > db.reservation.end_date.requires = IS_NOT_EMPTY()
>
> > Has anyone seen this error before? Is my select incorrect? I am
> > finding the documentation a little confusing in this area.


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

2011-11-07 Thread Vinicius Assef
I can try to help, too.



On Fri, Nov 4, 2011 at 5:26 PM, Gour  wrote:
> On Fri, 4 Nov 2011 10:38:06 -0700 (PDT)
> Massimo Di Pierro
>  wrote:
>
>> perhaps we should make a list of desired features.
>
> I believe that WordPress is quite etablished as Blog engine and CMS
> platform, so making Instant Press as "Python's WordPress" would be
> cool, iow, stable blog/CMS + support for easy styling/theming along
> with solid framework to write plugins...
>
> I'd be more than satisfied and would try to contribute to make it
> happen!
>
>
> Sincerely,
> Gour
>
> --
>


[web2py] Re: Online Book Typo

2011-11-07 Thread Andrew
I'm going through the book in detail looking for typos, and trying to
absorb some more learnings at the same time.  By all means go ahead,
but we may be doubling up in effort.  May I suggest waiting for a
cleaned up Version 3.3 ?  I hope it will only contain one or two
missed typos that may need many eyes to find.

Regards
Andrew

P.S.  You did find one in a chapter that I had already reviewed :)


On Nov 8, 10:44 am, mikech  wrote:
> Ok I'm reading thru that chapter, and forward.  So I'll report what I find.


[web2py] Re: Book formatting error

2011-11-07 Thread Anthony
On Monday, November 7, 2011 4:34:26 PM UTC-5, Kevin Ivarsen wrote:
>
> FWIW - back in March I had been given access as a book editor through 
> my gmail account, and I'd be happy to make these corrections, but it 
> seems that I'm no longer able to made edits. Does this permission 
> expire after some period of time?


The online book is locked right now because it's in the middle of a major 
update (4th edition). It should be editable again after the new version is 
released.

Anthony 


[web2py] Determining Local Server Filepath for Uploaded Files

2011-11-07 Thread D.P. Clark
Anyone know how to pull an uploaded file from the database locally on the
server?  I want to do some server-side processing on the file and then
re-insert it to the database.  I'm not sure I understand how to get the
local path on the server of the uploaded file.  The static/upload directory
appends an random ID to the files.  How can I get the path to an uploaded
file so that I can manipulate it?


I'm using a standard model form like the following:

db=DAL('sqlite://storage.db')
db.define_table('test',
Field('package_name'),
Field('attachment','upload',default=''))

My controller:

form=SQLFORM(db.testplug)
if form.accepts(request.vars):
response.flash='Files uploaded'
filename = request.vars.attachment.filename
filereference = request.vars.attachment.file
print filename
print filereference
records=SQLTABLE(db().select(db.test.ALL),upload=download)
return dict(form=form,records=records)





My view:

{{=records}}

[{{=A('delete all',_href=URL('delete_storage'))}}]


[web2py] Re: SyntaxError: Set: no tables selected on select statement.

2011-11-07 Thread Matthew Young
I get the following error with those changes:
Traceback (most recent call last):
  File "/home/mattosaurus/web2py/gluon/restricted.py", line 204, in
restricted
exec ccode in environment
  File "/home/mattosaurus/web2py/applications/roomReserve/views/
default/check_room_availability.html", line 84, in 
  File "/home/mattosaurus/web2py/gluon/html.py", line 230, in URL
function = f.__name__
AttributeError: 'int' object has no attribute '__name__'

On Nov 7, 2:39 pm, Limedrop  wrote:
> A couple of obvious thing.  First, the query goes with the db() not
> the select().  Second, the reference to room is via room.id rather
> than room.name.  So you could try:
>
> reservations = db(db.reservation.room==room.id).select()
>
> On Nov 8, 8:49 am, Matthew Young  wrote:
>
>
>
>
>
>
>
> > Hello I am using the Version 1.99.3 (2011-11-07 17:41:19) dev version
> > of web2py.
>
> > I am having an issue with this view function:
> > def check_room_availability():
> >     room = db.room(request.args(0)) or redirect(URL('view_rooms'))
> >     reservations = db().select(db.reservation.room.name==room.name)
> >     return dict(room=room, reservations=reservations)
>
> > I get the following error when this page is viewed with a room number
> > passed as an argument:
> > Traceback (most recent call last):
> >   File "/home/mattosaurus/web2py/gluon/restricted.py", line 194, in
> > restricted
> >     in code it raises a RestrictedError containing the traceback.
> > layer is
> >   File "/home/mattosaurus/web2py/applications/roomReserve/controllers/
> > default.py", line 121, in 
> >   File "/home/mattosaurus/web2py/gluon/globals.py", line 149, in
> > 
> >     self.files = []            # used by web2py_ajax.html
> >   File "/home/mattosaurus/web2py/applications/roomReserve/controllers/
> > default.py", line 85, in check_room_availability
> >     reservations = db().select(db.reservation.room.name==room.name)
> >   File "/home/mattosaurus/web2py/gluon/dal.py", line 5697, in select
> >     db,
> >   File "/home/mattosaurus/web2py/gluon/dal.py", line 1225, in select
> >     sql_t += ' %s %s' % (icommand, str(t))
> >   File "/home/mattosaurus/web2py/gluon/dal.py", line 1128, in _select
> >     tablenames = self.tables(query)
> > SyntaxError: Set: no tables selected
>
> > My table definitions in db.py look like this:
> > db.define_table('room',
> >     Field('name'),
> >     Field('description','text'),
> >     Field('location','text'),
> >     format='%(name)s')
>
> > db.define_table('reservation',
> >     Field('room','references room'),
> >     Field('start_date','datetime'),
> >     Field('end_date','datetime'),
> >     Field('special_requirements','text'),
> >     Field('approved','boolean'),
> >     auth.signature)
>
> > db.reservation.room.requires = IS_IN_DB(db,db.room.id,'%(name)s')
> > db.room.name.requires = IS_NOT_EMPTY()
> > db.room.description.requires = IS_NOT_EMPTY()
> > db.room.location.requires = IS_NOT_EMPTY()
> > db.reservation.start_date.requires = IS_NOT_EMPTY()
> > db.reservation.end_date.requires = IS_NOT_EMPTY()
>
> > Has anyone seen this error before? Is my select incorrect? I am
> > finding the documentation a little confusing in this area.


[web2py] Re: Determining Local Server Filepath for Uploaded Files

2011-11-07 Thread Anthony
When you upload a file via an upload field, by default it goes into the 
/web2py/applications/yourapp/uploads folder, though you can specify a 
different folder via the 'uploadfolder' argument to Field(). The file 
itself is renamed (for security reasons) to 
[tablename].[fieldname].[16-char-uuid].[b16encoded-original-filename].[original-extension].
 
This new name is what gets stored in the upload field (the 'attachment' 
field in your case). If you want to access the file, you can retrieve the 
name from the 'attachment' field, and use that along with the path to the 
'uploads' folder (or whatever folder you set for uploads).

Note, if you do any processing of the file, there's no need to "re-insert" 
anything in the database, as the database merely stores the filename.

Anthony

On Monday, November 7, 2011 6:07:10 PM UTC-5, D.P. wrote:
>
> Anyone know how to pull an uploaded file from the database locally on the 
> server?  I want to do some server-side processing on the file and then 
> re-insert it to the database.  I'm not sure I understand how to get the 
> local path on the server of the uploaded file.  The static/upload directory 
> appends an random ID to the files.  How can I get the path to an uploaded 
> file so that I can manipulate it?
>
>
> I'm using a standard model form like the following:
>
> db=DAL('sqlite://storage.db')
> db.define_table('test',
> Field('package_name'),
> Field('attachment','upload',default=''))
>
> My controller:
>
> form=SQLFORM(db.testplug)
> if form.accepts(request.vars):
> response.flash='Files uploaded'
> filename = request.vars.attachment.filename
> filereference = request.vars.attachment.file
> print filename
> print filereference
> records=SQLTABLE(db().select(db.test.ALL),upload=download) 
> return dict(form=form,records=records)
>
>
>
>
>
> My view:
>
> {{=records}}
>
> [{{=A('delete all',_href=URL('delete_storage'))}}]
>
>
>
>

[web2py] Re: Online Book Typo

2011-11-07 Thread Anthony
FYI, I am not specifically looking for typos, but I am adding a bunch of 
material to the book and reviewing most of the newer material, so I'm 
catching a lot of typos and errors as well. So, as Andrew says, most of the 
typos and formatting issues will likely be resolved by the next release.

Anthony

On Monday, November 7, 2011 5:54:37 PM UTC-5, Andrew wrote:
>
> I'm going through the book in detail looking for typos, and trying to 
> absorb some more learnings at the same time.  By all means go ahead, 
> but we may be doubling up in effort.  May I suggest waiting for a 
> cleaned up Version 3.3 ?  I hope it will only contain one or two 
> missed typos that may need many eyes to find. 
>
> Regards 
> Andrew 
>
> P.S.  You did find one in a chapter that I had already reviewed :) 
>
>
> On Nov 8, 10:44 am, mikech  wrote: 
> > Ok I'm reading thru that chapter, and forward.  So I'll report what I 
> find.



[web2py] Re: RSS newbie

2011-11-07 Thread Anthony
On Monday, November 7, 2011 3:21:25 PM UTC-5, Paul wrote:
>
> I do not see the right-hand side menu shown in the book Overview page 
> shortly after the start of RSS feed discussion. It seems to vary by 
> browser.
>

Yes, that menu is not generated by web2py. An RSS feed is really just some 
raw data delivered in a specific format. It is up to the RSS reader to 
determine how to display it, so it will vary depending on the browser (or 
dedicated RSS reader). web2py doesn't have any control over that.
 

> Also, viewing this RSS fied with Google Chrome 15.0.874.106 m displays 
> raw XML. Is there a setting that I need to change?


 I'm not sure Chrome has a builtin RSS reader. Try this: 
http://www.google.com/support/chrome/bin/answer.py?hl=en&answer=173637

Anthony


Re: [web2py] GAE & Python 2.7 update

2011-11-07 Thread Jonathan Lundell
On Nov 5, 2011, at 5:24 PM, Massimo Di Pierro wrote:

> I know I said otherwise before but perhaps we should continue to
> default to 2.5 until App Launcher supports 2.7

I just got Launcher 1.6.0, and it appears to support 2.7.

> 
> On Nov 5, 1:28 pm, Jonathan Lundell  wrote:
>> I thought I'd pass on my recent experience deploying an app to GAE with 
>> Python 2.7. My motivation was the new features available, in particular 
>> concurrent requests and WSGI operation, and secondarily some other 
>> performance improvements (like the native JSON library). 
>> Seehttp://code.google.com/appengine/docs/python/python27/newin27.htmlfor 
>> more info.
>> 
>> There are a couple of downsides.
>> 
>> 1. The App Launcher doesn't support 2.7 yet, so you need to deploy from the 
>> command line. I'm not entirely clear on whether there's any way at all to 
>> run a 2.7 app locally.
>> 
>> 2. You must use the High Replication datastore. That's not necessarily a bad 
>> thing, but a) it's more expensive (if you have enough traffic to be paying), 
>> and b) run_in_transaction only works with ancestor queries, which the DAL 
>> does not support.
>> 
>> Fortunately, my db requirements aren't too complicated, and I was able to 
>> put all my db accesses behind a class that allowed me to talk to the 
>> datastore through its native API while preserving compatibility with DAL on 
>> other servers. (There were some other advantages to doing this, and it was 
>> an interesting learning experience.)
>> 
>> The trunk's app.example.yaml defaults to 2.7; that part was fairly simple 
>> (it supports 2.5 as well; just change some commenting-out stuff).
>> 
>> I like the way GAE is going, and I really like being able to deploy an app 
>> in the cloud without having to become a sysadmin.




[web2py] Re: SyntaxError: Set: no tables selected on select statement.

2011-11-07 Thread Limedrop
Well that's progress.  The error is somewhere in your view.

On Nov 8, 12:20 pm, Matthew Young  wrote:
> I get the following error with those changes:
> Traceback (most recent call last):
>   File "/home/mattosaurus/web2py/gluon/restricted.py", line 204, in
> restricted
>     exec ccode in environment
>   File "/home/mattosaurus/web2py/applications/roomReserve/views/
> default/check_room_availability.html", line 84, in 
>   File "/home/mattosaurus/web2py/gluon/html.py", line 230, in URL
>     function = f.__name__
> AttributeError: 'int' object has no attribute '__name__'
>
> On Nov 7, 2:39 pm, Limedrop  wrote:
>
>
>
> > A couple of obvious thing.  First, the query goes with the db() not
> > the select().  Second, the reference to room is via room.id rather
> > than room.name.  So you could try:
>
> > reservations = db(db.reservation.room==room.id).select()
>
> > On Nov 8, 8:49 am, Matthew Young  wrote:
>
> > > Hello I am using the Version 1.99.3 (2011-11-07 17:41:19) dev version
> > > of web2py.
>
> > > I am having an issue with this view function:
> > > def check_room_availability():
> > >     room = db.room(request.args(0)) or redirect(URL('view_rooms'))
> > >     reservations = db().select(db.reservation.room.name==room.name)
> > >     return dict(room=room, reservations=reservations)
>
> > > I get the following error when this page is viewed with a room number
> > > passed as an argument:
> > > Traceback (most recent call last):
> > >   File "/home/mattosaurus/web2py/gluon/restricted.py", line 194, in
> > > restricted
> > >     in code it raises a RestrictedError containing the traceback.
> > > layer is
> > >   File "/home/mattosaurus/web2py/applications/roomReserve/controllers/
> > > default.py", line 121, in 
> > >   File "/home/mattosaurus/web2py/gluon/globals.py", line 149, in
> > > 
> > >     self.files = []            # used by web2py_ajax.html
> > >   File "/home/mattosaurus/web2py/applications/roomReserve/controllers/
> > > default.py", line 85, in check_room_availability
> > >     reservations = db().select(db.reservation.room.name==room.name)
> > >   File "/home/mattosaurus/web2py/gluon/dal.py", line 5697, in select
> > >     db,
> > >   File "/home/mattosaurus/web2py/gluon/dal.py", line 1225, in select
> > >     sql_t += ' %s %s' % (icommand, str(t))
> > >   File "/home/mattosaurus/web2py/gluon/dal.py", line 1128, in _select
> > >     tablenames = self.tables(query)
> > > SyntaxError: Set: no tables selected
>
> > > My table definitions in db.py look like this:
> > > db.define_table('room',
> > >     Field('name'),
> > >     Field('description','text'),
> > >     Field('location','text'),
> > >     format='%(name)s')
>
> > > db.define_table('reservation',
> > >     Field('room','references room'),
> > >     Field('start_date','datetime'),
> > >     Field('end_date','datetime'),
> > >     Field('special_requirements','text'),
> > >     Field('approved','boolean'),
> > >     auth.signature)
>
> > > db.reservation.room.requires = IS_IN_DB(db,db.room.id,'%(name)s')
> > > db.room.name.requires = IS_NOT_EMPTY()
> > > db.room.description.requires = IS_NOT_EMPTY()
> > > db.room.location.requires = IS_NOT_EMPTY()
> > > db.reservation.start_date.requires = IS_NOT_EMPTY()
> > > db.reservation.end_date.requires = IS_NOT_EMPTY()
>
> > > Has anyone seen this error before? Is my select incorrect? I am
> > > finding the documentation a little confusing in this area.- Hide quoted 
> > > text -
>
> - Show quoted text -


[web2py] Subfolders under /static/img

2011-11-07 Thread Spring
Hello there,

I have created subfolders under static/img for better img organizing. When 
tested with web2py and GAE launcher, it works fine. But when I tried to 
deploy on GAE, in the console it says "cloning 170 files; cloned 100 
files". When I check the webpage on mydomain.com, all img under subfolder 
of static/img are not available. Obviously, subfolders under static/img 
were not deployed. 

Is there any config to include the those subfolders, or this kind of 
subfolder under /static/img is not supported, ie. all img have to be under 
/static/img.

Thanks.

-Spring


[web2py] new welcome app - need help with css

2011-11-07 Thread Massimo Di Pierro
There is a new welcome app in trunk. It uses Skeleton for flexible
grid layout that works on mobile and jquery.dropdown.js instead of
superfish.js.

There are two problems:
1) the footer of the page is shifted of few pixels respect to the
statusbar. (needs to be fixed in views/layout.html)
2) if your return
dict(grid=SQLFORM.grid(db.auth_user),user_signature=False) the grid
appears completely messed up. (needs to be fixed in static/css/
web2py.css)
3) there are two types of button styles (some defined in skeleton.css
and some in web2py.css). we should use the skeleton ones everywhere
and minimize the code in web2py.css.

Any CSS expert who can help with these issues?

Massimo


[web2py] Re: Powertable and DAL count

2011-11-07 Thread Wes Hall
Pat,

I have a hard time hanging with you west-coasters some time.

Thank you for your assistance.  I was able to reference the field directly 
into the columns with 'COUNT(events.email)', but wasn't finding it when I 
was in the Virtual class.  _extra was the key. 

def event_list(): 
> class Virtual(object): 
> @virtualsettings(label='Count') 
> def email_count(self): 
> return ??? # What do I need to reference? 


is now

def event_list(): 
class Virtual(object): 
@virtualsettings(label='Count') 
def email_count(self): 
return self._extra(count1)
 
, and life is peachy.

Both 
table.columns = ['COUNT(events.email)','events.email'] 
& 
table.columns = ['virtual.email_count','events.email'] 
now work as expected.

Thanks again
wh


[web2py] Re: Book formatting error

2011-11-07 Thread Kevin Ivarsen
Thanks Anthony - good to know.

Another typo I spotted this evening is in Chapter 4 under "Running
tasks in the background". I think:

"Threads and recycles for efficiency and managed by the web server."

should be:

"Threads are recycled for efficiency and managed by the web server."

Cheers,
Kevin



On Nov 7, 2:57 pm, Anthony  wrote:
> On Monday, November 7, 2011 4:34:26 PM UTC-5, Kevin Ivarsen wrote:
>
> > FWIW - back in March I had been given access as a book editor through
> > my gmail account, and I'd be happy to make these corrections, but it
> > seems that I'm no longer able to made edits. Does this permission
> > expire after some period of time?
>
> The online book is locked right now because it's in the middle of a major
> update (4th edition). It should be editable again after the new version is
> released.
>
> Anthony


Re: [web2py] Mixing/supporting CMS with Web2py

2011-11-07 Thread ~redShadow~
I have quite large experience with Drupal, which I used since 2006 tu
build pretty much everything web-related, from websites to applications,
often using it more as a framework than a CMS.
That project is great, but IMHO it has some drawbacks.
The first that comes to mind:

* Not-so-elegant code, derived from the fact that's php-based
* Structure and data too much mixed up, due to the will to make
everything configurable from the admin panel.
* Excessive setup time. Many times 3rd-part modules (sometimes even
needed to add missing important features to the core) tend to conflict
or miss something -> many times there is need to develop a custom
site-specific module in order to simplify things.
* Lack of enterpriseness in 3rd-part modules: they are not "verified"
that much, and sometimes bad things happen, even with stuff that used to
work and must have continued to do so.

So, I recently started doing some experiments to see "how hard would it
be" to rewrite Drupal web2py-based and with some improvements.

At the moment, I have a simple app that, along with
garbage/experiments/stuff does pretty much this:

* CRUD for different content-types (each content type may be treated in
different ways / define extra fields / ..; some examples may be
"article", "page", "ecommerce product", ...).
* Commenting. It is handled in a component-like way, although I haven't
written a proper component yet, I'm using a similar way to attach
comments + comment form to "entities", that might be not only "content".
* Regions + blocks. In a way similar to what Drupal does, the
layout.html defines some regions (sidebars, footer, before/after
content, before/after page, ...) in which some "blocks" may be placed,
then blocks are shown independently from the controller (and only in the
html views, since they wouldn't make much sense, for example, in a json
or xml representation).
* Configuration stored in INI files (and maybe in database too, I have
to decide that).
* Some rudimental support (I still have to decide what's the best way to
do that) to user-defined (in the configuration) "views": a mix of
database query + templates to create custom visualizations of content.

I'm going to release all the code as soon as I finish adding access
control, so that I can also install a demo site somewhere (shouldn't
take long, it should only be matter of adding a few decorators..).


I think we should also start organizing the development of the CMS
application:
- who's up for development?
- who's up for testing?
- who's up for documentation? (developers should! documentation is
awesome! I already wrote more documentation than code for this CMS!)
- should we setup a project page / wiki / bugtracker / ..? I think that
it would be a good idea to have at least a wiki, for the moment, on
which to write all the ideas / misc brainstorming, in order to discuss
about the important decisions that should be taken before starting the
actual development.
- should we create another mailing-list just for the cms thing, in order
to keep separate the discussions?
- Do you guys use IRC? I see a #web2py channel on freenode but, although
there is always some people in it, I never saw pretty much anybody
speaking in there..

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



signature.asc
Description: This is a digitally signed message part


[web2py] Re: Powertable and DAL count

2011-11-07 Thread Wes Hall
Anthony,

Aha, thanks for the wisdom. From the CLI and if I build the table manually, 
you are correct, it works as expected. It appears as though the powertable 
plugin has some specific column requirements, so I'm now referencing the 
fields/columns as such:

table.columns = [str(count1),'events.email'] 

That should cover any db specifics as it references the abstracted query, 
right?

Thanks,
wh


[web2py] Re: Powertable and DAL count

2011-11-07 Thread Anthony
On Monday, November 7, 2011 11:57:52 PM UTC-5, Wes Hall wrote:
>
> Anthony,
>
> Aha, thanks for the wisdom. From the CLI and if I build the table 
> manually, you are correct, it works as expected. It appears as though the 
> powertable plugin has some specific column requirements, so I'm now 
> referencing the fields/columns as such:
>
> table.columns = [str(count1),'events.email'] 
>
> That should cover any db specifics as it references the abstracted query, 
> right?
>

I think so.


Re: [web2py] Re: Please help me understand how 'lambda row, rc' works

2011-11-07 Thread Johann Spies
I found the cause of the problem: I used the suggest-widget with the doc_nr
field and specified an id-field without specifying 'keyword' as in the
documentation.  This worked well in SQLFORM.factory but not in the model.

Removing the 'id_field' argument solved the problem.

Regards
Johann

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


Re: [web2py] Re: Please help me understand how 'lambda row, rc' works

2011-11-07 Thread Johann Spies
Apologies, I replied to the wrong thread.  Ignore my previous email in this
context please.

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


Re: [web2py] Re: Please help met to see the mistake causing this Valueerror

2011-11-07 Thread Johann Spies
Thanks for your attention Massimo.

I found the cause of the problem: I used the suggest-widget with the doc_nr
field and specified an id-field without specifying 'keyword' as in the
documentation.  This worked well in SQLFORM.factory but not in the model.

db.akb_doccenter.doc_nr.widget = suggest_widget(db.akb_doccenter.doc_nr,
  id_field = db.akb_doccenter.id
,
  limitby = (0, 8), min_length
= 2)


Removing the 'id_field' argument solved the problem.

Regards
Johann


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