[web2py] how to use javascript code in web2py html pages?

2012-08-23 Thread Amit
Hi,
I have html file with one text field with submit button inside form.I added 
javascript code to validate the textfield but its not working at all, why 
is it so? does web2py not support javascript function?

please check below the code :


function textFieldValidation()
{
var x=document.forms["text_form"]["test_textField"].value
if (x==null || x==""||x=="00:00:00:00:00:00")
  {
  alert("text field should not be empty");
  return false;
  }
}



In form tag:




  Enter value:
  








-- 





[web2py] About the Scheduler

2012-08-23 Thread Martin Weissenboeck
I have tried the examples found in the book and the scheduler works very
fine as expected. But how to use it in "real life"?
My questions:

   - I have written an application with contains only the scheduler. It
   woks, but does the scheduler need it's own application? What is the best
   way to communicate between the Scheduler and the Main application
   - Then I have tried to add a scheduler to an existing application. The
   worker shows it's heartbeat, but does not pick up any task, What could be
   wrong?
   - What is the best way to start both (scheduler and other application)
   in Linux and in Windows?
   python web2py.py myapp -K myscheduler is the wrong way
   - In the scheduler_worker there is a field called "is_ticker": what does
   it mean?


Regards, Martin

-- 





Re: [web2py] Re: Google group again

2012-08-23 Thread apps in tables
in this page:

https://groups.google.com/forum/?fromgroups=#!forum/web2py 

On Friday, August 24, 2012 7:05:49 AM UTC+3, apps in tables wrote:
>
> the upper right corner has the number of topics, above it the members 
> button , clicking it will show the members.
>
> On Friday, August 24, 2012 7:02:03 AM UTC+3, Massimo Di Pierro wrote:
>>
>> How 
>> Did
>> Yoy
>> Do
>> It
>> ?
>
>

-- 





Re: [web2py] Re: Google group again

2012-08-23 Thread apps in tables
the upper right corner has the number of topics, above it the members 
button , clicking it will show the members.

On Friday, August 24, 2012 7:02:03 AM UTC+3, Massimo Di Pierro wrote:
>
> How 
> Did
> Yoy
> Do
> It
> ?

-- 





[web2py] Re: Trunk > 20012-08-19 formatting

2012-08-23 Thread Simon Ashley
The last issue resolved and re iteration of a warning to others. 
*Don't use more than one SQLFORM.grid on a form.*


On Friday, 24 August 2012 12:32:01 UTC+10, Simon Ashley wrote:
>
> That's OK. 
> I'm not sure with the styling of the Export at bottom of the screen but no 
> biggy.
>
> The main issue that I'm working through is that a working app in a trunk 
> from 2012-07-21 is broken in the current trunk.
>
> One issue appears to be related to the auth_users table. 
> Would not play nicely with 2012-08-19 and the fix was to delete the table 
> and manually recreate it.
> (couldn't see any reason from tools.py, as table defs looked the same)
>
> An unresolved issue is with a .represent link loading the calling, rather 
> than the called form in the target div (2012-07-21 works perfectly) i.e.
>
> db.RaceData.date.represent = lambda value,row: A(value, callback=URL(app,
> "race","Rcard",args=[row.date,row.course]),target="Rcard")
>
>
>
>
> On Friday, 24 August 2012 11:58:41 UTC+10, Massimo Di Pierro wrote:
>>
>> Yes. The grid was an experimental feature in 1.99.7. We are still making 
>> minor tweaks to it. 
>> The query button is gone because its effect can be achieved by giving 
>> focus to the search input.
>> The add button moved up to save space.
>> The export feature has been improved. There are many export options and 
>> we thought a good way was to add links at the bottom.
>>
>> Notice that the old export form was problematic because did not work well 
>> with LOADed grids.
>>
>> Anyway, it should not break existing functionality. Doesn't it look 
>> better now?
>>
>> Massimo
>>
>> On Thursday, 23 August 2012 20:47:03 UTC-5, Simon Ashley wrote:
>>>
>>> Its appears that SQLFORM.grid formatting has changed recently in the 
>>> trunk:
>>> (with no change to the application)
>>>
>>>
>>>- The Query button has been dropped, 
>>>- Add button moved to on top of the query field.
>>>- Export function changed from before the table to after with 
>>>hyperlinks options rather than drill down box selections
>>>
>>>
>>> Is this an intentional move?
>>>
>>>
>>> 
>>>
>>>

-- 





Re: [web2py] Re: NoSQL Question Again!!!

2012-08-23 Thread apps in tables
what about the search?

On Friday, August 24, 2012 7:00:27 AM UTC+3, Massimo Di Pierro wrote:
>
> You can always pickle a python dict in a text field in sql database
>

-- 





Re: [web2py] Re: Google group again

2012-08-23 Thread Massimo Di Pierro
How 
Did
Yoy
Do
It
?

-- 





Re: [web2py] Re: NoSQL Question Again!!!

2012-08-23 Thread Massimo Di Pierro
You can always pickle a python dict in a text field in sql database

-- 





Re: [web2py] Re: Google group again

2012-08-23 Thread apps in tables
18252 topics 

-- 





Re: [web2py] Re: Google group again

2012-08-23 Thread apps in tables
4143 members 


-- 





Re: [web2py] Re: Google group again

2012-08-23 Thread apps in tables
web2py-users  
(Member)
Interest in web2py, former Gluon (for users) http://www.web2py.com 
Developers should also join: 
http://groups.google.com/group/web2py-developers
18252 topics last post: 6:45 AM (7 minutes ago)
web2py-developers
If you are here you know what this is about. If you are a web2py user, not 
a developer, please use web2py-users.
732 topics last post: 2:59 AM (3 hours ago)

> I did search on the groups level
>

-- 





Re: [web2py] Re: Google group again

2012-08-23 Thread Jonathan Lundell
On 23 Aug 2012, at 7:37 PM, Anthony  wrote:
> I'm not sure it's possible any more.

That's my impression.

> On Thursday, August 23, 2012 10:11:36 PM UTC-4, Massimo Di Pierro wrote:
> Does anybody know how to check how many members and how many posts are in 
> this group?
> 
> 


-- 





Re: [web2py] SQLFORM key error

2012-08-23 Thread pylix
I'm an idiot... 
the software works fine
I just forgot to name the
model appropriately(it wasn't named like the controller).
sorry for using up your
resources on this silly mistake
I'll try to troubleshoot more own
my own in the future.

On Thursday, August 23, 2012 9:49:14 PM UTC-4, Massimo Di Pierro wrote:
>
> We have posted some broken web2py version to perform some experiments. You 
> may have gotten one of them.  Download it again now. It is a release 
> candidate and should be better than 1.99.7.
>
> On Thursday, 23 August 2012 20:17:02 UTC-5, pylix wrote:
>>
>> 1.99.7 stable i think it's the latest downloaded it recently
>> but i'm on a windows machine, maybe that's the issue?
>>
>> On Thursday, August 23, 2012 9:04:41 PM UTC-4, rochacbruno wrote:
>>>
>>> web2py version??
>>>
>>>
>>> On Thu, Aug 23, 2012 at 10:00 PM, pylix  wrote:
>>>
 Here's my model

 db = DAL('sqlite://storage.sqlite')
 db.define_table('person',
 Field('name', requires=IS_NOT_EMPTY()),
 Field('phone', requires=IS_NOT_EMPTY()),
 Field('address', requires=IS_NOT_EMPTY()),
 Field('city', requires=IS_NOT_EMPTY()),
 Field('state', requires=IS_IN_SET(['NY' ,'NJ' ,'CN'])),
 Field('zip', requires=IS_NOT_EMPTY()),
 Field('year', requires=IS_NOT_EMPTY()),
 Field('model', requires=IS_NOT_EMPTY()),
 Field('make', requires=IS_NOT_EMPTY()),
 Field('engine', requires=IS_NOT_EMPTY()),
 Field('starts', 'boolean'),
 Field('foward', 'boolean'),
 Field('reverse', 'boolean'),
 Field('complaint', 'text'))

 the controller is

 def freequote():
 form = SQLFORM(db.person)
 return dict(form=form)

 and the view

 {{extend 'layout.html'}}
 {{=form}}

 I'm getting this error when i try to view the page
  'person'

 Traceback (most recent call last):
 File "gluon/restricted.py", line 205, in restricted


 File "/controllers/default.py" 
 ,
  line 10, in 

 File "gluon/globals.py", line 173, in 

 File "/controllers/default.py" 
 ,
  line 8, in freequote


 File "gluon/dal.py", line 6343, in __getattr__


 File "gluon/dal.py", line 6337, in __getitem__


 KeyError: 'person'


 not sure why i'm getting a keyerror is the table is defined.

 -- 
  
  
  

>>>
>>>

-- 





Re: [web2py] Re: NoSQL Question Again!!!

2012-08-23 Thread apps in tables
*

"A DBA walks into a NOSQL bar, but turns and leaves because he couldn't 
find atable"
*

Regarding nosql, I am interested in the benefit of not having a schema, 
specially, when it is complex and changing.

I think this is the main advantage of nosql no schema 
means maximum flexibility.

The data of an application can be divided into  two groups:

1- simple ( easy to discover the data model and stable ) .. list of users , 
list of items , list of locations,... and their relations

can be done by web2py DAL .

2- complex ... documents , their contents and flow of the documents 
(workflow)...job order , service order, parts request , rfq , quotation , 
invoice ,purchase order... 

can be done by web2py and pymongo no DAL ...


Extension of web2py to include (2) will be great, but an example of (1) and 
(2) working together is a enough for me.( eg. workflow)

Regards,

Ashraf

 

-- 





[web2py] Re: prevent future date being selected

2012-08-23 Thread Stephen Logan
Thanks again Anthony! Thats perfect

On Friday, 24 August 2012 14:42:04 UTC+12, Anthony wrote:
>
> Use the IS_DATE_IN_RANGE validator -- see 
> http://web2py.com/books/default/chapter/29/7#Validators for details. 
> Maybe something like:
>
> IS_DATE_IN_RANGE(maximum=request.now.date())
>
> Anthony
>
> On Thursday, August 23, 2012 10:24:14 PM UTC-4, Stephen Logan wrote:
>>
>> Hi Guys
>> Having a crack at my first webapp and stuck on the model:(
>>
>> What i want to do is record how far i have run on a particular day... 
>> QUESTION: how do i prevent a user from selecting a day in the future? as 
>> it is invalid
>>
>>
>> Thanks in Advance
>>
>> Stephen
>>
>

-- 





[web2py] web2py nginx and uwsgi

2012-08-23 Thread FERNANDO VILLARROEL
Dear.

I am new in web developing and  always i used sample apache config. But i see 
many post about my subject, so I would like use it.

Also I would like to integrate git to development environment, now i do using 
trac + svn for my standalone projects.

I am following the follow howto:

http://alvarolizama.net/2012/06/30/mi-configuracion-para-servidores-con-python/

But i am some confused.

I would like to learn how to set up a development and production environment 
for web2py with nginx + uwsgi. 

Does anyone know some howto for beginners?

Does anyone let me know some links or how i can do slowly so i will can 
understanding?


Regards.

-- 





Re: [web2py] Re: how to parse xml in web2py?

2012-08-23 Thread Amit
Thanks guys for helping me to write xml parsing in python..I will use
ElementTree Or cElementTree to extract data from xml and let you people
know about the outcome.

@Anthony: My mistatke :( , I manually written the xml so did mistake on
matching opening and closing tags.

Thanks once again
Amit

On Thu, Aug 23, 2012 at 8:48 PM, villas  wrote:

> If the XML is not well-formed, take a look at beautiful soup.   I have
> never found a parser so tolerant and forgiving.
>
>
> On Thursday, August 23, 2012 2:59:25 PM UTC+1, Anthony wrote:
>>
>> For simple parsing, you can also use the built-in TAG() helper -- see
>> http://web2py.com/books/**default/chapter/29/5#Parsing
>> .
>>
>> FYI, in your example, some of the closing tags do not match their
>> associated opening tags.
>>
>> Anthony
>>
>> On Thursday, August 23, 2012 5:53:32 AM UTC-4, Amit wrote:
>>>
>>> Hi,
>>> I have web service method in my application which will receive xml file
>>> from the request, i need to parse it and save the extracted data to the
>>> database. Please suggest me the best way to parse xml in web2py.
>>>
>>> xml format would be like below:
>>>
>>> 
>>> 
>>>   
>>> 123456
>>> 2012-06-30
>>> 1
>>> **adadafdfdgfgfhggjghjjj
>>>   
>>> 
>>>
>>  --
>
>
>
>

-- 





[web2py] Re: prevent future date being selected

2012-08-23 Thread Anthony
Use the IS_DATE_IN_RANGE validator -- see 
http://web2py.com/books/default/chapter/29/7#Validators for details.

Anthony

On Thursday, August 23, 2012 10:24:14 PM UTC-4, Stephen Logan wrote:
>
> Hi Guys
> Having a crack at my first webapp and stuck on the model:(
>
> What i want to do is record how far i have run on a particular day... 
> QUESTION: how do i prevent a user from selecting a day in the future? as 
> it is invalid
>
>
> Thanks in Advance
>
> Stephen
>

-- 





[web2py] prevent future date being selected

2012-08-23 Thread Stephen Logan
Hi Guys
Having a crack at my first webapp and stuck on the model:(

What i want to do is record how far i have run on a particular day... 
QUESTION: how do i prevent a user from selecting a day in the future? as it 
is invalid


Thanks in Advance

Stephen

-- 





[web2py] Re: Google group again

2012-08-23 Thread Anthony
I'm not sure it's possible any more.

On Thursday, August 23, 2012 10:11:36 PM UTC-4, Massimo Di Pierro wrote:
>
> Does anybody know how to check how many members and how many posts are in 
> this group?

-- 





[web2py] Re: Trunk > 20012-08-19 formatting

2012-08-23 Thread Simon Ashley
That's OK. 
I'm not sure with the styling of the Export at bottom of the screen but no 
biggy.

The main issue that I'm working through is the a working app in a trunk 
from 2012-07-21 is broken in the current trunk.

One issue appears to be related to the auth_users table. 
Would not play nicely with 2012-08-19 and the fix was to delete the table 
and manually recreate it.
(couldn't see any reason from tools.py, as table defs looked the same)

An unresolved issue is with a .represent link loading the calling, rather 
than the called form in the target div (2012-07-21 works perfectly) i.e.

db.RaceData.date.represent = lambda value,row: A(value, callback=URL(app,
"race","Rcard",args=[row.date,row.course]),target="Rcard")




On Friday, 24 August 2012 11:58:41 UTC+10, Massimo Di Pierro wrote:
>
> Yes. The grid was an experimental feature in 1.99.7. We are still making 
> minor tweaks to it. 
> The query button is gone because its effect can be achieved by giving 
> focus to the search input.
> The add button moved up to save space.
> The export feature has been improved. There are many export options and we 
> thought a good way was to add links at the bottom.
>
> Notice that the old export form was problematic because did not work well 
> with LOADed grids.
>
> Anyway, it should not break existing functionality. Doesn't it look better 
> now?
>
> Massimo
>
> On Thursday, 23 August 2012 20:47:03 UTC-5, Simon Ashley wrote:
>>
>> Its appears that SQLFORM.grid formatting has changed recently in the 
>> trunk:
>> (with no change to the application)
>>
>>
>>- The Query button has been dropped, 
>>- Add button moved to on top of the query field.
>>- Export function changed from before the table to after with 
>>hyperlinks options rather than drill down box selections
>>
>>
>> Is this an intentional move?
>>
>>
>> 
>>
>>

-- 





[web2py] Re: Limit output of a "details" page to only show some items.

2012-08-23 Thread Anthony

>
> def details():
> try:
> equipment = db.equipment[int(request.args(0))]
> except:
> equipment = db(db.equipment.slug == 
> request.args(0)).select().first()
>

Note, db.equipment(request.args(0)) will attempt to convert request.args(0) 
to an integer, and if that doesn't work, it will return None, so you can do:

equipment = db.equipment(request.args(0)) or db(db.equipment.slug == request
.args(0)).select().first()

Anthony 

-- 





[web2py] Google group again

2012-08-23 Thread Massimo Di Pierro
Does anybody know how to check how many members and how many posts are in 
this group?

-- 





[web2py] Re: Install in hostgator

2012-08-23 Thread pitonb
Sorry to revive this thing a year later. I have taken a stab at this 
yesterday and at 5 in the morning I was still nowhere trying to install w2p 
under a shared hosting account. Has anyone gotten this to work on 
hostgator? I would really appreciate some help. I have pretty much vacuumed 
the web for installation instructions and tried them all, though they are 
all very similar to what is described in this thread. I can't seem to get 
anything but 404 response. Maybe I try to navigate the wrong URL.

In a nut shell I have done the following:

- installed web2py inside ~/public_html
- created executable web2py.fcgi 
- added the stuff to .htaccess

At the end I was messing with routes.py a bit, but to no avail (I'm fuzzy 
on how to interpret this stuff though). If you have a working config on HG 
that would give me one of the w2p's wecome app to show or any sort of 
HelloWorld kind of an app to work, I would appreciate you sharing it here. 

On a related note, what would be the URL I would need to navigate to see 
w2p welcome app after a successful w2p install, given the domain 
www.blah.com and w2p installed ~/public_html? Would it be 
www.blah.com/web2py/welcome?

My plan at this point is to try django following the instructions from HG 
support pages. Just want to make sure any python framework at all would 
work. I have not done this yet and in the long run am not looking at using 
django. 

Thank you in a advance,
-piton

On Friday, May 13, 2011 9:21:13 PM UTC-7, pepe_eloy wrote:
>
> Hello! 
>
> Recently a customer bought a hosting plan (business) with hostgator. 
> I'm developing for him a web2py application, I have doubts of how to 
> deploy it. Somebody can help me? The application runs well in 
> localhost (ubuntu). 
>
> Thanks in advance 
>
>

-- 





[web2py] Re: Trunk > 20012-08-19 formatting

2012-08-23 Thread Massimo Di Pierro
Yes. The grid was an experimental feature in 1.99.7. We are still making 
minor tweaks to it. 
The query button is gone because its effect can be achieved by giving focus 
to the search input.
The add button moved up to save space.
The export feature has been improved. There are many export options and we 
thought a good way was to add links at the bottom.

Notice that the old export form was problematic because did not work well 
with LOADed grids.

Anyway, it should not break existing functionality. Doesn't it look better 
now?

Massimo

On Thursday, 23 August 2012 20:47:03 UTC-5, Simon Ashley wrote:
>
> Its appears that SQLFORM.grid formatting has changed recently in the trunk:
> (with no change to the application)
>
>
>- The Query button has been dropped, 
>- Add button moved to on top of the query field.
>- Export function changed from before the table to after with 
>hyperlinks options rather than drill down box selections
>
>
> Is this an intentional move?
>
>
> 
>
>

-- 





Re: [web2py] SQLFORM key error

2012-08-23 Thread Massimo Di Pierro
We have posted some broken web2py version to perform some experiments. You 
may have gotten one of them.  Download it again now. It is a release 
candidate and should be better than 1.99.7.

On Thursday, 23 August 2012 20:17:02 UTC-5, pylix wrote:
>
> 1.99.7 stable i think it's the latest downloaded it recently
> but i'm on a windows machine, maybe that's the issue?
>
> On Thursday, August 23, 2012 9:04:41 PM UTC-4, rochacbruno wrote:
>>
>> web2py version??
>>
>>
>> On Thu, Aug 23, 2012 at 10:00 PM, pylix  wrote:
>>
>>> Here's my model
>>>
>>> db = DAL('sqlite://storage.sqlite')
>>> db.define_table('person',
>>> Field('name', requires=IS_NOT_EMPTY()),
>>> Field('phone', requires=IS_NOT_EMPTY()),
>>> Field('address', requires=IS_NOT_EMPTY()),
>>> Field('city', requires=IS_NOT_EMPTY()),
>>> Field('state', requires=IS_IN_SET(['NY' ,'NJ' ,'CN'])),
>>> Field('zip', requires=IS_NOT_EMPTY()),
>>> Field('year', requires=IS_NOT_EMPTY()),
>>> Field('model', requires=IS_NOT_EMPTY()),
>>> Field('make', requires=IS_NOT_EMPTY()),
>>> Field('engine', requires=IS_NOT_EMPTY()),
>>> Field('starts', 'boolean'),
>>> Field('foward', 'boolean'),
>>> Field('reverse', 'boolean'),
>>> Field('complaint', 'text'))
>>>
>>> the controller is
>>>
>>> def freequote():
>>> form = SQLFORM(db.person)
>>> return dict(form=form)
>>>
>>> and the view
>>>
>>> {{extend 'layout.html'}}
>>> {{=form}}
>>>
>>> I'm getting this error when i try to view the page
>>>  'person'
>>>
>>> Traceback (most recent call last):
>>> File "gluon/restricted.py", line 205, in restricted
>>>
>>>
>>> File "/controllers/default.py" 
>>> ,
>>>  line 10, in 
>>>
>>> File "gluon/globals.py", line 173, in 
>>>
>>> File "/controllers/default.py" 
>>> ,
>>>  line 8, in freequote
>>>
>>>
>>> File "gluon/dal.py", line 6343, in __getattr__
>>>
>>>
>>> File "gluon/dal.py", line 6337, in __getitem__
>>>
>>>
>>> KeyError: 'person'
>>>
>>>
>>> not sure why i'm getting a keyerror is the table is defined.
>>>
>>> -- 
>>>  
>>>  
>>>  
>>>
>>
>>

-- 





Re: [web2py] Re: NoSQL Question Again!!!

2012-08-23 Thread Massimo Di Pierro
I like to see it this way and perhaps I am wrong...

They way you search on a database is using indexes. Indexes are trees 
(binary trees or b-trees, etc). They fast because the depth of the tree is 
log(N) where N is the number of the elements. You can insert, delete and 
search for items in tree very fast.  The information about your query 
propagates down the tree from its root to the leafs and the results 
propagates back to the root.

SQL databases are more than a collection of trees. They can do joins. They 
have transactions. These operation are non local. Think about updating two 
nodes of the tree which are on different branches (a transaction). That is 
complicated and expensive. Or think about joining data in one tree with 
data in another tree (left joins). Yes SQL databases are good at these 
things.

If you take a SQL database and remove non-local operations like joins, and 
transactions you are left with trees. Trees are fast and have other nice 
properties. You can for example store different branches in different 
servers thus making it scale at no performance cost. You can also keep 
copies of branches in different places thus making them resilient to server 
failures.

Moreover because all you have is a big tree of data, there is no need any 
more for the nodes to store the same type of information. So different 
nodes/records can store different types of data.

In my understanding this is what nosql databases are. Just databases 
without joins and limited transactions which are able to super-optimize 
whatever remains (insert and search). At first approximation they are 
key-value storage where the key is stored in the tree index and the value 
is a dictionary associated to the key. Some are more complex and allow you 
to search the values as well by distributing the query in parallel over the 
branches of the tree. Some have multiple keys.

If your data matches this model they are great. If you ever need to do a 
global search and replace or referential integrity or transactional 
integrity, forget it. 

Massimo









On Thursday, 23 August 2012 19:52:13 UTC-5, Niphlod wrote:
>
> Without hitting a "product vs product" issue... nosql dbs is just another 
> tool at the programmers belt.
> The "usually advertised benefits" are raw speed and scalability.  
>
> On Friday, August 24, 2012 2:01:03 AM UTC+2, apps in tables wrote:
>>
>>
>>  I think my problem is that my mind has been thinking for thirty years 
>> about applications in the sql database way.
>>
>> I don't know what the nosql database application structure will look like.
>>
>> this is not the problem of web2py web2py is full stack framework ( 
>> based on sql-like database (DAL) ).
>>
>> So, web2py will not get benefit from the nosql database feature.
>>
>> I think there are benefits for the nosql database, that i am not aware of.
>>
>> Anybody knows ??
>>
>

-- 





[web2py] Trunk > 20012-08-19 formatting

2012-08-23 Thread Simon Ashley
Its appears that SQLFORM.grid formatting has changed recently in the trunk:
(with no change to the application)


   - The Query button has been dropped, 
   - Add button moved to on top of the query field.
   - Export function changed from before the table to after with hyperlinks 
   options rather than drill down box selections
   

Is this an intentional move?



-- 





Re: [web2py] SQLFORM key error

2012-08-23 Thread pylix
1.99.7 stable i think it's the latest downloaded it recently
but i'm on a windows machine, maybe that's the issue?

On Thursday, August 23, 2012 9:04:41 PM UTC-4, rochacbruno wrote:
>
> web2py version??
>
>
> On Thu, Aug 23, 2012 at 10:00 PM, pylix >wrote:
>
>> Here's my model
>>
>> db = DAL('sqlite://storage.sqlite')
>> db.define_table('person',
>> Field('name', requires=IS_NOT_EMPTY()),
>> Field('phone', requires=IS_NOT_EMPTY()),
>> Field('address', requires=IS_NOT_EMPTY()),
>> Field('city', requires=IS_NOT_EMPTY()),
>> Field('state', requires=IS_IN_SET(['NY' ,'NJ' ,'CN'])),
>> Field('zip', requires=IS_NOT_EMPTY()),
>> Field('year', requires=IS_NOT_EMPTY()),
>> Field('model', requires=IS_NOT_EMPTY()),
>> Field('make', requires=IS_NOT_EMPTY()),
>> Field('engine', requires=IS_NOT_EMPTY()),
>> Field('starts', 'boolean'),
>> Field('foward', 'boolean'),
>> Field('reverse', 'boolean'),
>> Field('complaint', 'text'))
>>
>> the controller is
>>
>> def freequote():
>> form = SQLFORM(db.person)
>> return dict(form=form)
>>
>> and the view
>>
>> {{extend 'layout.html'}}
>> {{=form}}
>>
>> I'm getting this error when i try to view the page
>>  'person'
>>
>> Traceback (most recent call last):
>> File "gluon/restricted.py", line 205, in restricted
>>
>>
>> File "/controllers/default.py" 
>> ,
>>  line 10, in 
>>
>> File "gluon/globals.py", line 173, in 
>>
>> File "/controllers/default.py" 
>> ,
>>  line 8, in freequote
>>
>>
>> File "gluon/dal.py", line 6343, in __getattr__
>>
>>
>> File "gluon/dal.py", line 6337, in __getitem__
>>
>>
>> KeyError: 'person'
>>
>>
>> not sure why i'm getting a keyerror is the table is defined.
>>
>> -- 
>>  
>>  
>>  
>>
>
>

-- 





Re: [web2py] SQLFORM key error

2012-08-23 Thread Bruno Rocha
web2py version??


On Thu, Aug 23, 2012 at 10:00 PM, pylix  wrote:

> Here's my model
>
> db = DAL('sqlite://storage.sqlite')
> db.define_table('person',
> Field('name', requires=IS_NOT_EMPTY()),
> Field('phone', requires=IS_NOT_EMPTY()),
> Field('address', requires=IS_NOT_EMPTY()),
> Field('city', requires=IS_NOT_EMPTY()),
> Field('state', requires=IS_IN_SET(['NY' ,'NJ' ,'CN'])),
> Field('zip', requires=IS_NOT_EMPTY()),
> Field('year', requires=IS_NOT_EMPTY()),
> Field('model', requires=IS_NOT_EMPTY()),
> Field('make', requires=IS_NOT_EMPTY()),
> Field('engine', requires=IS_NOT_EMPTY()),
> Field('starts', 'boolean'),
> Field('foward', 'boolean'),
> Field('reverse', 'boolean'),
> Field('complaint', 'text'))
>
> the controller is
>
> def freequote():
> form = SQLFORM(db.person)
> return dict(form=form)
>
> and the view
>
> {{extend 'layout.html'}}
> {{=form}}
>
> I'm getting this error when i try to view the page
>  'person'
>
>
> Traceback (most recent call last):
> File "gluon/restricted.py", line 205, in restricted
>
> File "/controllers/default.py" 
> ,
>  line 10, in 
> File "gluon/globals.py", line 173, in 
> File "/controllers/default.py" 
> ,
>  line 8, in freequote
>
> File "gluon/dal.py", line 6343, in __getattr__
>
> File "gluon/dal.py", line 6337, in __getitem__
>
> KeyError: 'person'
>
>
> not sure why i'm getting a keyerror is the table is defined.
>
> --
>
>
>
>

-- 





[web2py] SQLFORM key error

2012-08-23 Thread pylix
Here's my model

db = DAL('sqlite://storage.sqlite')
db.define_table('person',
Field('name', requires=IS_NOT_EMPTY()),
Field('phone', requires=IS_NOT_EMPTY()),
Field('address', requires=IS_NOT_EMPTY()),
Field('city', requires=IS_NOT_EMPTY()),
Field('state', requires=IS_IN_SET(['NY' ,'NJ' ,'CN'])),
Field('zip', requires=IS_NOT_EMPTY()),
Field('year', requires=IS_NOT_EMPTY()),
Field('model', requires=IS_NOT_EMPTY()),
Field('make', requires=IS_NOT_EMPTY()),
Field('engine', requires=IS_NOT_EMPTY()),
Field('starts', 'boolean'),
Field('foward', 'boolean'),
Field('reverse', 'boolean'),
Field('complaint', 'text'))

the controller is

def freequote():
form = SQLFORM(db.person)
return dict(form=form)

and the view

{{extend 'layout.html'}}
{{=form}}

I'm getting this error when i try to view the page
 'person'

Traceback (most recent call last):
File "gluon/restricted.py", line 205, in restricted
File "/controllers/default.py" 
, 
line 10, in 
File "gluon/globals.py", line 173, in 
File "/controllers/default.py" 
, 
line 8, in freequote
File "gluon/dal.py", line 6343, in __getattr__
File "gluon/dal.py", line 6337, in __getitem__
KeyError: 'person'


not sure why i'm getting a keyerror is the table is defined.

-- 





Re: [web2py] Limit output of a "details" page to only show some items.

2012-08-23 Thread SeamusSeamus
Oh, very easy! Web2y is great!

On Thursday, August 23, 2012 6:48:30 PM UTC-6, rochacbruno wrote:
>
> Considering this:
>
> def details():
> try:
> equipment = db.equipment[int(request.args(0))]
> except:
> equipment = db(db.equipment.slug == request.args(0)).select().
> first()
> 
> return dict(equipment=equipment)
>
> Your view details.html should be
>
> {{=equipment.title}}
> {{=equipment.description}}
> {{=IMG(_src=URL('default', 'download', 
> args=equipment.image1))}}
>
> *Bruno Cezar Rocha** - @rochacbruno*
> rocha...@gmail.com  | Mobile: +55 (11) 99210-8821
> www.CursoDePython.com.br | www.rochacbruno.com.br
> Blog: WEB APPS THAT WORTH A 
> TRY
>   Get a signature like this. 
> 
>  Click 
> here.
>
>
>
>
> On Thu, Aug 23, 2012 at 9:38 PM, SeamusSeamus 
> 
> > wrote:
>
>> I am trying to set a nice clean "details" page that only shows some basic 
>> information for a product. I do not want ALL information that is being 
>> storded (such as my slug, private notes field, etc..) to be visable to the 
>> customer. Now, I have this:
>>
>> def details():
>> try:
>> equipment = db.equipment[int(request.args(0))]
>> except:
>> equipment = db(db.equipment.slug == 
>> request.args(0)).select().first()
>> 
>> return dict(equipment=equipment)
>>
>> and in my details.html I am just using the {{=BEAUTIFY(response._vars)}} 
>> which is displaying all of the info in a un clean way. What do I need to do 
>> to just display only a few items, and allow me to place the elements 
>> anywhere I would like on the page? For example, I just want the 'title', 
>> 'description' and 'photo' to be shown on the 'details' page. How would I 
>> make them independant of one another so I can place the image one spot, the 
>> title another spot (the ) and the description elsewhere ()
>> For example
>> {{title}}
>> {{description}}
>> {{image1}}
>>
>>  I know this may be basic stuff, but I am learning python as I go and 
>> these forums are a great help. I cannot seem to find my answer in the 
>> web2py docs.
>>
>>  -- 
>>  
>>  
>>  
>>
>
>

-- 





Re: [web2py] Re: NoSQL Question Again!!!

2012-08-23 Thread Niphlod
Without hitting a "product vs product" issue... nosql dbs is just another 
tool at the programmers belt.
The "usually advertised benefits" are raw speed and scalability.  

On Friday, August 24, 2012 2:01:03 AM UTC+2, apps in tables wrote:
>
>
>  I think my problem is that my mind has been thinking for thirty years 
> about applications in the sql database way.
>
> I don't know what the nosql database application structure will look like.
>
> this is not the problem of web2py web2py is full stack framework ( 
> based on sql-like database (DAL) ).
>
> So, web2py will not get benefit from the nosql database feature.
>
> I think there are benefits for the nosql database, that i am not aware of.
>
> Anybody knows ??
>

-- 





Re: [web2py] Limit output of a "details" page to only show some items.

2012-08-23 Thread Bruno Rocha
Considering this:

def details():
try:
equipment = db.equipment[int(request.args(0))]
except:
equipment = db(db.equipment.slug == request.args(0)).select().
first()

return dict(equipment=equipment)

Your view details.html should be

{{=equipment.title}}
{{=equipment.description}}
{{=IMG(_src=URL('default', 'download',
args=equipment.image1))}}

*Bruno Cezar Rocha** - @rochacbruno*
rochacbr...@gmail.com | Mobile: +55 (11) 99210-8821
www.CursoDePython.com.br | www.rochacbruno.com.br
Blog: WEB APPS THAT WORTH A
TRY
  Get a signature like this.

Click
here.



On Thu, Aug 23, 2012 at 9:38 PM, SeamusSeamus
wrote:

> I am trying to set a nice clean "details" page that only shows some basic
> information for a product. I do not want ALL information that is being
> storded (such as my slug, private notes field, etc..) to be visable to the
> customer. Now, I have this:
>
> def details():
> try:
> equipment = db.equipment[int(request.args(0))]
> except:
> equipment = db(db.equipment.slug ==
> request.args(0)).select().first()
>
> return dict(equipment=equipment)
>
> and in my details.html I am just using the {{=BEAUTIFY(response._vars)}}
> which is displaying all of the info in a un clean way. What do I need to do
> to just display only a few items, and allow me to place the elements
> anywhere I would like on the page? For example, I just want the 'title',
> 'description' and 'photo' to be shown on the 'details' page. How would I
> make them independant of one another so I can place the image one spot, the
> title another spot (the ) and the description elsewhere ()
> For example
> {{title}}
> {{description}}
> {{image1}}
>
>  I know this may be basic stuff, but I am learning python as I go and
> these forums are a great help. I cannot seem to find my answer in the
> web2py docs.
>
>  --
>
>
>
>

-- 





[web2py] Limit output of a "details" page to only show some items.

2012-08-23 Thread SeamusSeamus
I am trying to set a nice clean "details" page that only shows some basic 
information for a product. I do not want ALL information that is being 
storded (such as my slug, private notes field, etc..) to be visable to the 
customer. Now, I have this:

def details():
try:
equipment = db.equipment[int(request.args(0))]
except:
equipment = db(db.equipment.slug == 
request.args(0)).select().first()

return dict(equipment=equipment)

and in my details.html I am just using the {{=BEAUTIFY(response._vars)}} 
which is displaying all of the info in a un clean way. What do I need to do 
to just display only a few items, and allow me to place the elements 
anywhere I would like on the page? For example, I just want the 'title', 
'description' and 'photo' to be shown on the 'details' page. How would I 
make them independant of one another so I can place the image one spot, the 
title another spot (the ) and the description elsewhere ()
For example
{{title}}
{{description}}
{{image1}}

 I know this may be basic stuff, but I am learning python as I go and these 
forums are a great help. I cannot seem to find my answer in the web2py docs.

-- 





[web2py] Re: How to ask how many active sessions?

2012-08-23 Thread weheh


On Thursday, August 23, 2012 4:11:51 PM UTC+8, Niphlod wrote:
>
> define "active" session.active users, loginned users, peoples 
> wandering in your site ? 


Depends on info available. But all of the above, at least.

-- 





[web2py] Questions on instantpress

2012-08-23 Thread Andrew
Hello (Martin),

What's the best way to ask questions about InstantPress ?   Here ?
I would like to use it for a local Scout group website.

Also, the old version is still at http://code.google.com/p/instant-press/  
without any comments or links to the new bitbucket version.
Should this one be dropped ?

-- 





Re: [web2py] Re: NoSQL Question Again!!!

2012-08-23 Thread apps in tables


>  I think my problem is that my mind has been thinking for thirty years 
about applications in the sql database way.

I don't know what the nosql database application structure will look like.

this is not the problem of web2py web2py is full stack framework ( 
based on sql-like database (DAL) ).

So, web2py will not get benefit from the nosql database feature.

I think there are benefits for the nosql database, that i am not aware of.

Anybody knows ??

-- 





Re: [web2py] Re: fpdf upgrade and contib/generics.py

2012-08-23 Thread Andrew
In the console:  "The system cannot find the path specified."
I'm just trying to do a "Hello World" pdf .

On Friday, August 24, 2012 11:29:52 AM UTC+12, Mariano Reingart wrote:
>
> What error does occur? 
> Does it throw an exception? 
>
> I think It should work, but note that pdf conversion is simple, if you 
> have a complex html, you'll need more advanced tools. 
>
> Best regards, 
>
> Mariano Reingart 
> http://www.sistemasagiles.com.ar 
> http://reingart.blogspot.com 
>
>
> On Thu, Aug 23, 2012 at 6:03 PM, Andrew > 
> wrote: 
> > Sorry, that should be contrib/generics.py 
> > 
> > Is views/generics.pdf working for others ?  I might be doing someting 
> wrong, 
> > but it's not working for me. 
> > 
> > 
> > 
> > On Friday, August 24, 2012 8:30:17 AM UTC+12, Andrew wrote: 
> >> 
> >> Does genereics.py need to be updated ? 
> >> 
> >> from gluon.contrib.pyfpdf import FPDF, HTMLMixin 
> >> 
> >> Could this reference occur elsewhere ? 
> > 
> > -- 
> > 
> > 
> > 
>

-- 





Re: [web2py] Re: SEO Friendly URLs and Page Titles

2012-08-23 Thread SeamusSeamus
Thanks, that worked. I just added db.equipment.slug to the fields


On Thursday, August 23, 2012 1:18:16 AM UTC-6, Anthony wrote:
>
> links = [lambda ro
>> w: A('Details',_href=URL('default','show', args=[row.slug]))]
>> fields = [db.equipment.category, db.equipment.title, 
>> db.equipment.price]
>>
>
> You have not included "slug" in your list of fields, so I believe it will 
> not be included in the data query. Instead of specifying the list of 
> fields, you can set the readable attribute to False for fields you don't 
> want displayed (including "slug"). In that case, all fields will be 
> included in the query (including "slug"), but only the fields you want to 
> show will be visible in the grid.
>
> Anthony 
>

-- 





[web2py] Re: Grid, NameError: name 'auth' is not defined

2012-08-23 Thread Simon Ashley
Yep, sorry about that (was trying to post something quick to illustrate the 
issue).
Part of the issue appears to be the db.auth_user table.
Deleted and manually rebuilt it, and the error disappeared.

Its appears that the latest trunk maybe have broken a callback link 
(reloads the calling form rather than the form being called), but still 
investigating.


-- 





Re: [web2py] Re: fpdf upgrade and contib/generics.py

2012-08-23 Thread Mariano Reingart
What error does occur?
Does it throw an exception?

I think It should work, but note that pdf conversion is simple, if you
have a complex html, you'll need more advanced tools.

Best regards,

Mariano Reingart
http://www.sistemasagiles.com.ar
http://reingart.blogspot.com


On Thu, Aug 23, 2012 at 6:03 PM, Andrew  wrote:
> Sorry, that should be contrib/generics.py
>
> Is views/generics.pdf working for others ?  I might be doing someting wrong,
> but it's not working for me.
>
>
>
> On Friday, August 24, 2012 8:30:17 AM UTC+12, Andrew wrote:
>>
>> Does genereics.py need to be updated ?
>>
>> from gluon.contrib.pyfpdf import FPDF, HTMLMixin
>>
>> Could this reference occur elsewhere ?
>
> --
>
>
>

-- 





[web2py] Re: Twitter Bootstrap scatfolding application *updated.

2012-08-23 Thread Anthony

>
> It is based on anytime.js
>

And note, anytime.js requires a commercial license for use on any 
commercial website.

Anthony 

-- 





[web2py] food for thought....

2012-08-23 Thread Massimo Di Pierro
http://tent.io/
http://www.nicollet.net/2012/08/tent-the-right-goals-the-wrong-perspective/
https://github.com/pdxwebdev/yadapy


-- 





Re: [web2py] Re: NoSQL Question Again!!!

2012-08-23 Thread Massimo Di Pierro
Exactly.

In web2py one can use mongo db in two ways:
1) using the pymongo apis directly. It does not need the DAL and does not 
need them. They would get in the way.
2) using the DAL and "pretend" you have a sql-like table structure on top 
of mongo. You have to db.define_table(s) and you can query them as you 
would with a relational database (no joins). The records uuid is 
automatically converted to a long integer id. You can extend your model by 
adding tables and fields without overhead and without need to do migrations 
but you still need to alter the model is you want to store new filelds in a 
record.
This also allow you to use SQLFORM and SQLFORM.grid.

Depending on what you want to do you can choose 1 and 2. You can partially 
mix and match them but you cannot have both of them at the same time. For 
example what would the point of SQLFORM(db.mytable) or 
SQLFORM.grid(db.mytable) if db.mytable has no field structure associated to 
it?

Massimo


On Thursday, 23 August 2012 15:38:54 UTC-5, Vasile Ermicioi wrote:
>
>
> If thats true, then NoSQL support isnt yet ready.
>>
>>
> in web2py you define TABLES which have FIELDS, and NoSQL support in web2py 
> means that you are running your models on top of a NoSQL database (e.g. 
> MongoDB)
>
> there is not yet support for queries like 
> db(db.user.country.name ='US').select()
>
> but to my knowledge django doesn't support it either,
>
> do you know any python framework or ORM library with support for nosql 
> features?
>  

-- 





Re: [web2py] Major speed improvement need testers

2012-08-23 Thread Massimo Di Pierro
No without making non-lazy table significatively slower.

On Thursday, 23 August 2012 15:32:08 UTC-5, Anthony wrote:
>
> OK, that makes sense. I guess there's no good way to make that lazy at the 
> Field level.
>
> Thanks.
>
> Anthony
>
> On Thursday, August 23, 2012 4:10:23 PM UTC-4, Massimo Di Pierro wrote:
>>
>> Here is an example:
>>
>> Say you have
>>
>> db.define_table('person',Field('name'))
>> db.person.name.requires=IS_IN_SET(build_set())
>>
>> where build_set is computationally expensive. You only want to create the 
>> set if you actually need the table. You can move it in the controller 
>> action but does it belong there? Now you can do:
>>
>> def set_requirements(person): person.name.requires=IS_IN_SET(build_set())
>> db.define_table('person',Field('name'),on_define=set_requirements)
>>
>> Notice that this does not call build_set() until the table is actually 
>> defined, moreover is does use the notation db.person and therefore does not 
>> force table instantiation.
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> On Thursday, 23 August 2012 13:22:34 UTC-5, Anthony wrote:
>>>
>>> I'd also still be interested to see a real-world example of where this 
> would be useful.
>
> Anthony
>

 Someone posted an example of GAE CPU Cycles, with class based Lazy 
 Tables it lower to half cycles. Also there is another user in the group 
 which has a huge traffic, so Lazy tables might be useful.

>>>
>>> No, I meant an example of where the new on_delete argument would be 
>>> useful.
>>>
>>> Anthony 
>>>
>>

-- 





[web2py] Re: Twitter Bootstrap scatfolding application *updated.

2012-08-23 Thread Massimo Di Pierro
Martin,

it is really well done but, as it is, it not appropriate for out 
scaffolding app. 

First of all it relies on many bootstrap specific helpers.
Menus work in a different way than documented.
Flash has a more complex html structure and does not provide a good example 
for new users.
It is based on anytime.js while we moved to calendar.js.
The html lacks the blocks for header, footer and sidebar.
Many web2py specific styles are missing.

Yours is a more a by-the-book bootstrap app than welcome is but welcome is 
designed above all to provide an example for new users who may or not want 
to use bootstrap. The fact that is uses bootstrap is accidental and only 
affects the CSS.

It is in principle possible to merge it with the scaffolding but we would 
still need to fix menus. Perhaps we should do it but web2py 2.0 has waited 
long enough, mostly because of css. I would not want to put it off more 
because we have a new css option.
 
Massimo


On Thursday, 23 August 2012 13:48:03 UTC-5, Martin.Mulone wrote:
>
> Twitter Bootstrap scatfolding application *updated.
>
> Now is awesome :-P
>
> * Now based on version 2.1.0 (sync)
> * Menu based on twitter bootstrap navbar (support multilevel menu)
> * Plugin highlight.
> * Many fixes to layout now support responsive.
> * Very clean layout.
> * Started to document (getting)
> * Some examples.
> * Flash is render as alert.
>
> Working demo: http://testbootstrap.tecnodoc.com.ar/
> Doc: http://testbootstrap.tecnodoc.com.ar/getting
> Source: https://bitbucket.org/mulonemartin/bootstrap
>
> Note: Not yet fully tested.
>

-- 





[web2py] Re: General knowledge questions about reference fields

2012-08-23 Thread Mike Girard
Every question answered. Thanks a lot, Anthony!

On Thursday, August 23, 2012 3:27:07 PM UTC-4, Anthony wrote:
>
> 1. When you do a select that includes a reference field, how does it 
>> fetch, say, the name column, when only the id column is in the table you 
>> are doing a select on?
>>
>
> Unless you do a join, it does not fetch the "name" column (presumably you 
> mean the "name" column of the referenced table) at the time of the initial 
> select. However, if you access the "name" attribute of one of the returned 
> Row objects, it will do a query to fetch the "name" field for that 
> particular record. If you check the type of the reference field of the Row 
> object, you'll see that it is a DAL Reference object -- this holds the 
> value of the referenced record id but also knows how to fetch the 
> associated record from the referenced table. This is called a recursive 
> select . 
> Note, because recursive selects involve a separate query for each record, 
> if you need the referenced fields for many records, it is more efficient to 
> do a single query with a join instead.
>  
>
>> 3. My list:reference fields hold a series of integer values but they do 
>> so in a column of type 'text' . They are strings of integers separated with 
>> '|'. If I were going to use SQL, rather than DAL methods to update a 
>> list:reference field of this kind, would inserting a string like this - 
>> '|100|300|450|' - work the same as a field updated by the DAL with a list? 
>> Or is the DAL doing something else behind the scenes when you update the 
>> field that would be excluded from a simple SQL update.
>>
>
> I don't think the DAL is doing anything special other than creating a 
> string as you describe above, so you should be able to make your own 
> inserts using SQL if you like.
>
> Anthony 
>

-- 





[web2py] Re: fpdf upgrade and contib/generics.py

2012-08-23 Thread Andrew
Sorry, that should be contrib/generics.py

Is views/generics.pdf working for others ?  I might be doing someting 
wrong, but it's not working for me.


On Friday, August 24, 2012 8:30:17 AM UTC+12, Andrew wrote:
>
> Does genereics.py need to be updated ?
>
> from gluon.contrib.pyfpdf import FPDF, HTMLMixin
>
> Could this reference occur elsewhere ?
>

-- 





Re: [web2py] Re: NoSQL Question Again!!!

2012-08-23 Thread Vasile Ermicioi
> If thats true, then NoSQL support isnt yet ready.
>
>
in web2py you define TABLES which have FIELDS, and NoSQL support in web2py
means that you are running your models on top of a NoSQL database (e.g.
MongoDB)

there is not yet support for queries like
db(db.user.country.name ='US').select()

but to my knowledge django doesn't support it either,

do you know any python framework or ORM library with support for nosql
features?

-- 





Re: [web2py] Major speed improvement need testers

2012-08-23 Thread Anthony
OK, that makes sense. I guess there's no good way to make that lazy at the 
Field level.

Thanks.

Anthony

On Thursday, August 23, 2012 4:10:23 PM UTC-4, Massimo Di Pierro wrote:
>
> Here is an example:
>
> Say you have
>
> db.define_table('person',Field('name'))
> db.person.name.requires=IS_IN_SET(build_set())
>
> where build_set is computationally expensive. You only want to create the 
> set if you actually need the table. You can move it in the controller 
> action but does it belong there? Now you can do:
>
> def set_requirements(person): person.name.requires=IS_IN_SET(build_set())
> db.define_table('person',Field('name'),on_define=set_requirements)
>
> Notice that this does not call build_set() until the table is actually 
> defined, moreover is does use the notation db.person and therefore does not 
> force table instantiation.
>
>
>
>
>
>
>
>
>
>
> On Thursday, 23 August 2012 13:22:34 UTC-5, Anthony wrote:
>>
>> I'd also still be interested to see a real-world example of where this 
 would be useful.

 Anthony

>>>
>>> Someone posted an example of GAE CPU Cycles, with class based Lazy 
>>> Tables it lower to half cycles. Also there is another user in the group 
>>> which has a huge traffic, so Lazy tables might be useful.
>>>
>>
>> No, I meant an example of where the new on_delete argument would be 
>> useful.
>>
>> Anthony 
>>
>

-- 





[web2py] fpdf upgrade and contib/generics.py

2012-08-23 Thread Andrew
Does genereics.py need to be updated ?

from gluon.contrib.pyfpdf import FPDF, HTMLMixin

Could this reference occur elsewhere ?

-- 





Re: [web2py] Major speed improvement need testers

2012-08-23 Thread Massimo Di Pierro
Here is an example:

Say you have

db.define_table('person',Field('name'))
db.person.name.requires=IS_IN_SET(build_set())

where build_set is computationally expensive. You only want to create the 
set if you actually need the table. You can move it in the controller 
action but does it belong there? Now you can do:

def set_requirements(person): person.name.requires=IS_IN_SET(build_set())
db.define_table('person',Field('name'),on_define=set_requirements)

Notice that this does not call build_set() until the table is actually 
defined, moreover is does use the notation db.person and therefore does not 
force table instantiation.










On Thursday, 23 August 2012 13:22:34 UTC-5, Anthony wrote:
>
> I'd also still be interested to see a real-world example of where this 
>>> would be useful.
>>>
>>> Anthony
>>>
>>
>> Someone posted an example of GAE CPU Cycles, with class based Lazy Tables 
>> it lower to half cycles. Also there is another user in the group which has 
>> a huge traffic, so Lazy tables might be useful.
>>
>
> No, I meant an example of where the new on_delete argument would be useful.
>
> Anthony 
>

-- 





Re: [web2py] Re: NoSQL Question Again!!!

2012-08-23 Thread Pystar
If thats true, then NoSQL support isnt yet ready.

On Thursday, August 23, 2012 8:31:31 PM UTC+1, Vasile Ermicioi wrote:
>
> you can use it but without dal and you lose all great features like form 
> generation and others 

-- 





[web2py] Re: Web2Py in cluster and DATABASES folder

2012-08-23 Thread Mike
Thanks, Massimo, that's exactly the code I've written, 
using migrate_enabled parameter in DAL constructor.
The files will be created once, in that sub-folder, when the schema is 
first created and initialized with tables.
I might need those files late for migrations and, regardless, I don't see 
the way to stop DAL from creating those.

What about that typo/bug? Have I figured out the right code that should 
have been there?

On Thursday, August 23, 2012 1:38:01 PM UTC-4, Massimo Di Pierro wrote:
>
> If they share the database, they should also share the folder. Anyway, 
> mind that file IO is a major bottleneck and accessing a shared filesystem 
> is every worse.
>
> Setting migrate=False prevents the file system access completely.
>
> Ideally should have a way to set migrate=True only when the new 
> organization joins and migrate=True when it joined already. You should be 
> able to perform this check without looking at the filesystem.
>
>
>
> On Thursday, 23 August 2012 12:15:49 UTC-5, Mike wrote:
>>
>> Perhaps I haven't made myself clear enough...
>>
>> Forget about development environment - think cluster deployment scenario 
>> only.
>> I can't create databases in advance - in fact, the server code is written 
>> to create a new schema (using MySQL parlance) every time a new group of 
>> customers (an "organization") is joining the site. As such, any of the 
>> servers in the cluster at any point in time could be faced with the task of 
>> creating a new schema, a new sub-folder inside DATABASES and initializing 
>> the schema with appropriate tables and sub-folder - with appropriate .table 
>> files. My only issue is whether or not DATABASES folder should be shared 
>> among the machines in the cluster (like SESSIONS, for instance) or if each 
>> of them should maintain its own (less preferable, for various reasons). And 
>> that bug will have to be fixed, of course.
>>
>> On Thursday, August 23, 2012 12:42:06 PM UTC-4, Niphlod wrote:
>>>
>>> ehm... deploy. production. cluster.
>>> You say that "some .table files are created" hence I think you're using 
>>> the same database uri both for production and development (if any). If 
>>> .table files are created, it's safe to assume that the underlying code 
>>> changes too, right ?
>>> If so, a simply copy/rsync from a "development" to all the "cluster" 
>>> machines suffices, without you ending in misery. Why all the pain if you 
>>> have to sync the code accross cluster if .table files can travel the same 
>>> way as your codebase ?
>>>
>>> Il giorno giovedì 23 agosto 2012 17:14:51 UTC+2, Mike ha scritto:

 We are planning on deploying our Web2Py application under Apache-WSGI 
 on a cluster of servers all accessing the same multiple databases. Since 
 the new databases will be created on the fly, as needed, we cannot predict 
 beforehand how many we will end up using and, consequently, how many files 
 will end up being created in DATABASES folder. As a result, I am trying to 
 create sub-folders under DATABASES and set MIGRATE parameter on 
 .define_table() call for a given database to />>> name>.table. Such approach allows me to better control the overall number 
 of files in a single folder as well as make the overall picture more 
 manageable. There is one problem with this approach and one question for 
 the experts:

 1. A problem - we are using Auth to authenticate users and so need to 
 perform auth.define_tables(). By passing to it migrate=">>> name>/", I almost made it create all the auth_ table files in that 
 sub-folder, except that there is a typo in TOOLS.PY, line 1420 in my 
 source 
 code for version 1.99.7, where instead of expected 
 
 migrate=self.__get_migrate(settings.table_cas_name, migrate),
 
 it goes
 
 migrate=self.__get_migrate(settings.table_event_name, migrate),

 I've fixed it in my copy and would like to request that the fix should 
 be made in the official release code base as well.

 2. A question - should DATABASES folder be shared among the 
 Apache-Web2Py machines or should each maintain its own copy? More 
 specifically, is there any locking mechanism on those .table files built 
 specifically for the purpose of sharing between threads/machines? I intend 
 to use migrate_enabled=False when creating an instance of DAL if I know 
 that the tables have already been created, but to make sure that multiple 
 machines won't try to create the new database/new sub-folder at the same 
 time, I will probably have to build some locks outside DAL. Is this even 
 the right way of thinking about this problem?

 Sorry for the long-winded question. Great framework, BTW. :)



-- 





[web2py] Using Request_tenant , but shows all records in the table

2012-08-23 Thread Saba Kazi
I've added the field request_tenant  using :

if auth.user:
 defaultval = auth.user.id
   
else:
  defaultval = 0

db._common_fields.append(Field('request_tenant',default=defaultval))

While create a new record , the default value is inserted into the table,
But when i view the records from the index.html file , i see all the records 
and not just the records for that particular user ! 

-- 





Re: [web2py] Re: NoSQL Question Again!!!

2012-08-23 Thread Vasile Ermicioi
you can use it but without dal and you lose all great features like form
generation and others

-- 





[web2py] Re: NoSQL Question Again!!!

2012-08-23 Thread apps in tables


>
>
> db=DAL('mongodb://127.0.0.1:5984/db')
>
> (the port may be different). Everything else should work as usual..
>
>
>
Hi massimo,

I think the point is not working as usual.

'usual' is to define tables . In  Mongodb 'not usual'  , there is no schema.

Please, explain How to use the mongodb feature (no schema) in web2py?

Regards,

Ashraf

-- 





[web2py] Re: General knowledge questions about reference fields

2012-08-23 Thread Anthony

>
> 1. When you do a select that includes a reference field, how does it 
> fetch, say, the name column, when only the id column is in the table you 
> are doing a select on?
>

Unless you do a join, it does not fetch the "name" column (presumably you 
mean the "name" column of the referenced table) at the time of the initial 
select. However, if you access the "name" attribute of one of the returned 
Row objects, it will do a query to fetch the "name" field for that 
particular record. If you check the type of the reference field of the Row 
object, you'll see that it is a DAL Reference object -- this holds the 
value of the referenced record id but also knows how to fetch the 
associated record from the referenced table. This is called a recursive 
select . 
Note, because recursive selects involve a separate query for each record, 
if you have to loop over many records, it is more efficient to do a single 
query with a join instead.
 

> 3. My list:reference fields hold a series of integer values but they do so 
> in a column of type 'text' . They are strings of integers separated with 
> '|'. If I were going to use SQL, rather than DAL methods to update a 
> list:reference field of this kind, would inserting a string like this - 
> '|100|300|450|' - work the same as a field updated by the DAL with a list? 
> Or is the DAL doing something else behind the scenes when you update the 
> field that would be excluded from a simple SQL update.
>

I don't think the DAL is doing anything special other than creating a 
string as you describe above, so you should be able to make your own 
inserts using SQL if you like.

Anthony 

-- 





Re: [web2py] Re: Twitter Bootstrap scatfolding application *updated.

2012-08-23 Thread Bruno Rocha
Put
z-index: 0;

on flash alert

On Thu, Aug 23, 2012 at 4:05 PM, David Marko  wrote:

> The alert 'Well done! ...' conflicts somehow with menu when you click e.g.
> on 'Bootstrap' menu item ...
>
> Dne čtvrtek, 23. srpna 2012 20:48:03 UTC+2 Martin.Mulone napsal(a):
>
>> Twitter Bootstrap scatfolding application *updated.
>>
>> Now is awesome :-P
>>
>> * Now based on version 2.1.0 (sync)
>> * Menu based on twitter bootstrap navbar (support multilevel menu)
>> * Plugin highlight.
>> * Many fixes to layout now support responsive.
>> * Very clean layout.
>> * Started to document (getting)
>> * Some examples.
>> * Flash is render as alert.
>>
>> Working demo: 
>> http://testbootstrap.tecnodoc.**com.ar/
>> Doc: 
>> http://testbootstrap.tecnodoc.**com.ar/getting
>> Source: 
>> https://bitbucket.org/**mulonemartin/bootstrap
>>
>> Note: Not yet fully tested.
>>
>  --
>
>
>
>

-- 





[web2py] Re: Twitter Bootstrap scatfolding application *updated.

2012-08-23 Thread David Marko
The alert 'Well done! ...' conflicts somehow with menu when you click e.g. 
on 'Bootstrap' menu item ...

Dne čtvrtek, 23. srpna 2012 20:48:03 UTC+2 Martin.Mulone napsal(a):
>
> Twitter Bootstrap scatfolding application *updated.
>
> Now is awesome :-P
>
> * Now based on version 2.1.0 (sync)
> * Menu based on twitter bootstrap navbar (support multilevel menu)
> * Plugin highlight.
> * Many fixes to layout now support responsive.
> * Very clean layout.
> * Started to document (getting)
> * Some examples.
> * Flash is render as alert.
>
> Working demo: http://testbootstrap.tecnodoc.com.ar/
> Doc: http://testbootstrap.tecnodoc.com.ar/getting
> Source: https://bitbucket.org/mulonemartin/bootstrap
>
> Note: Not yet fully tested.
>

-- 





Re: [web2py] Twitter Bootstrap scatfolding application *updated.

2012-08-23 Thread Bruno Rocha
Great!

This new navbar is very better! Thank you Martin!


On Thu, Aug 23, 2012 at 3:48 PM, Martín Mulone wrote:

> Twitter Bootstrap scatfolding application *updated.
>
> Now is awesome :-P
>
> * Now based on version 2.1.0 (sync)
> * Menu based on twitter bootstrap navbar (support multilevel menu)
> * Plugin highlight.
> * Many fixes to layout now support responsive.
> * Very clean layout.
> * Started to document (getting)
> * Some examples.
> * Flash is render as alert.
>
> Working demo: http://testbootstrap.tecnodoc.com.ar/
> Doc: http://testbootstrap.tecnodoc.com.ar/getting
> Source: https://bitbucket.org/mulonemartin/bootstrap
>
> Note: Not yet fully tested.
>
> --
>
>
>
>

-- 





[web2py] General knowledge questions about reference fields

2012-08-23 Thread Mike Girard
Still working on optimizing updates. 

Could someone provide high-level answers to the following?

1. When you do a select that includes a reference field, how does it fetch, 
say, the name column, when only the id column is in the table you are doing 
a select on?

2. For many-to-many relationships, how does list:reference compare in 
performance and convenience with using linking tables and joins? 

3. My list:reference fields hold a series of integer values but they do so 
in a column of type 'text' . They are strings of integers separated with 
'|'. If I were going to use SQL, rather than DAL methods to update a 
list:reference field of this kind, would inserting a string like this - 
'|100|300|450|' - work the same as a field updated by the DAL with a list? 
Or is the DAL doing something else behind the scenes when you update the 
field that would be excluded from a simple SQL update. 

Grateful for any input.

Thanks. 

-- 





[web2py] Twitter Bootstrap scatfolding application *updated.

2012-08-23 Thread Martín Mulone
Twitter Bootstrap scatfolding application *updated.

Now is awesome :-P

* Now based on version 2.1.0 (sync)
* Menu based on twitter bootstrap navbar (support multilevel menu)
* Plugin highlight.
* Many fixes to layout now support responsive.
* Very clean layout.
* Started to document (getting)
* Some examples.
* Flash is render as alert.

Working demo: http://testbootstrap.tecnodoc.com.ar/
Doc: http://testbootstrap.tecnodoc.com.ar/getting
Source: https://bitbucket.org/mulonemartin/bootstrap

Note: Not yet fully tested.

-- 





Re: [web2py] Major speed improvement need testers

2012-08-23 Thread Anthony

>
> I'd also still be interested to see a real-world example of where this 
>> would be useful.
>>
>> Anthony
>>
>
> Someone posted an example of GAE CPU Cycles, with class based Lazy Tables 
> it lower to half cycles. Also there is another user in the group which has 
> a huge traffic, so Lazy tables might be useful.
>

No, I meant an example of where the new on_delete argument would be useful.

Anthony 

-- 





Re: [web2py] Major speed improvement need testers

2012-08-23 Thread Bruno Rocha
On Thu, Aug 23, 2012 at 3:11 PM, Anthony  wrote:

> I'd also still be interested to see a real-world example of where this
> would be useful.
>
> Anthony
>

Someone posted an example of GAE CPU Cycles, with class based Lazy Tables
it lower to half cycles. Also there is another user in the group which has
a huge traffic, so Lazy tables might be useful.

I would like to test it ASAP.

-- 





[web2py] Re: custom built login form

2012-08-23 Thread Anthony
Can you show some code or provide a little more detail regarding what 
you're trying to do?

On Thursday, August 23, 2012 12:39:47 PM UTC-4, shartha wrote:
>
> Sorry for being out of touch. I discovered what was causing the issue 
> initially. If I try to assign a value to the id or name attributes of any 
> of the login form elements, the form.cust.widget will not work as expected. 
> So if you have any insight into this, please let me know as it'd be helpful 
> under certain circumstances to be able to do that. 
>
> On Tuesday, August 14, 2012 10:51:12 PM UTC-7, shartha wrote:
>>
>> Hello, 
>> Quick question:
>> Instead of {{=auth.login()}}, I am using the following to be able to 
>> customize my login form. However the resulting form does not work and I 
>> cannot login with the same username/password that enable me to login if I 
>> had used {{=auth.login()}} -- I get the flash error: Invalid Login.
>>
>> Could someone please tell me what's possibly going wrong? Thanks!
>>
>> {{form=auth.login()}}
>> {{=form.custom.begin}} 
>> Username:
>> {{=form.custom.widget.username}}
>> 
>> Password:
>> {{=form.custom.widget.password}}
>> {{=form.custom.submit}} 
>> {{=form.custom.end}} 
>>
>

-- 





Re: [web2py] Major speed improvement need testers

2012-08-23 Thread Anthony
I'd also still be interested to see a real-world example of where this 
would be useful.

Anthony

On Thursday, August 23, 2012 12:19:24 PM UTC-4, Jonathan Lundell wrote:
>
> On 23 Aug 2012, at 9:16 AM, Massimo Di Pierro 
> > 
> wrote:
>
> Isn't that what my code does?
>
> In the example I used a lambda instead of a function but the 
> implementation should be exactly what you say. Perhaps I misunderstood.
>
>
> Or maybe I did. I'll have a chance to look at it more closely later. Let's 
> label it experimental for now.
>
>
> BTW. Auth is now fully lazy, when DAL(lazy_tables=True), and therefore 
> should be faster. Needs testing and benchmarking.
>
> massimo
>
>
> On Thursday, 23 August 2012 10:45:42 UTC-5, Jonathan Lundell wrote:
>>
>> On 23 Aug 2012, at 8:39 AM, Anthony  wrote:
>>
>> Couple of things (including questions).
>>>
>>> 1. attributes defined in the Field() spec are lazy already, right?
>>>
>>
>> I guess not so much "lazy", but for the most part all that happens is 
>> they get added as attributes to the Field's self. There is a little logic 
>> in the constructor, though. I suppose we don't really need to make them 
>> much more lazy, but then I'm wondering about the use case for on_define.
>>  
>>
>>> In the above example, the attributes could just as well be defined 
>>> there; my intent was for attributes that required more logic, where 
>>> attributes are being set conditionally and it's clumsy to construct 
>>> different Field() calls to do it.
>>>
>>
>> OK, sounds reasonable. Do you have an example?
>>
>>
>> More later (I'm off to a meeting). 
>>
>> Looking at the new code, I see that Massimo and I had different ideas 
>> about the definition of on_define. I think they both have merit, and I need 
>> to consider the implications. Briefly, the new code patches up the table 
>> definition, which will be used as usual in a lazy fashion.
>>
>> My version defined a function to be called when the table was actually 
>> created (later, lazily).
>>
>
>
>
>
>

-- 





[web2py] Re: Web2Py in cluster and DATABASES folder

2012-08-23 Thread Massimo Di Pierro
If they share the database, they should also share the folder. Anyway, mind 
that file IO is a major bottleneck and accessing a shared filesystem is 
every worse.

Setting migrate=False prevents the file system access completely.

Ideally should have a way to set migrate=True only when the new 
organization joins and migrate=True when it joined already. You should be 
able to perform this check without looking at the filesystem.



On Thursday, 23 August 2012 12:15:49 UTC-5, Mike wrote:
>
> Perhaps I haven't made myself clear enough...
>
> Forget about development environment - think cluster deployment scenario 
> only.
> I can't create databases in advance - in fact, the server code is written 
> to create a new schema (using MySQL parlance) every time a new group of 
> customers (an "organization") is joining the site. As such, any of the 
> servers in the cluster at any point in time could be faced with the task of 
> creating a new schema, a new sub-folder inside DATABASES and initializing 
> the schema with appropriate tables and sub-folder - with appropriate .table 
> files. My only issue is whether or not DATABASES folder should be shared 
> among the machines in the cluster (like SESSIONS, for instance) or if each 
> of them should maintain its own (less preferable, for various reasons). And 
> that bug will have to be fixed, of course.
>
> On Thursday, August 23, 2012 12:42:06 PM UTC-4, Niphlod wrote:
>>
>> ehm... deploy. production. cluster.
>> You say that "some .table files are created" hence I think you're using 
>> the same database uri both for production and development (if any). If 
>> .table files are created, it's safe to assume that the underlying code 
>> changes too, right ?
>> If so, a simply copy/rsync from a "development" to all the "cluster" 
>> machines suffices, without you ending in misery. Why all the pain if you 
>> have to sync the code accross cluster if .table files can travel the same 
>> way as your codebase ?
>>
>> Il giorno giovedì 23 agosto 2012 17:14:51 UTC+2, Mike ha scritto:
>>>
>>> We are planning on deploying our Web2Py application under Apache-WSGI on 
>>> a cluster of servers all accessing the same multiple databases. Since the 
>>> new databases will be created on the fly, as needed, we cannot predict 
>>> beforehand how many we will end up using and, consequently, how many files 
>>> will end up being created in DATABASES folder. As a result, I am trying to 
>>> create sub-folders under DATABASES and set MIGRATE parameter on 
>>> .define_table() call for a given database to />> name>.table. Such approach allows me to better control the overall number 
>>> of files in a single folder as well as make the overall picture more 
>>> manageable. There is one problem with this approach and one question for 
>>> the experts:
>>>
>>> 1. A problem - we are using Auth to authenticate users and so need to 
>>> perform auth.define_tables(). By passing to it migrate=">> name>/", I almost made it create all the auth_ table files in that 
>>> sub-folder, except that there is a typo in TOOLS.PY, line 1420 in my source 
>>> code for version 1.99.7, where instead of expected 
>>> 
>>> migrate=self.__get_migrate(settings.table_cas_name, migrate),
>>> 
>>> it goes
>>> 
>>> migrate=self.__get_migrate(settings.table_event_name, migrate),
>>>
>>> I've fixed it in my copy and would like to request that the fix should 
>>> be made in the official release code base as well.
>>>
>>> 2. A question - should DATABASES folder be shared among the 
>>> Apache-Web2Py machines or should each maintain its own copy? More 
>>> specifically, is there any locking mechanism on those .table files built 
>>> specifically for the purpose of sharing between threads/machines? I intend 
>>> to use migrate_enabled=False when creating an instance of DAL if I know 
>>> that the tables have already been created, but to make sure that multiple 
>>> machines won't try to create the new database/new sub-folder at the same 
>>> time, I will probably have to build some locks outside DAL. Is this even 
>>> the right way of thinking about this problem?
>>>
>>> Sorry for the long-winded question. Great framework, BTW. :)
>>>
>>>

-- 





[web2py] Re: Web2Py in cluster and DATABASES folder

2012-08-23 Thread Mike
Perhaps I haven't made myself clear enough...

Forget about development environment - think cluster deployment scenario 
only.
I can't create databases in advance - in fact, the server code is written 
to create a new schema (using MySQL parlance) every time a new group of 
customers (an "organization") is joining the site. As such, any of the 
servers in the cluster at any point in time could be faced with the task of 
creating a new schema, a new sub-folder inside DATABASES and initializing 
the schema with appropriate tables and sub-folder - with appropriate .table 
files. My only issue is whether or not DATABASES folder should be shared 
among the machines in the cluster (like SESSIONS, for instance) or if each 
of them should maintain its own (less preferable, for various reasons). And 
that bug will have to be fixed, of course.

On Thursday, August 23, 2012 12:42:06 PM UTC-4, Niphlod wrote:
>
> ehm... deploy. production. cluster.
> You say that "some .table files are created" hence I think you're using 
> the same database uri both for production and development (if any). If 
> .table files are created, it's safe to assume that the underlying code 
> changes too, right ?
> If so, a simply copy/rsync from a "development" to all the "cluster" 
> machines suffices, without you ending in misery. Why all the pain if you 
> have to sync the code accross cluster if .table files can travel the same 
> way as your codebase ?
>
> Il giorno giovedì 23 agosto 2012 17:14:51 UTC+2, Mike ha scritto:
>>
>> We are planning on deploying our Web2Py application under Apache-WSGI on 
>> a cluster of servers all accessing the same multiple databases. Since the 
>> new databases will be created on the fly, as needed, we cannot predict 
>> beforehand how many we will end up using and, consequently, how many files 
>> will end up being created in DATABASES folder. As a result, I am trying to 
>> create sub-folders under DATABASES and set MIGRATE parameter on 
>> .define_table() call for a given database to /> name>.table. Such approach allows me to better control the overall number 
>> of files in a single folder as well as make the overall picture more 
>> manageable. There is one problem with this approach and one question for 
>> the experts:
>>
>> 1. A problem - we are using Auth to authenticate users and so need to 
>> perform auth.define_tables(). By passing to it migrate="> name>/", I almost made it create all the auth_ table files in that 
>> sub-folder, except that there is a typo in TOOLS.PY, line 1420 in my source 
>> code for version 1.99.7, where instead of expected 
>> 
>> migrate=self.__get_migrate(settings.table_cas_name, migrate),
>> 
>> it goes
>> 
>> migrate=self.__get_migrate(settings.table_event_name, migrate),
>>
>> I've fixed it in my copy and would like to request that the fix should be 
>> made in the official release code base as well.
>>
>> 2. A question - should DATABASES folder be shared among the Apache-Web2Py 
>> machines or should each maintain its own copy? More specifically, is there 
>> any locking mechanism on those .table files built specifically for the 
>> purpose of sharing between threads/machines? I intend to use 
>> migrate_enabled=False when creating an instance of DAL if I know that the 
>> tables have already been created, but to make sure that multiple machines 
>> won't try to create the new database/new sub-folder at the same time, I 
>> will probably have to build some locks outside DAL. Is this even the right 
>> way of thinking about this problem?
>>
>> Sorry for the long-winded question. Great framework, BTW. :)
>>
>>

-- 





[web2py] Re: Web2Py in cluster and DATABASES folder

2012-08-23 Thread Niphlod
ehm... deploy. production. cluster.
You say that "some .table files are created" hence I think you're using the 
same database uri both for production and development (if any). If .table 
files are created, it's safe to assume that the underlying code changes 
too, right ?
If so, a simply copy/rsync from a "development" to all the "cluster" 
machines suffices, without you ending in misery. Why all the pain if you 
have to sync the code accross cluster if .table files can travel the same 
way as your codebase ?

Il giorno giovedì 23 agosto 2012 17:14:51 UTC+2, Mike ha scritto:
>
> We are planning on deploying our Web2Py application under Apache-WSGI on a 
> cluster of servers all accessing the same multiple databases. Since the new 
> databases will be created on the fly, as needed, we cannot predict 
> beforehand how many we will end up using and, consequently, how many files 
> will end up being created in DATABASES folder. As a result, I am trying to 
> create sub-folders under DATABASES and set MIGRATE parameter on 
> .define_table() call for a given database to / name>.table. Such approach allows me to better control the overall number 
> of files in a single folder as well as make the overall picture more 
> manageable. There is one problem with this approach and one question for 
> the experts:
>
> 1. A problem - we are using Auth to authenticate users and so need to 
> perform auth.define_tables(). By passing to it migrate=" name>/", I almost made it create all the auth_ table files in that 
> sub-folder, except that there is a typo in TOOLS.PY, line 1420 in my source 
> code for version 1.99.7, where instead of expected 
> 
> migrate=self.__get_migrate(settings.table_cas_name, migrate),
> 
> it goes
> 
> migrate=self.__get_migrate(settings.table_event_name, migrate),
>
> I've fixed it in my copy and would like to request that the fix should be 
> made in the official release code base as well.
>
> 2. A question - should DATABASES folder be shared among the Apache-Web2Py 
> machines or should each maintain its own copy? More specifically, is there 
> any locking mechanism on those .table files built specifically for the 
> purpose of sharing between threads/machines? I intend to use 
> migrate_enabled=False when creating an instance of DAL if I know that the 
> tables have already been created, but to make sure that multiple machines 
> won't try to create the new database/new sub-folder at the same time, I 
> will probably have to build some locks outside DAL. Is this even the right 
> way of thinking about this problem?
>
> Sorry for the long-winded question. Great framework, BTW. :)
>
>

-- 





[web2py] Re: custom built login form

2012-08-23 Thread shartha
Sorry for being out of touch. I discovered what was causing the issue 
initially. If I try to assign a value to the id or name attributes of any 
of the login form elements, the form.cust.widget will not work as expected. 
So if you have any insight into this, please let me know as it'd be helpful 
under certain circumstances to be able to do that. 

On Tuesday, August 14, 2012 10:51:12 PM UTC-7, shartha wrote:
>
> Hello, 
> Quick question:
> Instead of {{=auth.login()}}, I am using the following to be able to 
> customize my login form. However the resulting form does not work and I 
> cannot login with the same username/password that enable me to login if I 
> had used {{=auth.login()}} -- I get the flash error: Invalid Login.
>
> Could someone please tell me what's possibly going wrong? Thanks!
>
> {{form=auth.login()}}
> {{=form.custom.begin}} 
> Username:
> {{=form.custom.widget.username}}
> 
> Password:
> {{=form.custom.widget.password}}
> {{=form.custom.submit}} 
> {{=form.custom.end}} 
>

-- 





[web2py] Re: Access layout file in another application

2012-08-23 Thread curiouslearn
Thanks, Anthony. I will also go with the method you showed.

On Thursday, August 23, 2012 11:05:44 AM UTC-4, Anthony wrote:
>
> I think I would use the method I showed rather than links.
>
> Anthony
>

-- 





[web2py] Re: how to save the id when passing a dict in an insert

2012-08-23 Thread puercoespin


El jueves, 23 de agosto de 2012 15:50:41 UTC+2, Anthony escribió:
>
> Do you have an existing dict and you need to insert it as a record, but 
> also want the record id? In that case, you can do:
>
> id = db.person.insert(**some_dict)
>
> Anthony
>

  Thanks Antony! That works.

 I tried:

 id=db.person.insert(some_dict).. without the two stars!... Thanks 
again.

-- 





Re: [web2py] Major speed improvement need testers

2012-08-23 Thread Jonathan Lundell
On 23 Aug 2012, at 9:16 AM, Massimo Di Pierro  
wrote:
> Isn't that what my code does?
> 
> In the example I used a lambda instead of a function but the implementation 
> should be exactly what you say. Perhaps I misunderstood.

Or maybe I did. I'll have a chance to look at it more closely later. Let's 
label it experimental for now.

> 
> BTW. Auth is now fully lazy, when DAL(lazy_tables=True), and therefore should 
> be faster. Needs testing and benchmarking.
> 
> massimo
> 
> 
> On Thursday, 23 August 2012 10:45:42 UTC-5, Jonathan Lundell wrote:
> On 23 Aug 2012, at 8:39 AM, Anthony  wrote:
>> Couple of things (including questions).
>> 
>> 1. attributes defined in the Field() spec are lazy already, right?
>> 
>> I guess not so much "lazy", but for the most part all that happens is they 
>> get added as attributes to the Field's self. There is a little logic in the 
>> constructor, though. I suppose we don't really need to make them much more 
>> lazy, but then I'm wondering about the use case for on_define.
>>  
>> In the above example, the attributes could just as well be defined there; my 
>> intent was for attributes that required more logic, where attributes are 
>> being set conditionally and it's clumsy to construct different Field() calls 
>> to do it.
>> 
>> OK, sounds reasonable. Do you have an example?
>> 
> 
> More later (I'm off to a meeting). 
> 
> Looking at the new code, I see that Massimo and I had different ideas about 
> the definition of on_define. I think they both have merit, and I need to 
> consider the implications. Briefly, the new code patches up the table 
> definition, which will be used as usual in a lazy fashion.
> 
> My version defined a function to be called when the table was actually 
> created (later, lazily).
> 
> 


-- 





Re: [web2py] Major speed improvement need testers

2012-08-23 Thread Massimo Di Pierro
Isn't that what my code does?

In the example I used a lambda instead of a function but the implementation 
should be exactly what you say. Perhaps I misunderstood.

BTW. Auth is now fully lazy, when DAL(lazy_tables=True), and therefore 
should be faster. Needs testing and benchmarking.

massimo


On Thursday, 23 August 2012 10:45:42 UTC-5, Jonathan Lundell wrote:
>
> On 23 Aug 2012, at 8:39 AM, Anthony > 
> wrote:
>
> Couple of things (including questions).
>>
>> 1. attributes defined in the Field() spec are lazy already, right?
>>
>
> I guess not so much "lazy", but for the most part all that happens is they 
> get added as attributes to the Field's self. There is a little logic in the 
> constructor, though. I suppose we don't really need to make them much more 
> lazy, but then I'm wondering about the use case for on_define.
>  
>
>> In the above example, the attributes could just as well be defined there; 
>> my intent was for attributes that required more logic, where attributes are 
>> being set conditionally and it's clumsy to construct different Field() 
>> calls to do it.
>>
>
> OK, sounds reasonable. Do you have an example?
>
>
> More later (I'm off to a meeting). 
>
> Looking at the new code, I see that Massimo and I had different ideas 
> about the definition of on_define. I think they both have merit, and I need 
> to consider the implications. Briefly, the new code patches up the table 
> definition, which will be used as usual in a lazy fashion.
>
> My version defined a function to be called when the table was actually 
> created (later, lazily).
>

-- 





[web2py] Re: Extra field not getting validated.

2012-08-23 Thread Massimo Di Pierro
No problem. I prefer false positive than false negative. It means people 
are using and checking. ;-)


On Thursday, 23 August 2012 07:52:08 UTC-5, Rujaun Fourie wrote:
>
> Sorry for wasting your time Massimo
>
> db.auth_user.nickname.requires = IS_NOT_IN_DB(db, 'auth_user.nickname')
>
> was the validator I used. But I forgot to mention that down the line I 
> have:
>
> db.auth_user.nickname.requires = IS_NOT_EMPTY()
>
> And that messed it up.
>
>

-- 





Re: [web2py] Major speed improvement need testers

2012-08-23 Thread Jonathan Lundell
On 23 Aug 2012, at 8:39 AM, Anthony  wrote:
> Couple of things (including questions).
> 
> 1. attributes defined in the Field() spec are lazy already, right?
> 
> I guess not so much "lazy", but for the most part all that happens is they 
> get added as attributes to the Field's self. There is a little logic in the 
> constructor, though. I suppose we don't really need to make them much more 
> lazy, but then I'm wondering about the use case for on_define.
>  
> In the above example, the attributes could just as well be defined there; my 
> intent was for attributes that required more logic, where attributes are 
> being set conditionally and it's clumsy to construct different Field() calls 
> to do it.
> 
> OK, sounds reasonable. Do you have an example?
> 

More later (I'm off to a meeting). 

Looking at the new code, I see that Massimo and I had different ideas about the 
definition of on_define. I think they both have merit, and I need to consider 
the implications. Briefly, the new code patches up the table definition, which 
will be used as usual in a lazy fashion.

My version defined a function to be called when the table was actually created 
(later, lazily).

-- 





Re: [web2py] Major speed improvement need testers

2012-08-23 Thread Anthony

>
> Couple of things (including questions).
>
> 1. attributes defined in the Field() spec are lazy already, right? 
>

I guess not so much "lazy", but for the most part all that happens is they 
get added as attributes to the Field's self. There is a little logic in the 
constructor, though. I suppose we don't really need to make them much more 
lazy, but then I'm wondering about the use case for on_define.
 

> In the above example, the attributes could just as well be defined there; 
> my intent was for attributes that required more logic, where attributes are 
> being set conditionally and it's clumsy to construct different Field() 
> calls to do it.
>

OK, sounds reasonable. Do you have an example?

Anthony

-- 





[web2py] Web2Py Cookbook - Designing modular applications CORRECTION

2012-08-23 Thread Fred Kornyev
Hello!

I was not able to find this information in one place so I had to piece it 
together, so I thought I would share it here:

On page 94 in the Cookbook the "Designing modular applications" example has 
some mistakes and consequently the new item is not displayed automatically when 
using the create form.

The problem lies in this function:
def edit_item():
def display_changed(data):
response.ajax = 'web2py_component("%s","show_itemlist")' 
%URL('showitems')
form = crud.update(db.mytable, request.args(0), onaccept=display_changed)
return form

specifically the 3rd line needs to be changed to:
response.js = "web2py_component('%s', 'showitems')" %URL('default','list_items')

It should be 
 - 1: response.js instead of response.ajax
 - 2: the web2py_component has to target the showitems DIV (created by the LOAD 
helper on the index page)
 - 3: the URL has to point to the list_items view

Well this is just what worked for me after a few tries, it may not be 100% 
correct, I am still learning!

-- 





[web2py] Web2Py in cluster and DATABASES folder

2012-08-23 Thread Mike
We are planning on deploying our Web2Py application under Apache-WSGI on a 
cluster of servers all accessing the same multiple databases. Since the new 
databases will be created on the fly, as needed, we cannot predict beforehand 
how many we will end up using and, consequently, how many files will end up 
being created in DATABASES folder. As a result, I am trying to create 
sub-folders under DATABASES and set MIGRATE parameter on .define_table() call 
for a given database to /.table. Such approach 
allows me to better control the overall number of files in a single folder as 
well as make the overall picture more manageable. There is one problem with 
this approach and one question for the experts:

1. A problem - we are using Auth to authenticate users and so need to perform 
auth.define_tables(). By passing to it migrate="/", I almost 
made it create all the auth_ table files in that sub-folder, except that there 
is a typo in TOOLS.PY, line 1420 in my source code for version 1.99.7, where 
instead of expected 

migrate=self.__get_migrate(settings.table_cas_name, migrate),

it goes

migrate=self.__get_migrate(settings.table_event_name, migrate),

I've fixed it in my copy and would like to request that the fix should be made 
in the official release code base as well.

2. A question - should DATABASES folder be shared among the Apache-Web2Py 
machines or should each maintain its own copy? More specifically, is there any 
locking mechanism on those .table files built specifically for the purpose of 
sharing between threads/machines? I intend to use migrate_enabled=False when 
creating an instance of DAL if I know that the tables have already been 
created, but to make sure that multiple machines won't try to create the new 
database/new sub-folder at the same time, I will probably have to build some 
locks outside DAL. Is this even the right way of thinking about this problem?

Sorry for the long-winded question. Great framework, BTW. :)

-- 





[web2py] Re: how to parse xml in web2py?

2012-08-23 Thread villas
If the XML is not well-formed, take a look at beautiful soup.   I have 
never found a parser so tolerant and forgiving.

On Thursday, August 23, 2012 2:59:25 PM UTC+1, Anthony wrote:
>
> For simple parsing, you can also use the built-in TAG() helper -- see 
> http://web2py.com/books/default/chapter/29/5#Parsing.
>
> FYI, in your example, some of the closing tags do not match their 
> associated opening tags.
>
> Anthony
>
> On Thursday, August 23, 2012 5:53:32 AM UTC-4, Amit wrote:
>>
>> Hi,
>> I have web service method in my application which will receive xml file 
>> from the request, i need to parse it and save the extracted data to the 
>> database. Please suggest me the best way to parse xml in web2py.
>>
>> xml format would be like below:
>>
>> 
>> 
>>   
>> 123456
>> 2012-06-30
>> 1
>> adadafdfdgfgfhggjghjjj
>>   
>> 
>>
>

-- 





Re: [web2py] Major speed improvement need testers

2012-08-23 Thread Jonathan Lundell
On 23 Aug 2012, at 7:48 AM, Anthony  wrote:
> db = DAL(lazy_tables=True)
> db.define_table('person',Field('name'),Field('age','integer'),
>on_define=lambda table: [
>table.name.set_attributes(requires=IS_NOT_EMPTY(),default=''),
>
> table.age.set_attributes(requires=IS_INT_IN_RANGE(0,120),default=30),
>   ])
> 
> and the attributes will be set lazily. This is a good idea! Thanks Jonathan.
> 
> Syntax is kind of clunky. How difficult would it be to make lazy Fields so 
> attributes are automatically lazy?
> 

Couple of things (including questions).

1. attributes defined in the Field() spec are lazy already, right? In the above 
example, the attributes could just as well be defined there; my intent was for 
attributes that required more logic, where attributes are being set 
conditionally and it's clumsy to construct different Field() calls to do it.

2. It does not, of course, have to be a lambda expression. My own inclination 
would be to define a separate function.

3. Is there a particular reason to use set_attributes? Why not the more 
readable: table.name.requires = ... ?

-- 





[web2py] Re: Access layout file in another application

2012-08-23 Thread Anthony
I think I would use the method I showed rather than links.

Anthony

On Thursday, August 23, 2012 10:54:11 AM UTC-4, curiouslearn wrote:
>
> Thank you, Anthony. That worked well. 
>
> Do you have an opinion on which is a better method (in terms of easier to 
> maintain, less problems that I cannot foresee given my lack of experience 
> building web apps): the links of using extend as suggested?
>
> Thanks again.
>
> On Thursday, August 23, 2012 10:30:33 AM UTC-4, Anthony wrote:
>>
>> {{extend ...}} takes a file path, not a URL, and it needs to be relative 
>> to the current application's /views folder. So you can use directory 
>> traversal to get to the other layout:
>>
>> {{extend '../../myadminapp/views/default/mylayout.html'}}
>>
>> The ../../ will go up two levels from /applications/current_app/views to 
>> /applications, and then the rest of the path follows from there.
>>
>> Anthony
>>
>> On Thursday, August 23, 2012 10:08:09 AM UTC-4, curiouslearn wrote:
>>>
>>> Hello,
>>>
>>> I searched on the forums here and it appears that the suggested solution 
>>> for accessing a layout file is to create links (hard links or soft links?). 
>>>
>>> I have two questions in this regard:
>>>
>>> (i) Is this solution robust to changes in where the application is 
>>> hosted? Would the links works regardless of whether I have it hosted on 
>>> EC2, or dotcloud, or pythonanywhere etc.
>>>
>>> (ii) Is it possible to do this using the {{extend ...}} command? If so, 
>>> I would appreciate an example. 
>>>
>>> For example, suppose I am in application called *participants *and I 
>>> want to use the layout file in application *myadminapp *(in *myadminapp* 
>>> the 
>>> layout file is in views/default/). I tried doing the following, but none of 
>>> these work. 
>>>
>>> {{extend URL(a='myadminapp', c='  ', f='views/default/mylayout.html')}} 
>>>  results in /myadminapp/ /views/default/mylayout.html
>>>
>>> {{extend URL(a='myadminapp', f='views/default/mylayout.html')}}  results 
>>> in /myadminapp/default/views/default/mylayout.html
>>>
>>> I also tried:
>>> {{extend '/myadminapp/views/default/mylayout.html'}}, which gives the 
>>> following error:
>>>
>>> ([Errno 2] No such file or directory: 
>>> '/myadminapp/views/default/mylayout.html')
>>>
>>> This *error is strange* because there does exist an application 
>>> *myadminapp, 
>>> *with folder views with folder default with file mylayout.html.
>>>
>>> Thanks.
>>>
>>

-- 





[web2py] how to parse xml in web2py?

2012-08-23 Thread Mike Girard
ElementTree or cElementTree are good. CElementTree is said to be faster.

The most important thing is the method you use. If your sample is the extent of 
the document, any parser will do.  However, if your actual documents are large, 
you should consider an iterparsing method to conserve memory.

I think the most robust parser in terms of methods is lxml, which supports XSL 
and XPath along with  ElementTrees.  However, it requires separate 
installation. Python ships with ElementTree and cElementTree which are fine for 
most cases. 

-- 





[web2py] Re: Access layout file in another application

2012-08-23 Thread curiouslearn
Thank you, Anthony. That worked well. 

Do you have an opinion on which is a better method (in terms of easier to 
maintain, less problems that I cannot foresee given my lack of experience 
building web apps): the links of using extend as suggested?

Thanks again.

On Thursday, August 23, 2012 10:30:33 AM UTC-4, Anthony wrote:
>
> {{extend ...}} takes a file path, not a URL, and it needs to be relative 
> to the current application's /views folder. So you can use directory 
> traversal to get to the other layout:
>
> {{extend '../../myadminapp/views/default/mylayout.html'}}
>
> The ../../ will go up two levels from /applications/current_app/views to 
> /applications, and then the rest of the path follows from there.
>
> Anthony
>
> On Thursday, August 23, 2012 10:08:09 AM UTC-4, curiouslearn wrote:
>>
>> Hello,
>>
>> I searched on the forums here and it appears that the suggested solution 
>> for accessing a layout file is to create links (hard links or soft links?). 
>>
>> I have two questions in this regard:
>>
>> (i) Is this solution robust to changes in where the application is 
>> hosted? Would the links works regardless of whether I have it hosted on 
>> EC2, or dotcloud, or pythonanywhere etc.
>>
>> (ii) Is it possible to do this using the {{extend ...}} command? If so, I 
>> would appreciate an example. 
>>
>> For example, suppose I am in application called *participants *and I 
>> want to use the layout file in application *myadminapp *(in *myadminapp* the 
>> layout file is in views/default/). I tried doing the following, but none of 
>> these work. 
>>
>> {{extend URL(a='myadminapp', c='  ', f='views/default/mylayout.html')}} 
>>  results in /myadminapp/ /views/default/mylayout.html
>>
>> {{extend URL(a='myadminapp', f='views/default/mylayout.html')}}  results 
>> in /myadminapp/default/views/default/mylayout.html
>>
>> I also tried:
>> {{extend '/myadminapp/views/default/mylayout.html'}}, which gives the 
>> following error:
>>
>> ([Errno 2] No such file or directory: 
>> '/myadminapp/views/default/mylayout.html')
>>
>> This *error is strange* because there does exist an application *myadminapp, 
>> *with folder views with folder default with file mylayout.html.
>>
>> Thanks.
>>
>

-- 





[web2py] Internal ip to external access

2012-08-23 Thread Gerald Klein
Hi all, I was wondering if anyone could direct me to a resource that will
outline the techniques used to grant external access to an internal ip,
along the lines of NetMeeting. I have tried to google and not getting a lot
of traction on the subject, if someone knows a resource that would be
great. The app is not a meeting app but to programmatically allow external
access to internal ip cameras on a users internal network.

thanks

-- 

Gerald Klein DBA

geraldklein.wordpress.com

j...@zognet.com

708-599-0352


Arch Awesome, Ranger & Vim the coding triple threat.

Linux registered user #548580

-- 





Re: [web2py] Major speed improvement need testers

2012-08-23 Thread Anthony

>
> db = DAL(lazy_tables=True)
> db.define_table('person',Field('name'),Field('age','integer'),
>on_define=lambda table: [
>table.name.set_attributes(requires=IS_NOT_EMPTY(),default=''),
>   
>  table.age.set_attributes(requires=IS_INT_IN_RANGE(0,120),default=30),
>   ])
>
> and the attributes will be set lazily. This is a good idea! Thanks 
> Jonathan.
>

Syntax is kind of clunky. How difficult would it be to make lazy Fields so 
attributes are automatically lazy?

Anthony 

-- 





[web2py] Re: Access layout file in another application

2012-08-23 Thread Anthony
{{extend ...}} takes a file path, not a URL, and it needs to be relative to 
the current application's /views folder. So you can use directory traversal 
to get to the other layout:

{{extend '../../myadminapp/views/default/mylayout.html'}}

The ../../ will go up two levels from /applications/current_app/views to 
/applications, and then the rest of the path follows from there.

Anthony

On Thursday, August 23, 2012 10:08:09 AM UTC-4, curiouslearn wrote:
>
> Hello,
>
> I searched on the forums here and it appears that the suggested solution 
> for accessing a layout file is to create links (hard links or soft links?). 
>
> I have two questions in this regard:
>
> (i) Is this solution robust to changes in where the application is hosted? 
> Would the links works regardless of whether I have it hosted on EC2, or 
> dotcloud, or pythonanywhere etc.
>
> (ii) Is it possible to do this using the {{extend ...}} command? If so, I 
> would appreciate an example. 
>
> For example, suppose I am in application called *participants *and I want 
> to use the layout file in application *myadminapp *(in *myadminapp* the 
> layout file is in views/default/). I tried doing the following, but none of 
> these work. 
>
> {{extend URL(a='myadminapp', c='  ', f='views/default/mylayout.html')}} 
>  results in /myadminapp/ /views/default/mylayout.html
>
> {{extend URL(a='myadminapp', f='views/default/mylayout.html')}}  results 
> in /myadminapp/default/views/default/mylayout.html
>
> I also tried:
> {{extend '/myadminapp/views/default/mylayout.html'}}, which gives the 
> following error:
>
> ([Errno 2] No such file or directory: 
> '/myadminapp/views/default/mylayout.html')
>
> This *error is strange* because there does exist an application *myadminapp, 
> *with folder views with folder default with file mylayout.html.
>
> Thanks.
>

-- 





Re: [web2py] Major speed improvement need testers

2012-08-23 Thread Massimo Di Pierro
So now in trunk you can do:

db = DAL(lazy_tables=True)
db.define_table('person',Field('name'),Field('age','integer'),
   on_define=lambda table: [
   table.name.set_attributes(requires=IS_NOT_EMPTY(),default=''),
  
 table.age.set_attributes(requires=IS_INT_IN_RANGE(0,120),default=30),
  ])

and the attributes will be set lazily. This is a good idea! Thanks Jonathan.







On Monday, 20 August 2012 16:36:22 UTC-5, Jonathan Lundell wrote:
>
> On 20 Aug 2012, at 10:32 AM, Massimo Di Pierro 
> > 
> wrote: 
> > can you show a proof of concept? 
>
> Not exactly a proof, but a concept. 
>
> At the very end of lazy_define_table, just before 'return table': 
>
> if args.get('on_define'): 
> args.get('on_define')(table) 
>
> The caller-defined on_define function can do things like: 
>
> def on_define(table): 
> table.field.readable = True 
>
> or, more interestingly: 
>
> def on_define(table): 
> if request.something == whatever: 
> table.field.readable = True 
>
> ...etc. Assuming that there's dynamic stuff like that going on, it saves 
> having to figure out whether you're in a request in which the table is 
> going to be instantiated and then modify the fields. 
>
> One more thought, just an abstract one because I don't have an example to 
> offer. Since we're storing args at define_table time, to be used later when 
> the table is referenced, it's important that the caller not include mutable 
> objects in args and change them (in relevant ways) between the define_table 
> call and the instantiation. 
>
>
> > 
> > On Monday, 20 August 2012 11:51:27 UTC-5, Jonathan Lundell wrote: 
> > On 18 Aug 2012, at 1:46 PM, Massimo Di Pierro  
> wrote: 
> >> As Bruno says. Something like this will completely nullify the benefit 
> of lazy tables. 
> >> 
> >> Field(..., readable=True) is OK but 
> >> db.table.field.readable=True is BAD because will force db.table to be 
> instantiated. 
> >> 
> > 
> > Here's a vague idea: suppose define_table had a requirements parameter, 
> defaulting to None, that could be set to a function (lambda or otherwise) 
> that would be called after the table is instantiated? Then you'd still be 
> able to pull your dynamic requirements into one place, but without 
> triggering define-time instantiation. For convenience, the function would 
> be called for any instantiation, even a non-lazy one, so one could turn 
> lazy instantiation on & off for testing without changing it. 
> > 
>
>
>

-- 





[web2py] Access layout file in another application

2012-08-23 Thread curiouslearn
Hello,

I searched on the forums here and it appears that the suggested solution 
for accessing a layout file is to create links (hard links or soft links?). 

I have two questions in this regard:

(i) Is this solution robust to changes in where the application is hosted? 
Would the links works regardless of whether I have it hosted on EC2, or 
dotcloud, or pythonanywhere etc.

(ii) Is it possible to do this using the {{extend ...}} command? If so, I 
would appreciate an example. 

For example, suppose I am in application called *participants *and I want 
to use the layout file in application *myadminapp *(in *myadminapp* the 
layout file is in views/default/). I tried doing the following, but none of 
these work. 

{{extend URL(a='myadminapp', c='  ', f='views/default/mylayout.html')}} 
 results in /myadminapp/ /views/default/mylayout.html

{{extend URL(a='myadminapp', f='views/default/mylayout.html')}}  results in 
/myadminapp/default/views/default/mylayout.html

I also tried:
{{extend '/myadminapp/views/default/mylayout.html'}}, which gives the 
following error:

([Errno 2] No such file or directory: 
'/myadminapp/views/default/mylayout.html')

This *error is strange* because there does exist an application *myadminapp, 
*with folder views with folder default with file mylayout.html.

Thanks.

-- 





[web2py] Re: how to parse xml in web2py?

2012-08-23 Thread Anthony
For simple parsing, you can also use the built-in TAG() helper -- see 
http://web2py.com/books/default/chapter/29/5#Parsing.

FYI, in your example, some of the closing tags do not match their 
associated opening tags.

Anthony

On Thursday, August 23, 2012 5:53:32 AM UTC-4, Amit wrote:
>
> Hi,
> I have web service method in my application which will receive xml file 
> from the request, i need to parse it and save the extracted data to the 
> database. Please suggest me the best way to parse xml in web2py.
>
> xml format would be like below:
>
> 
> 
>   
> 123456
> 2012-06-30
> 1
> adadafdfdgfgfhggjghjjj
>   
> 
>

-- 





[web2py] Re: how to save the id when passing a dict in an insert

2012-08-23 Thread Anthony
Do you have an existing dict and you need to insert it as a record, but 
also want the record id? In that case, you can do:

id = db.person.insert(**some_dict)

Anthony

On Thursday, August 23, 2012 3:30:44 AM UTC-4, puercoespin wrote:
>
> Hi
>
>  if   ""db.person.insert(name='Juan',age=23)""   is equal to 
> ""db.person[0] = dict(name='Juan',age=23)""
>
> how to save the id of the new record in the second case?
>
> h=db.person.insert(name='Juan',age=23)  saves the id in h but:
>
> h=db.person[0] = dict(name='Juan',age=23)  saves the dict in h, not the id!
>
> I need to access to the id in the second case.
>
> thanks
>
>

-- 





Re: [web2py] Re: App Cookbook friends.html - no such column: auth_user.first_name

2012-08-23 Thread Patrick Ryan
Thanks, Massimo. I studied the ticket a little more closely, and it looks
like it was a problem with the controller.

I had:

*friends = db(Link.target==me).select(orderby=alphabetical)*

But the "alphabetical" variable stores a query that references
db.auth_user, so I changed it to:

*friends = db(Link.target==me)(Link.target==db.auth_user.id
).select(orderby=alphabetical)*

and everything appears to be working now.


On Tue, Aug 21, 2012 at 9:42 AM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> please try delete eveything in yourapp/databasaes
>
>
> On Tuesday, 21 August 2012 08:35:52 UTC-5, pjryan126 wrote:
>>
>> I'm working through the Friends example in the Web2py Application
>> Cookbook, and when I try the friends.html view, I get the following error:
>>
>>  no such column: auth_user.first_name
>>
>> My friends.html view is as follows:
>>
>> {{extend 'layout.html'}}
>> Friendship Offered
>> 
>>   {{for friend in friends:}}
>>   
>>
>> {{=A(name_of(db.auth_user(**friend.source)),_href=URL('**
>> wall',args=friend.source))}}
>> 
>> {{if friend.accepted:}}accepted{{**else:}}> onclick="ajax('{{=URL('**friendship',args=('accept',**friend.source))}}',
>> [],null); $(this).parent().html('**accepted')">accept{{**
>> pass}}> td>
>>> onclick="ajax('{{=URL('**friendship',args=('deny',**friend.source))}}',
>> [],null); $(this).parent().html('denied'**)">deny
>>   
>>   {{pass}}
>> 
>> Friendship Requested
>> 
>>   {{for friend in requests:}}
>>   
>>
>> {{=A(name_of(db.auth_user(**friend.target)),_href=URL('**
>> wall',args=friend.target))}}
>> 
>> {{if friend.accepted:}}accepted{{**else:}}pending{{pass}}
>> > onclick="ajax('{{=URL('**friendship',args=('deny',**friend.target))}}',
>> [],null); $(this).parent().html('**removed')">remove
>>   
>>   {{pass}}
>> 
>>
>> Any help with this error would be greatly appreciated!
>>
>  --
>
>
>
>

-- 





[web2py] Re: Automatically login after account creation

2012-08-23 Thread Anthony
If account creation is not going through the usual registration process 
(i.e., calling auth.register()), you can programmatically log in the user 
by calling auth.login_bare([email address], [password]) -- so you will need 
to generate a temporary password.

Anthony

On Thursday, August 23, 2012 8:00:43 AM UTC-4, Daniel Gonzalez wrote:
>
> Hi,
>
> I would like to implement the following flow:
>
>1. The user provides his email address, and clicks "register"
>2. An account is created, and an email is sent with information 
>(eventually with a confirmation link, but I will do this later)
>3. The user is then *automatically* logged in.
>4. Then I will probably force the user to choose a password, so that 
>the next time he can log in normally
>
> I am now stuck in point 3: I want the user to be automatically logged-in, 
> even though no password is defined, and without the user entering any extra 
> information.
> Since he has already provided the email address, and this is a new 
> account, he should be immediately be logged-in.
> How can I programmatically trigger a log-in in web2py? Will this also set 
> the necessary cookies in the client side?
>
> Thanks
> Daniel
>

-- 





[web2py] Re: Extra field not getting validated.

2012-08-23 Thread Rujaun Fourie
Sorry for wasting your time Massimo

db.auth_user.nickname.requires = IS_NOT_IN_DB(db, 'auth_user.nickname')

was the validator I used. But I forgot to mention that down the line I have:

db.auth_user.nickname.requires = IS_NOT_EMPTY()

And that messed it up.

-- 





[web2py] Re: Automatically login after account creation

2012-08-23 Thread Massimo Di Pierro
auth.settings.registration_requires_verification = True # 2
auth.settings.login_after_registration = True # 3



On Thursday, 23 August 2012 07:00:43 UTC-5, Daniel Gonzalez wrote:
>
> Hi,
>
> I would like to implement the following flow:
>
>1. The user provides his email address, and clicks "register"
>2. An account is created, and an email is sent with information 
>(eventually with a confirmation link, but I will do this later)
>3. The user is then *automatically* logged in.
>4. Then I will probably force the user to choose a password, so that 
>the next time he can log in normally
>
> I am now stuck in point 3: I want the user to be automatically logged-in, 
> even though no password is defined, and without the user entering any extra 
> information.
> Since he has already provided the email address, and this is a new 
> account, he should be immediately be logged-in.
> How can I programmatically trigger a log-in in web2py? Will this also set 
> the necessary cookies in the client side?
>
> Thanks
> Daniel
>

-- 





[web2py] Re: URL() on *.load page

2012-08-23 Thread tomasz bandura
...

extension=False

this is a little confusing ( it is appended to the function ), but it works


2012/8/23 tomasz bandura 

> Hello,
>
> How to properly generate url on LOAD page (with ajax=False)?
>
> Image html tag:
> 
>
> Is rendered as:
> 
>
> Regards,
> Tomasz

-- 





[web2py] Re: Extra field not getting validated.

2012-08-23 Thread Massimo Di Pierro
Some days yet and some days no. Today yes.

On Thursday, 23 August 2012 02:39:01 UTC-5, Rujaun Fourie wrote:
>
> Sorry if this is a stupid question but can I use the trunk in a production 
> enviroment? 

-- 





[web2py] Re: Accessing db['auth_user'] raises exception

2012-08-23 Thread Massimo Di Pierro
What's wrong with the grid?

On Wednesday, 22 August 2012 23:52:01 UTC-5, Simon Ashley wrote:
>
> Noted and confirmed. 
> Must be a different issue. 
> Will investigate further and raise on a new thread. 
>
> The current situation is that the application/ grid works fine on a trunk 
> from 2012-07-21 but not on anything from the last few days.
>
>
> On Thursday, 23 August 2012 10:30:20 UTC+10, Massimo Di Pierro wrote:
>>
>> works with current trunk:
>>
>> $ python web2py.py -S welcome -M -N
>> >>> db['auth_user']
>> 
>>
>>
>> On Wednesday, 22 August 2012 19:07:13 UTC-5, Simon Ashley wrote:
>>>
>>> It helps, but it seems like a change in trunk causes the error. 
>>> Have rolled back to an earlier version 7/21 version
>>>
>>> On Wednesday, 22 August 2012 22:07:43 UTC+10, villas wrote:

 With regards the grid,  this parameter may help:  
 user_signature=False


 On Wednesday, August 22, 2012 8:00:25 AM UTC+1, Simon Ashley wrote:
>
> Getting the following error on the latest nightly build. (have just 
> downloaded again to make sure). Is this related? 
>
> TRACEBACK
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
> 10.
> 11.
> 12.
>
> Traceback (most recent call last):
>   File "c:\web2py4\gluon\restricted.py", line 205, in restricted
> exec ccode in environment
>   File "c:/web2py4/applications/crm05/controllers/lookup.py" 
> , 
> line 68, in 
>   File "c:\web2py4\gluon\globals.py", line 182, in 
> self._caller = lambda f: f()
>   File "c:/web2py4/applications/crm05/controllers/lookup.py" 
> , 
> line 4, in Jockey
> grid=SQLFORM.grid(query, paginate=10 )
>   File "c:\web2py4\gluon\sqlhtml.py", line 1633, in grid
> (not auth.user and \
> NameError: global name 'auth' is not defined
>
>
>
>
>

-- 





  1   2   >