Re: [web2py] pre selected checkboxes

2012-07-11 Thread Fabiano Faver
the field is shown if I dont declare the type, however the checks are not 
checked with default=True, like I wrote

Em quarta-feira, 11 de julho de 2012 07h35min46s UTC-3, villas escreveu:
>
> Don't you need a list field type for 'usuarios'?
>
>
> On Tuesday, July 10, 2012 9:49:40 PM UTC+1, Fabiano Faver wrote:
>>
>> controller:
>>
>> def gerenciar_grupos():
>>
>> form_not_usu = SQLFORM.factory(
>> Field('usuarios', requires=IS_IN_DB(db, 
>> db.auth_user,'%(email)s',multiple=True),widget=SQLFORM.widgets.checkboxes.widget,
>>  
>> default=True),
>> )
>> return dict(  form_not_usu = form_not_usu)
>>
>>
>>
>> view:
>>
>> {{extend 'layout.html'}}
>> {{=form_not_usu.custom.begin}}
>>
>> 
>> {{for x in form_not_usu.custom.widget.usuarios:}}
>> {{=LI(x)}}
>>
>> {{pass}}
>> 
>>
>> {{=form_not_usu.custom.submit}}
>> {{=form_not_usu.custom.end}}
>>
>>
>>
>> Checkboxes are not checked when accessing the page.
>>
>> Em terça-feira, 10 de julho de 2012 16h46min48s UTC-3, Richard escreveu:
>>>
>>> in your model Field(..., default=True) or in the controller 
>>> db.table.field.default=True
>>>
>>> You also need to use checkbox widget.
>>>
>>> Richard
>>>
>>> On Tue, Jul 10, 2012 at 2:39 PM, Fabiano Faver  wrote:
>>>
 I want to creat something similar to SQLFORM(auth_membership) but I 
 want the user to choose a group and all users show up as checkboxes and 
 users who already belong to this group are checked as well.

 I`m downt know how to pre-select these auth_users.

 any tips?

>>>
>>>

[web2py] Form Dropbox dependant on other dropbox (field) (Validation Dependencies, ...)

2012-07-11 Thread SeamusSeamus
I am trying to create a form to input data for a particular item. For 
example, I would like to store the item's location, area, and owner. 
 An example is I have an owner, an area (Items location), and the item. 
When I go to input a new "item", I need to select the "owner", then the 
dropbox below it needs to show me a list of all the "areas" the "owner" 
has. For example, If Bob (the owner), has 3 locations, his 3 locations 
would show up, but not pauls location (Another owner.) This allows me to 
sort data and areas by owner. It allows me to enter data by owner. It 
allows me to enter areas for owner. The owner would be akin to their 
address(es). When I go to the 'add_area' page, it shows a drop box of all 
of the owners, but when I go to the 'add_item' page, it only shows me the 
owner dropbox, and not the area options.



In Model:

db.define_table('owner',
Field('name'),
Field('notes')
)

db.define_table('area',
Field('owner', db.owner),
Field('name'),
Field('note', 'text'))

db.define_table('item',
Field('owner', db.owner),
Field('area_id', db.area),
Field('date', 'date'),
Field('note'),
Field('picture', 'upload', default=''),
Field('flag', 'boolean', default='False'))

In Controller:
def add_owner():
form = SQLFORM(db.owner)
if form.process().accepted:
response.flash = 'New Owner Entered'
return dict(form=form)

def add_area():
form = SQLFORM.factory(
Field('building_id', requires=IS_IN_DB(db, db.owner.name, 
'%(name)s')),
Field('area', 'string'),
Field('note', 'text'))


if form.process().accepted:
response.flash = 'New Area Added'
return dict(form=form)

def add_item():
form = SQLFORM.factory(
Field('owner_id', requires=IS_IN_DB(db, db.building.name, 
'%(name)s')),
Field('area_id', requires=IS_IN_DB(db, db.area.name, '%(name)s')),
Field('date', 'date'),
Field('picture', 'upload', default=''),
Field('note', 'text'),
Field('flag', 'boolean')
)


Re: [web2py] Re: Website/Sqlite Backup

2012-07-11 Thread villas
Thanks guys!  I didn't even know there was a backup command.  That, with 
the dropbox, sounds perfect.  Hope it all works with cron,  I have to 
investigate.  
Best wishes,  David

On Wednesday, July 11, 2012 3:47:17 PM UTC+1, Jonathan Lundell wrote:
>
> On 11 Jul 2012, at 7:25 AM, Massimo Di Pierro wrote:
>
> If you pay the $100, dropbox has a 6month restore. I do not know if it 
> will save all the versions of the file, or only some snapshot.
>
>
> I wouldn't count on dropbox to safely back up a live sqlite database, for 
> the same reason you can't simply copy the file: you might get the database 
> in an inconsistent state. Use the sqlite3 .backup command instead to take a 
> snapshot. Send its output to a dropbox folder if you like.
>
>
> On Wednesday, 11 July 2012 03:16:29 UTC-5, villas wrote:
>>
>> Hi All,
>> I'm looking for any easy way to backup small websites which use Sqlite.  
>> I found an interesting suggestion from Massimo:
>>
>> >> Put web2py in a dropbox folder! Once a day hg commit the entire folder.
>>  
>>
>> That sounds good,  but would it make a safe copy of the data?  
>>
>> In any case, does anyone have other ideas?
>>
>> Regards, David
>
>
>
>

[web2py] Re: template.render() and whitespace [patch attached]

2012-07-11 Thread Rob
Thanks Massimo.

That prints out:
   hihihi


If you change it to:
 {{for d in data[:3]:
   = "hi\n" 
   pass}} 

It prints out (spacing gets messed up):
   hi
hi
hi

Anyway, you probably aren't interested in a patch (see attached), but this 
patch has been working pretty good for me when using my original syntax. 
 Although, I don't know if there are any unforeseen consequences since I'm 
not using the templating engine to it's full potential right now.

Thanks,
Rob

On Tuesday, July 10, 2012 8:07:16 PM UTC-7, Massimo Di Pierro wrote:
>
> You can do
>
>  {{for d in data[:3]:
>= "hi" 
>pass}}
>
> to achieve when you want.
>
> On Tuesday, 10 July 2012 16:08:40 UTC-5, Rob wrote:
>>
>> Hi,
>>
>> I'm using the standalone template.py to generate non html files and the 
>> excess whitespace is making this somewhat painful.
>>
>> For example, my view:
>> #ifndef __BLAH__
>> #define __BLAH__
>> {{for d in data[:3]:}}
>>   {{= "hi"}} 
>> {{pass}}
>> #endif
>>
>> outputs:
>> #ifndef __BLAH__
>> #define __BLAH__
>> 
>>   hi 
>> 
>>   hi 
>> 
>>   hi 
>> 
>> #endif
>>
>> I'm sure there are lots of reasons why this can't happen, but I propose 
>> that render() simply removes lines that contain nothing but whitespace and 
>> logic. For example, given the same view:
>> 1 #ifndef __BLAH__
>> 2 #define __BLAH__
>> 3 {{for d in data[:3]:}}
>> 4   {{= "hi"}} 
>> 5 {{pass}}
>> 6 #endif 
>>
>> Line number 3 and 6 contain nothing but template logic and whitespace 
>> (with excess carriage returns).  Is there a reason why the rendering engine 
>> couldn't simply remove this whitespace from the output?  IE: if the line 
>> contains pure logic ({{...}}) and whitespace, just remove it.  If the line 
>> contains {{=..}} and other whitespace then it stays.
>>
>> Does this break all sorts of HTML output?
>>
>> Thanks,
>> Rob
>>
>--- template.orig.py	Wed Jul 11 11:16:57 2012
+++ template.py	Wed Jul 11 11:27:33 2012
@@ -234,6 +234,7 @@
 
 default_delimiters = ('{{','}}')
 r_tag = re.compile(r'(\{\{.*?\}\})', re.DOTALL)
+r_whitespace_cleanup = re.compile(r'^\s*(\{\{[^=].*?\}\})\s*\n', re.MULTILINE)
 
 r_multiline = re.compile(r'(""".*?""")|(\'\'\'.*?\'\'\')', re.DOTALL)
 
@@ -546,6 +547,9 @@
 in_tag = False
 extend = None
 pre_extend = True
+
+# cleanup unwanted whitespace around template logic
+text = re.sub(self.r_whitespace_cleanup, "\g<1>", text)
 
 # Use a list to store everything in
 # This is because later the code will "look ahead"


Re: [web2py] Re: Profile link

2012-07-11 Thread Kevin Miller
Perfect. Thank you very much. I wanted a custom view. I choose the latter
approach and it worked like a charm. I didn't realize it was that easy.
Thanks again.


On Wed, Jul 11, 2012 at 11:52 AM, Anthony  wrote:

> Just to clarify, are you saying your profile page has a custom URL (i.e.,
> something other than /default/user/profile), or that it simply has a custom
> view (i.e., you need to use a view other than the standard
> /views/default/user.html view)? If the latter, there are two options.
> First, rather than having a separate view file, you could add a condition
> to the user.html view that displays a custom view when request.args(0) ==
> 'profile'. The other option is specifying a custom view in the user()
> function:
>
> def user():
> if request.args(0) == 'profile':
> response.view = 'default/profile.html'
>
> Anthony
>
> Thanks for the reply. That is my setup. The only edit I want is to change
>> the link on profile to point to my custom profile. Apart from that, I don't
>> want to edit any other function of the Auth system. Thanks. I kind a see
>> where it might be possible in gluon/tools.py, but I don't want to touch the
>> source code directly. I was hoping there was some settings I could alter.
>>
>> I also did not want to create a custom navbar. However manipulating it
>> after it is generated seems an option. How do you do that to change the
>> link on the profile?
>>
>> Thanks.
>>
>> On Wed, Jul 11, 2012 at 10:31 AM, Anthony wrote:
>>
>> The navbar assumes all the Auth actions are handled by the same function,
>>> with the action being specified via request.args[0]. If that's not your
>>> setup, then you'll have to create a custom navbar, or manipulate the navbar
>>> after it is generated.
>>>
>>> Anthony
>>>
>>>
>>> On Wednesday, July 11, 2012 11:15:21 AM UTC-4, dundee wrote:

 Hi all,

 I have created a custom view for profile. However, I don't know where
 to look to change the profile link (auth.navbar) to use my link.

 Thanks.

>>>
>>
>>
>>


Re: [web2py] Multiple select Web2py

2012-07-11 Thread Richard Vézina
That's what I think maybe something broken temporarily.

Richard

On Tue, Jul 10, 2012 at 9:21 PM, Kevin Miller wrote:

> I am using the Nightly Build as I need twitter bootstrap :-)
>
>
> On Tue, Jul 10, 2012 at 11:41 AM, Richard Vézina <
> ml.richard.vez...@gmail.com> wrote:
>
>> Ok, so must be a issue with web2py... Which version are you using?
>>
>> Maybe open issue on google code.
>>
>> Richard
>>
>>
>> On Tue, Jul 10, 2012 at 11:48 AM, Kevin Miller wrote:
>>
>>> Thanks for your reply. The form is auto generated by web2py. It is the
>>> profile link you click on when you log in the system.
>>>
>>>
>>> On Tue, Jul 10, 2012 at 8:25 AM, Richard Vézina <
>>> ml.richard.vez...@gmail.com> wrote:
>>>
 Would need to see the model and your controller function that create
 the form...

 Richard


 On Tue, Jul 10, 2012 at 12:50 AM, Kevin Miller 
 wrote:

> Hi all,
>
> I have a multiple select that I attach to a  auth user profile.
> However, after I save the profile and log back in, I don't see the
> selected values when I am editing the profile form.
>
> Any ideas.
>
> Thank you all very much.
>


>>>
>>>
>>> --
>>> Kevin Miller
>>> Acting Data Controller
>>> Department of Computing
>>> UWI, Mona
>>> Kingston 7
>>>
>>
>>
>
>
> --
> Kevin Miller
> Acting Data Controller
> Department of Computing
> UWI, Mona
> Kingston 7
>


[web2py] Re: Asyncronous Application Sync

2012-07-11 Thread Niphlod
I don't think there is something already written, however we could use some 
more info about it
- how many data are we talking about ?
- what does it mean "as soon as there is availability of connectivity" ?

Given that, the approximate design for this kind of things is some form of 
interoperability (i.e. xmlrpc or jsonrpc) on the "city" location, that 
receive "records" uniquely identifiable (e.g. with uuids assigned), then 
db.table.update_or_insert(uuid==record.uuid, **record). At the end of the 
process (i.e. "jungle" sends 50 records at a time, "city" update_or_insert 
all of them in a transaction), "city" replies with some message meaning 
"ok, processed".
At this point "jungle" knows that the batch is "committed" on "city", so 
"marks" in some way the records just sent as "already transmitted", selects 
the next batch and prepare data to be sent. 
If you have a solid model (i.e. a unique record and a "transmitted" boolean 
for every record you must sync), "jungle" can use web2py's scheduler: every 
n seconds tries to connect to the "city" endpoint, if "city" is available 
--> data is transmitted, if "city" is unavailable (probably raising an 
urllib error) --> waits n seconds and retry.

NB: jsonrpc saves some kb, xmlrpc is more verbose and needs more "space" to 
serialize the same record.

NB2: if data is several megabytes and perhaps serializing to csv and 
zipping or gzipping it result in a serious compression percentage, then you 
can replace jsonrpc with:
-  "jungle" dumps the data to csv and transmit it zipped
- "city" receive zipped data, decompress to csv and loads data. You can use 
then db.table.import_from_csv_file that handles the "update_or_insert" 
automatically, as stated in the book 
http://web2py.com/books/default/chapter/29/6#CSV-%28one-Table-at-a-time%29
"""
If a table contains a field called "uuid", this field will be used to 
identify duplicates. Also, if an imported record has the same "uuid" as an 
existing record, the previous record will be updated.
"""

Summary: if frequent updates (like 50 updates in a minute) are needed, then 
a message queue like rabbitmq is probably the best choice ("high 
availability"). Given that the connectivity is "random", I guess the "city" 
app (and users) already "knows" that "jungle" can be disconnected for some 
time. If the underlying model of "jungle" and "city" can easily identify a) 
what data is already synced b) a way to identify unique records, you're 
probably "overcomplicating" a relatively simple issue to fix. 
If "city" is online, it will "reply" to "jungle" as soon as possible (i.e. 
when "jungle" can reach "city"). You just have to write a small function 
for "jungle" that identifies what records are going to be sent and a small 
function on city that acknowledges the received data. Then cron or 
scheduler will do the work for you (polling at specified intervals for 
"city" availability and sending data from "jungle" to "city") 


On Wednesday, July 11, 2012 7:06:23 PM UTC+2, Alfonso wrote:
>
> Hi, 
>
>
> I have a web2py app in 2 places: 
> - City location 
> - Rainforest location 
>
> The app is the same for both cases, however the city app is the "main". 
>
> I need to synchronize the information entered in the location of the 
> jungle to the city but not bi-directionally due to low bandwidth, in 
> addition should be automatic as soon as there is availability of 
> connectivity (ie queue management / messaging). 
>
> Has anyone had experiences like this with web2py specifically? ( I can 
> surely work with rabbitmq, hornetmq, etc. but there is an approach for 
> web2py?) 
>
>
> Saludos, 
>
>  
> Alfonso de la Guarda 
> Twitter: @alfonsodg 
> Redes sociales: alfonsodg 
>Telef. 991935157 
> 1024D/B23B24A4 
> 5469 ED92 75A3 BBDB FD6B  58A5 54A1 851D B23B 24A4 
>


Re: [web2py] pre selected checkboxes

2012-07-11 Thread Richard Vézina
Fabiano,

I think there is an issue with widget=SQLFORM.widgets.checkboxes.widget do
you use it?

I try without widget=SQLFORM.widgets.checkboxes.widget and I can set
default=True and I get a checked box, but if I use it the box doesn't get
checked.

If you don't need the fancy feature of widget (I think that it is mostly to
have many checkboxes for the same field and specify labels for those
multiple checkboxes) avoid using it could solve your issue.

I will investigate further why and how SQLFORM.widgets.checkboxes.widget
could be broken.

Richard

On Wed, Jul 11, 2012 at 1:50 PM, Fabiano Faver  wrote:

> the field is shown if I dont declare the type, however the checks are not
> checked with default=True, like I wrote
>
> Em quarta-feira, 11 de julho de 2012 07h35min46s UTC-3, villas escreveu:
>
>> Don't you need a list field type for 'usuarios'?
>>
>>
>> On Tuesday, July 10, 2012 9:49:40 PM UTC+1, Fabiano Faver wrote:
>>>
>>> controller:
>>>
>>> def gerenciar_grupos():
>>>
>>> form_not_usu = SQLFORM.factory(
>>> Field('usuarios', requires=IS_IN_DB(db, db.auth_user,'%(email)s',**
>>> multiple=True),widget=SQLFORM.**widgets.checkboxes.widget,
>>> default=True),
>>> )
>>> return dict(  form_not_usu = form_not_usu)
>>>
>>>
>>>
>>> view:
>>>
>>> {{extend 'layout.html'}}
>>> {{=form_not_usu.custom.begin}}
>>>
>>> 
>>> {{for x in form_not_usu.custom.widget.**usuarios:}}
>>> {{=LI(x)}}
>>>
>>> {{pass}}
>>> 
>>>
>>> {{=form_not_usu.custom.submit}**}
>>> {{=form_not_usu.custom.end}}
>>>
>>>
>>>
>>> Checkboxes are not checked when accessing the page.
>>>
>>> Em terça-feira, 10 de julho de 2012 16h46min48s UTC-3, Richard escreveu:

 in your model Field(..., default=True) or in the controller
 db.table.field.default=True

 You also need to use checkbox widget.

 Richard

 On Tue, Jul 10, 2012 at 2:39 PM, Fabiano Faver wrote:

> I want to creat something similar to SQLFORM(auth_membership) but I
> want the user to choose a group and all users show up as checkboxes and
> users who already belong to this group are checked as well.
>
> I`m downt know how to pre-select these auth_users.
>
> any tips?
>




Re: [web2py] pre selected checkboxes

2012-07-11 Thread Richard Vézina
Ok Fabiano, no issue with SQLFORM.widgets.checkboxes.widget...

I didn't know exactly how it works :)

In this thread look for Bruno's answers that how I figure out how to pass
the proper default to widget :
https://groups.google.com/forum/?fromgroups#!searchin/web2py/%5Bweb2py%5D$20requires$20and$20T()/web2py/f60S4rwwHnY/w8w4hPMYMigJ

Basically, since there is multiple checkboxes you need to define a
IS_IN_SET requires with your options set (your check boxes) and then you
can define a default by passing to default the label of what you use as
label for the differents checkboxe in your defined set.

Here a example :

form = SQLFORM.factory(
Field('test', type='boolean', requires=IS_IN_SET([1,2,3],
multiple=True), widget=SQLFORM.widgets.checkboxes.widget, default = 3),

I pass to default "3" since that the box that I want to be ckecked by
default.

In order to pass more then one choice you just pass a list to default like
this :

form = SQLFORM.factory(
Field('test', type='boolean', requires=IS_IN_SET([1,2,3],
multiple=True), widget=SQLFORM.widgets.checkboxes.widget, default = [2,3]),
formstyle='divs'
)

Hope it helps...

I appreciate answer your question since it helps me understand something I
will have to cover in the coming days for a particular form.

Ciao!

Richard

On Wed, Jul 11, 2012 at 3:52 PM, Richard Vézina  wrote:

> Fabiano,
>
> I think there is an issue with widget=SQLFORM.widgets.checkboxes.widget do
> you use it?
>
> I try without widget=SQLFORM.widgets.checkboxes.widget and I can set
> default=True and I get a checked box, but if I use it the box doesn't get
> checked.
>
> If you don't need the fancy feature of widget (I think that it is mostly
> to have many checkboxes for the same field and specify labels for those
> multiple checkboxes) avoid using it could solve your issue.
>
> I will investigate further why and how SQLFORM.widgets.checkboxes.widget
> could be broken.
>
> Richard
>
>
> On Wed, Jul 11, 2012 at 1:50 PM, Fabiano Faver  wrote:
>
>> the field is shown if I dont declare the type, however the checks are not
>> checked with default=True, like I wrote
>>
>> Em quarta-feira, 11 de julho de 2012 07h35min46s UTC-3, villas escreveu:
>>
>>> Don't you need a list field type for 'usuarios'?
>>>
>>>
>>> On Tuesday, July 10, 2012 9:49:40 PM UTC+1, Fabiano Faver wrote:

 controller:

 def gerenciar_grupos():

 form_not_usu = SQLFORM.factory(
 Field('usuarios', requires=IS_IN_DB(db, db.auth_user,'%(email)s',**
 multiple=True),widget=SQLFORM.**widgets.checkboxes.widget,
 default=True),
 )
 return dict(  form_not_usu = form_not_usu)



 view:

 {{extend 'layout.html'}}
 {{=form_not_usu.custom.begin}}

 
 {{for x in form_not_usu.custom.widget.**usuarios:}}
 {{=LI(x)}}

 {{pass}}
 

 {{=form_not_usu.custom.submit}**}
 {{=form_not_usu.custom.end}}



 Checkboxes are not checked when accessing the page.

 Em terça-feira, 10 de julho de 2012 16h46min48s UTC-3, Richard escreveu:
>
> in your model Field(..., default=True) or in the controller
> db.table.field.default=True
>
> You also need to use checkbox widget.
>
> Richard
>
> On Tue, Jul 10, 2012 at 2:39 PM, Fabiano Faver wrote:
>
>> I want to creat something similar to SQLFORM(auth_membership) but I
>> want the user to choose a group and all users show up as checkboxes and
>> users who already belong to this group are checked as well.
>>
>> I`m downt know how to pre-select these auth_users.
>>
>> any tips?
>>
>
>
>


[web2py] Re: Form Dropbox dependant on other dropbox (field) (Validation Dependencies, ...)

2012-07-11 Thread Anthony
http://stackoverflow.com/questions/8146260/best-practice-for-populating-dropdown-based-on-other-dropdown-selection-in-web2p/8152910#8152910

On Wednesday, July 11, 2012 2:22:58 PM UTC-4, SeamusSeamus wrote:
>
> I am trying to create a form to input data for a particular item. For 
> example, I would like to store the item's location, area, and owner. 
>  An example is I have an owner, an area (Items location), and the item. 
> When I go to input a new "item", I need to select the "owner", then the 
> dropbox below it needs to show me a list of all the "areas" the "owner" 
> has. For example, If Bob (the owner), has 3 locations, his 3 locations 
> would show up, but not pauls location (Another owner.) This allows me to 
> sort data and areas by owner. It allows me to enter data by owner. It 
> allows me to enter areas for owner. The owner would be akin to their 
> address(es). When I go to the 'add_area' page, it shows a drop box of all 
> of the owners, but when I go to the 'add_item' page, it only shows me the 
> owner dropbox, and not the area options.
>
>
>
> In Model:
>
> db.define_table('owner',
> Field('name'),
> Field('notes')
> )
> 
> db.define_table('area',
> Field('owner', db.owner),
> Field('name'),
> Field('note', 'text'))
>
> db.define_table('item',
> Field('owner', db.owner),
> Field('area_id', db.area),
> Field('date', 'date'),
> Field('note'),
> Field('picture', 'upload', default=''),
> Field('flag', 'boolean', default='False'))
>
> In Controller:
> def add_owner():
> form = SQLFORM(db.owner)
> if form.process().accepted:
> response.flash = 'New Owner Entered'
> return dict(form=form)
>
> def add_area():
> form = SQLFORM.factory(
> Field('building_id', requires=IS_IN_DB(db, db.owner.name, 
> '%(name)s')),
> Field('area', 'string'),
> Field('note', 'text'))
>
> 
> if form.process().accepted:
> response.flash = 'New Area Added'
> return dict(form=form)
> 
> def add_item():
> form = SQLFORM.factory(
> Field('owner_id', requires=IS_IN_DB(db, db.building.name, 
> '%(name)s')),
> Field('area_id', requires=IS_IN_DB(db, db.area.name, '%(name)s')),
> Field('date', 'date'),
> Field('picture', 'upload', default=''),
> Field('note', 'text'),
> Field('flag', 'boolean')
> )
>


Re: [web2py] Any jquery gurus out there?

2012-07-11 Thread RKS

>
> What is it that isn't working in IE?
>

I'm fairly certain the hash part just bunks it up but I have no way of 
confirming it. I've tried all the debugging tools I could find and either 
I'm too stupid to figure out how to get them to work or I'm too stupid to 
figure out what step I'm missing in the debugging process.

 

> Have you checked the Javascript console?


Yes. I've even followed similar tutorials as you've posted but no matter 
what I try everything remains greyed out. There is never an option to 
execute even after inserting breakpoints and trying to run. jsfiddle is 
completely inept when it comes to viewing the site in IE<9 so that's 
useless too. 


Re: [web2py] Re: postgres connect problem

2012-07-11 Thread lucas
hey wade,

yes, i have been banging my head on this one because i have had success 
with web2py and postgresql for quite a while.  my admin interface says that 
my "web2py is up to date" and that is currently on version 1.99.7.  so what 
is the best method toi update my web2py?  i am using centos 6.2 and the 
"web2py_install" script found at:

http://www.web2pyslices.com/slice/show/1423/deploy-web2py-on-fedoracentosred-hat

lucas


Re: [web2py] Re: postgres connect problem

2012-07-11 Thread Cliff Kachinske
+1 for psycopg2.  Works fine for me.

I missed that you weren't using it.



On Wednesday, July 11, 2012 4:40:56 PM UTC-4, lucas wrote:
>
> hey wade,
>
> yes, i have been banging my head on this one because i have had success 
> with web2py and postgresql for quite a while.  my admin interface says that 
> my "web2py is up to date" and that is currently on version 1.99.7.  so what 
> is the best method toi update my web2py?  i am using centos 6.2 and the 
> "web2py_install" script found at:
>
>
> http://www.web2pyslices.com/slice/show/1423/deploy-web2py-on-fedoracentosred-hat
>
> lucas
>


Re: [web2py] Re: postgres connect problem

2012-07-11 Thread Bruce Wade
Until trunk is stable I suggest you just install psycopg2 and use that.
Once you install the python driver everything will just work without any
change to your code.

On Wed, Jul 11, 2012 at 1:45 PM, Cliff Kachinske  wrote:

> +1 for psycopg2.  Works fine for me.
>
> I missed that you weren't using it.
>
>
>
> On Wednesday, July 11, 2012 4:40:56 PM UTC-4, lucas wrote:
>>
>> hey wade,
>>
>> yes, i have been banging my head on this one because i have had success
>> with web2py and postgresql for quite a while.  my admin interface says that
>> my "web2py is up to date" and that is currently on version 1.99.7.  so what
>> is the best method toi update my web2py?  i am using centos 6.2 and the
>> "web2py_install" script found at:
>>
>> http://www.web2pyslices.com/**slice/show/1423/deploy-web2py-**
>> on-fedoracentosred-hat
>>
>> lucas
>>
>


-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.fittraineronline.com - Fitness Personal Trainers Online
http://www.warplydesigned.com


[web2py] Re: Routing help

2012-07-11 Thread Janath
Hi, 
I am trying to make the home page of the  
http://111.111.111.11:8000/welcome/default/index
  
which is the default page loaded when I type   
http://111.111.111.11:8000, 
to  
*http://111.111.111.11:8000
:pythonPsse/defult/index.html*

having read the above articles, I created routes.py and router.py in the 
base web2py folder.

and made following changes to each file:

routes.py

default_application = 'PythonPSSE'# ordinarily set in base routes.py
default_controller = 'default'  # ordinarily set in app-specific routes.py
default_function = 'index'  # ordinarily set in app-specific routes.py

router.py

routers = dict(
BASE = dict(
default_application = 'PythonPSSE',
default_controller = 'default',
default_function = 'index',
),
)

however, it has no effect on the web2py behaviour, pages are downloaded as 
they were.

I am sorry about raising this issue again. 

Thank yoy,

Janath








On Friday, May 18, 2012 1:19:03 PM UTC-5, Alexander McLin wrote:
>
> Sorry I posted too early,
>
> My solution is:
>
> in routes.py in the base folder, where myapp is the actual name of the 
> application I'm developing.
>
> routes_app = ((r'/(?Pwelcome|admin|myapp)\b.*', r'\g'),)
>
> and in myapp's folder, I have another routes.py with the following,
>
> routes_in = ((r'/myapp/users/(?P\d*)', r'/myapp/users/index/\g'),)
>
> routes_out = 
> ((r'/myapp/users/index/(?P\d*)', r'/myapp/users/\g'),')
>
> This is what worked for me. 
>
>
> Alex
>
>
> On Friday, May 18, 2012 2:11:28 PM UTC-4, Alexander McLin wrote:
>>
>> Sorry if I wasn't clear, I actually meant URLs of the following form, 
>> myapp/controller/args to be mapped to myapp/controller/index/args. The 
>> second point of confusion takes a different tack on web2py routing than the 
>> first point.
>>
>> I'll try to experiment with your solution though.
>>
>> For future notes, I actually got the pattern-matching solution working, I 
>> realized that what I was missing was that I had to include my application's 
>> name in the routes_app for the custom routes to be enabled.
>>
>> In any event, my solution is
>>
>> On Friday, May 18, 2012 9:17:30 AM UTC-4, Wikus van de Merwe wrote:
>>>
>>> OK, so you want /myapp/args to be mapped to 
>>> /myapp/default_controller/default_function/args. By default args would be 
>>> interpreted as a function name and will be mapped to 
>>> /myapp/default_controller/args. To change that you need to define a list of 
>>> functions for the default controller. Then if args is not in that list it 
>>> would be mapped to /myapp/default_controller/default_function/args.
>>>
>>> routers = dict( 
>>> myapp = dict(
>>> default_controller = "default",
>>> default_function = "index",
>>> functions = ["fun1", "fun2", "fun3"]
>>> )
>>> )
>>>
>>>

[web2py] Re: Any jquery gurus out there?

2012-07-11 Thread Cliff Kachinske
Not a jquery guru...

What would happen if you changed the anchor tags to spans?  If it works it 
will also allow you to remove the "event.preventDefault()" call.

Also I would change this line of code:

$("a.reveal").click(function (event) {

to this:
   
$(".reveal").live('click', function(event){


The "live" method allows for repeated clicks on the identifier.  In the 
past, click methods are exhausted after they have fired one time.  I don't 
think this is caused by a peculiarity in my own code, though it is possible.

Anyway, good luck.

On Tuesday, July 10, 2012 6:54:14 PM UTC-4, RKS wrote:
>
> I know this is probably not the right place to ask, but I am using w2p and 
> post here pretty frequently so I figured what the heck. I'm also in a rush 
> and not finding out what I need on stackoverflow.
>
> I have some jquery and it works in every browser except any version of IE. 
> If you happen to notice anything right off the bat that will cause this not 
> to work, please let me know. I'm desperate. Thanks.
>
> https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
> ">
> 
> $(function () {
> // hide all the steps on document load
> $("div.step").addClass("hidden");
> // show the one step that is identified by the current hash 
> (if any)
> $(document.location.hash).removeClass("hidden");
> $("a.reveal").click(function (event) {
> var idToReveal = $(this).attr("href");
> // store the ID to show in the URL for bookmarking
> document.location.hash = idToReveal;
> // hide every step that is currently visible
> $("div.step").not(".hidden").addClass("hidden");
> // reveal the next div (as identified by the current 
> link's href)
> $(idToReveal).removeClass("hidden");
> // prevent the default click behavior (i.e. prevent 
> navigation)
> event.preventDefault();
> });
> });
> 
>
> Quick recap, this hides divs and shows them via anchors on the page. It 
> also saves the hash so on reload it opens to the current hash instead of 
> going back to 1. Thanks
>


[web2py] Re: Routing help

2012-07-11 Thread Anthony
web2py does not use a file called "router.py". All rewrite code goes in 
routes.py. You can use either the parameter-based system (router.example.py 
is an example) *or* the pattern-based system (routes.example.py is an 
example), but not both.

Anthony

On Wednesday, July 11, 2012 4:49:33 PM UTC-4, Janath wrote:
>
> Hi, 
> I am trying to make the home page of the  
> http://111.111.111.11:8000/welcome/default/index
>   
> which is the default page loaded when I type   
> http://111.111.111.11:8000, 
> to  
> *http://111.111.111.11:8000
> :pythonPsse/defult/index.html*
>
> having read the above articles, I created routes.py and router.py in the 
> base web2py folder.
>
> and made following changes to each file:
>
> routes.py
>
> default_application = 'PythonPSSE'# ordinarily set in base routes.py
> default_controller = 'default'  # ordinarily set in app-specific routes.py
> default_function = 'index'  # ordinarily set in app-specific routes.py
>
> router.py
>
> routers = dict(
> BASE = dict(
> default_application = 'PythonPSSE',
> default_controller = 'default',
> default_function = 'index',
> ),
> )
>
> however, it has no effect on the web2py behaviour, pages are downloaded as 
> they were.
>
> I am sorry about raising this issue again. 
>
> Thank yoy,
>
> Janath
>
>
>
>
>
>
>
>
> On Friday, May 18, 2012 1:19:03 PM UTC-5, Alexander McLin wrote:
>>
>> Sorry I posted too early,
>>
>> My solution is:
>>
>> in routes.py in the base folder, where myapp is the actual name of the 
>> application I'm developing.
>>
>> routes_app = ((r'/(?Pwelcome|admin|myapp)\b.*', r'\g'),)
>>
>> and in myapp's folder, I have another routes.py with the following,
>>
>> routes_in = ((r'/myapp/users/(?P\d*)', r'/myapp/users/index/\g'),)
>>
>> routes_out = 
>> ((r'/myapp/users/index/(?P\d*)', r'/myapp/users/\g'),')
>>
>> This is what worked for me. 
>>
>>
>> Alex
>>
>>
>> On Friday, May 18, 2012 2:11:28 PM UTC-4, Alexander McLin wrote:
>>>
>>> Sorry if I wasn't clear, I actually meant URLs of the following form, 
>>> myapp/controller/args to be mapped to myapp/controller/index/args. The 
>>> second point of confusion takes a different tack on web2py routing than the 
>>> first point.
>>>
>>> I'll try to experiment with your solution though.
>>>
>>> For future notes, I actually got the pattern-matching solution working, 
>>> I realized that what I was missing was that I had to include my 
>>> application's name in the routes_app for the custom routes to be enabled.
>>>
>>> In any event, my solution is
>>>
>>> On Friday, May 18, 2012 9:17:30 AM UTC-4, Wikus van de Merwe wrote:

 OK, so you want /myapp/args to be mapped to 
 /myapp/default_controller/default_function/args. By default args would be 
 interpreted as a function name and will be mapped to 
 /myapp/default_controller/args. To change that you need to define a list 
 of 
 functions for the default controller. Then if args is not in that list it 
 would be mapped to /myapp/default_controller/default_function/args.

 routers = dict( 
 myapp = dict(
 default_controller = "default",
 default_function = "index",
 functions = ["fun1", "fun2", "fun3"]
 )
 )



[web2py] Re: Routing help

2012-07-11 Thread Anthony
Note, when you create or change routes.py, you need to reload it before it 
will take effect (either restart the server or click the "Reload routes" 
button in the admin interface).

Anthony

On Wednesday, July 11, 2012 5:14:20 PM UTC-4, Anthony wrote:
>
> web2py does not use a file called "router.py". All rewrite code goes in 
> routes.py. You can use either the parameter-based system (
> router.example.py is an example) *or* the pattern-based system (
> routes.example.py is an example), but not both.
>
> Anthony
>
> On Wednesday, July 11, 2012 4:49:33 PM UTC-4, Janath wrote:
>>
>> Hi, 
>> I am trying to make the home page of the  
>> http://111.111.111.11:8000/welcome/default/index
>>   
>> which is the default page loaded when I type   
>> http://111.111.111.11:8000,
>>  
>> to  
>> *http://111.111.111.11:8000
>> :pythonPsse/defult/index.html*
>>
>> having read the above articles, I created routes.py and router.py in the 
>> base web2py folder.
>>
>> and made following changes to each file:
>>
>> routes.py
>>
>> default_application = 'PythonPSSE'# ordinarily set in base routes.py
>> default_controller = 'default'  # ordinarily set in app-specific routes.py
>> default_function = 'index'  # ordinarily set in app-specific routes.py
>>
>> router.py
>>
>> routers = dict(
>> BASE = dict(
>> default_application = 'PythonPSSE',
>> default_controller = 'default',
>> default_function = 'index',
>> ),
>> )
>>
>> however, it has no effect on the web2py behaviour, pages are downloaded 
>> as they were.
>>
>> I am sorry about raising this issue again. 
>>
>> Thank yoy,
>>
>> Janath
>>
>>
>>
>>
>>
>>
>>
>>
>> On Friday, May 18, 2012 1:19:03 PM UTC-5, Alexander McLin wrote:
>>>
>>> Sorry I posted too early,
>>>
>>> My solution is:
>>>
>>> in routes.py in the base folder, where myapp is the actual name of the 
>>> application I'm developing.
>>>
>>> routes_app = ((r'/(?Pwelcome|admin|myapp)\b.*', r'\g'),)
>>>
>>> and in myapp's folder, I have another routes.py with the following,
>>>
>>> routes_in = ((r'/myapp/users/(?P\d*)', 
>>> r'/myapp/users/index/\g'),)
>>>
>>> routes_out = 
>>> ((r'/myapp/users/index/(?P\d*)', r'/myapp/users/\g'),')
>>>
>>> This is what worked for me. 
>>>
>>>
>>> Alex
>>>
>>>
>>> On Friday, May 18, 2012 2:11:28 PM UTC-4, Alexander McLin wrote:

 Sorry if I wasn't clear, I actually meant URLs of the following form, 
 myapp/controller/args to be mapped to myapp/controller/index/args. The 
 second point of confusion takes a different tack on web2py routing than 
 the 
 first point.

 I'll try to experiment with your solution though.

 For future notes, I actually got the pattern-matching solution working, 
 I realized that what I was missing was that I had to include my 
 application's name in the routes_app for the custom routes to be enabled.

 In any event, my solution is

 On Friday, May 18, 2012 9:17:30 AM UTC-4, Wikus van de Merwe wrote:
>
> OK, so you want /myapp/args to be mapped to 
> /myapp/default_controller/default_function/args. By default args would be 
> interpreted as a function name and will be mapped to 
> /myapp/default_controller/args. To change that you need to define a list 
> of 
> functions for the default controller. Then if args is not in that list it 
> would be mapped to /myapp/default_controller/default_function/args.
>
> routers = dict( 
> myapp = dict(
> default_controller = "default",
> default_function = "index",
> functions = ["fun1", "fun2", "fun3"]
> )
> )
>
>

Re: [web2py] Re: postgres connect problem

2012-07-11 Thread lucas
ok, i installed the rpm version of psycopg2 and web2py recognizes it when i 
run "python web2py.py".  i then added a very simple application under the 
admin interface and added only:

db = DAL('postgres:psycopg2://postgres:password@localhost/testbank')

to the db.py file.  when i run the "database administration" button, i get 
the error:

Traceback (most recent call last):
  File "/opt/web-apps/web2py/gluon/dal.py", line 5955, in __init__
self._adapter = ADAPTERS[self._dbname](*args)
  File "/opt/web-apps/web2py/gluon/dal.py", line 2010, in __init__
self.pool_connection(connect)
  File "/opt/web-apps/web2py/gluon/dal.py", line 465, in pool_connection
self.connection = f()
  File "/opt/web-apps/web2py/gluon/dal.py", line 2009, in connect
return self.driver.connect(msg,**driver_args)
  File "/usr/lib64/python2.6/site-packages/psycopg2/__init__.py", line 179, in 
connect
connection_factory=connection_factory, async=async)
OperationalError: FATAL:  Ident authentication failed for user "postgres"


BUT, BUTTE, psql is totally working and accessing the postgresql service and 
testbank database for the "postgres" user with "trust" or "md5" set to the 
local under pg_hba.conf file and using the proper password.


also under python native:

import psycopg2
conn = psycopg2.connect('dbname=testbank user=postgres password=password')

works fine also with no issues and conn shows a proper connection object.  
so damn, even the psycopg2 driver is working either.

lucas


Re: [web2py] Re: postgres connect problem

2012-07-11 Thread Bruce Wade
First you don't need to write you connection string like this:
db = DAL('postgres:psycopg2://postgres:password@localhost/testbank')
You can use this:
db = DAL('postgres://postgres:password@localhost/testbank')

I always set pg_hba.conf (this is on my development box not my live server)
# Database administrative login by Unix domain socket
local   all postgrespeer

# TYPE  DATABASEUSERADDRESS METHOD

# "local" is for Unix domain socket connections only
local   all all peer
# IPv4 local connections:
hostall all 127.0.0.1/32md5
# IPv6 local connections:
hostall all ::1/128 md5

Besides that if your username and password is correct you shouldn't have
any problems.

On Wed, Jul 11, 2012 at 2:29 PM, lucas  wrote:

> ok, i installed the rpm version of psycopg2 and web2py recognizes it when
> i run "python web2py.py".  i then added a very simple application under the
> admin interface and added only:
>
> db = DAL('postgres:psycopg2://postgres:password@localhost/testbank')
>
> to the db.py file.  when i run the "database administration" button, i get
> the error:
>
> Traceback (most recent call last):
>   File "/opt/web-apps/web2py/gluon/dal.py", line 5955, in __init__
> self._adapter = ADAPTERS[self._dbname](*args
> )
>   File "/opt/web-apps/web2py/gluon/dal.py", line 2010, in __init__
> self.pool_connection(connect)
>   File "/opt/web-apps/web2py/gluon/dal.py", line 465, in pool_connection
> self.connection = f()
>   File "/opt/web-apps/web2py/gluon/dal.py", line 2009, in connect
> return self.driver.connect(msg,**driver_args)
>   File "/usr/lib64/python2.6/site-packages/psycopg2/__init__.py", line 179, 
> in connect
> connection_factory=connection_factory, async=async)
> OperationalError: FATAL:  Ident authentication failed for user "postgres"
>
>
> BUT, BUTTE, psql is totally working and accessing the postgresql service and
> testbank database for the "postgres" user with "trust" or "md5" set to the
> local under pg_hba.conf file and using the proper password.
>
>
> also under python native:
>
> import psycopg2
> conn = psycopg2.connect('dbname=testbank user=postgres password=password')
>
> works fine also with no issues and conn shows a proper connection object.
> so damn, even the psycopg2 driver is working either.
>
> lucas
>



-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.fittraineronline.com - Fitness Personal Trainers Online
http://www.warplydesigned.com


Re: [web2py] Getting drop-down value names from grandparent record

2012-07-11 Thread MichaelF
Problem solved. My mistake was in thinking that the 'r' in the lambda 
function referred to the C record. Of course it doesn't; we're trying to 
INSERT a new C record. Instead, that 'r' refers to the parent B record. So 
the lambda function should be:

lambda r : '%s' % (db.A[r.A_id].A_name) 

On Wednesday, July 11, 2012 9:54:24 AM UTC-6, MichaelF wrote:
>
> Okay; I understand. Let me explain using a simpler version, and also come 
> up with SQL that would do the equivalent.
>
> Here's a simpler version. This example shows the problem, and simply uses 
> a grandparent table (A), a parent table (B), and a child table (C). That 
> is, C is a child of B, and B is a child of A:
>
> db.define_table('A',
> Field('A_name', 'string', required=True),
> format='%(A_name)s')
>
> db.define_table('B',
> Field('A_id', db.A),
> Field('B_name', 'string', required=True),
> format='%(B_name)s')
>
> db.define_table('C',
> Field('B_id', db.B),
> Field('C_name', 'string', required=True),
> format='%(C_name)s')
> db.C.B_id.requires=IS_IN_DB(db, 'B.id',
>   lambda r : '%s' % (db.A[db.B[r.B_id].A_id].A_name)
>   )
>
> If I leave the lambda out, then the drop-down values are B.id values. I 
> can make that be B.B_name values easily, but what I want are A.A_name 
> values. The lambda is fairly straightforward (although I'm obviously 
> missing something).
>
>   lambda r : '%s' % (db.A[db.B[r.B_id].A_id].A_name)
>
> The 'r' is the current record, and we're looking at a C record, so it first 
> evaluates r.B_id, B_id being the foreign key in the C record of its 
> parent B record. Let's say this evaluates to 123 (for example), which would 
> then be id 123 in the B table. Now, replacing r.B_id with 123 we get:
>
>   lambda r : '%s' % (db.A[db.B[123].A_id].A_name)
>
> So now it evaluates db.B[123].A_id, A_id being the foreign key in the B 
> record of its parent A record:
>
>   lambda r : '%s' % (db.A[db.B[123].A_id].A_name)
>
> Let's say that evaluates to 456, which would then be id 456 in the A 
> table. Replacing db.B[123].A_id with 456 we get:
>
>   lambda r : '%s' % (db.A[456].A_name)
>
> So now it evaluates db.A[456].A_name, which is what I'd like to see in the 
> drop-down. And yet the error I get is:
>  'B_id'
>
> An equivalent SQL to get the A_name for each C id would be:
>
> SELECT C.id, A.A_name
> FROM A  INNER JOIN
>  B ON A.id = B.A_id INNER JOIN
>  C ON B.id = C.B_id;
>
> Thoughts?
>
> Thanks.
>
> On Wednesday, July 11, 2012 3:24:41 AM UTC-6, Johann Spies wrote:
>>
>> On 11 July 2012 05:27, MichaelF  wrote:
>>
>>> Didn't help. I now get the same error, this time in the function. Any 
>>> idea what the error message is trying to tell me?
>>
>>
>> Unfortunately I don't have time to try and work out your logic.  The 
>> error is telling you that the process could not find the key C1_2 in your 
>> database query.  You have some logical proglem in your code.
>>
>> Try and build an SQL-query to which you can translate into a function.
>>
>> Regards
>> Johann
>>  
>> -- 
>> Because experiencing your loyal love is better than life itself, 
>> my lips will praise you.  (Psalm 63:3)
>>
>>

[web2py] Web2py URL rewrite according to preferred language

2012-07-11 Thread Athelionas
Is it possible to rewrite a URL according to preferred language of browser? 
I mean if the browser's preferred language is, for example, English then 
rewrite example.com/app/controller/index to 
example.com/app/en/controller/index. In routes.py I could set up languages 
but if I set default_language then it overrides language preference and if 
I don't then the URL won't contain the language identifier.


[web2py] Re: template.render() and whitespace [patch attached]

2012-07-11 Thread Rob
Updated patch - I haven't been able to break it.  I'm posting this in case 
someone else finds it useful - it's a very small patch.

This basically looks for {{...}} and strips the white space around it (up 
to an including a new line) ignoring everything else.  The output from 
render() now looks just like the view code without a bunch of extra white 
space and carriage returns.

Thanks a lot for making this template library available to use outside of 
web2py!

On Wednesday, July 11, 2012 11:33:44 AM UTC-7, Rob wrote:
>
> Thanks Massimo.
>
> That prints out:
>hihihi
>
>
> If you change it to:
>  {{for d in data[:3]:
>= "hi\n" 
>pass}} 
>
> It prints out (spacing gets messed up):
>hi
> hi
> hi
>
> Anyway, you probably aren't interested in a patch (see attached), but this 
> patch has been working pretty good for me when using my original syntax. 
>  Although, I don't know if there are any unforeseen consequences since I'm 
> not using the templating engine to it's full potential right now.
>
> UPDATE: the attached patch matches template lines like{{for d in 
> data[:3]:}}{{foo = 5}}{{=foo}}   which it shouldn't (I think) and my regex 
> foo is weak :/
>
> Thanks,
> Rob
>
> On Tuesday, July 10, 2012 8:07:16 PM UTC-7, Massimo Di Pierro wrote:
>>
>> You can do
>>
>>  {{for d in data[:3]:
>>= "hi" 
>>pass}}
>>
>> to achieve when you want.
>>
>> On Tuesday, 10 July 2012 16:08:40 UTC-5, Rob wrote:
>>>
>>> Hi,
>>>
>>> I'm using the standalone template.py to generate non html files and the 
>>> excess whitespace is making this somewhat painful.
>>>
>>> For example, my view:
>>> #ifndef __BLAH__
>>> #define __BLAH__
>>> {{for d in data[:3]:}}
>>>   {{= "hi"}} 
>>> {{pass}}
>>> #endif
>>>
>>> outputs:
>>> #ifndef __BLAH__
>>> #define __BLAH__
>>> 
>>>   hi 
>>> 
>>>   hi 
>>> 
>>>   hi 
>>> 
>>> #endif
>>>
>>> I'm sure there are lots of reasons why this can't happen, but I propose 
>>> that render() simply removes lines that contain nothing but whitespace and 
>>> logic. For example, given the same view:
>>> 1 #ifndef __BLAH__
>>> 2 #define __BLAH__
>>> 3 {{for d in data[:3]:}}
>>> 4   {{= "hi"}} 
>>> 5 {{pass}}
>>> 6 #endif 
>>>
>>> Line number 3 and 6 contain nothing but template logic and whitespace 
>>> (with excess carriage returns).  Is there a reason why the rendering engine 
>>> couldn't simply remove this whitespace from the output?  IE: if the line 
>>> contains pure logic ({{...}}) and whitespace, just remove it.  If the line 
>>> contains {{=..}} and other whitespace then it stays.
>>>
>>> Does this break all sorts of HTML output?
>>>
>>> Thanks,
>>> Rob
>>>
>>--- template.orig.py	Wed Jul 11 11:16:57 2012
+++ template.py	Wed Jul 11 15:03:32 2012
@@ -234,6 +234,7 @@
 
 default_delimiters = ('{{','}}')
 r_tag = re.compile(r'(\{\{.*?\}\})', re.DOTALL)
+r_whitespace_cleanup = re.compile(r' *?(\{\{([^=])(.*?)\}\})[^\S\n]*\n*', re.MULTILINE)
 
 r_multiline = re.compile(r'(""".*?""")|(\'\'\'.*?\'\'\')', re.DOTALL)
 
@@ -546,6 +547,9 @@
 in_tag = False
 extend = None
 pre_extend = True
+
+# cleanup unwanted whitespace around template logic
+text = re.sub(self.r_whitespace_cleanup, "\g<1>", text)
 
 # Use a list to store everything in
 # This is because later the code will "look ahead"


[web2py] ldap login method bug - Allows any user to log in with blank password (AD)

2012-07-11 Thread Kory Prince
Hello all. Today I discovered that all my web2py installations are allowing 
any domain user to login as long as they don't enter a password. The root 
of this is that the ldap_auth.py authentication will return True as long as 
a user is in Active Directory. An incorrect password will not work, but a 
blank one will.

My setup is the latest stable web2py with ldap_auth.py from web2py trunk on 
github.

Can I get someone to test this and see if it is an issue for them? I will 
try and fix this tomorrow and submit a patch.

Thanks,
Kory


[web2py] Re: [web2py-dev] Asyncronous Application Sync

2012-07-11 Thread Massimo DiPierro
There are two issue: 1) protocol for transferring data; 2) exporting and 
importing from database.

rabbitmq etc. only address 1 and you do not need any. Web2py already has a web 
server a many RPC systems you can use.
The real issue is 2. If your tables have a uuid field, db.export_to_csv_field 
and db.import_from_csv_file should do what you ask.

I am planning to improve this functionality but it would help to know if it 
works for you as it is and what problems you encounter with it.



On Jul 11, 2012, at 12:06 PM, Alfonso de la Guarda wrote:

> Hi,
> 
> 
> I have a web2py app in 2 places:
> - City location
> - Rainforest location
> 
> The app is the same for both cases, however the city app is the "main".
> 
> I need to synchronize the information entered in the location of the
> jungle to the city but not bi-directionally due to low bandwidth, in
> addition should be automatic as soon as there is availability of
> connectivity (ie queue management / messaging).
> 
> Has anyone had experiences like this with web2py specifically? ( I can
> surely work with rabbitmq, hornetmq, etc. but there is an approach for
> web2py?)
> 
> 
> Saludos,
> 
> 
> Alfonso de la Guarda
> Twitter: @alfonsodg
> Redes sociales: alfonsodg
>   Telef. 991935157
> 1024D/B23B24A4
> 5469 ED92 75A3 BBDB FD6B  58A5 54A1 851D B23B 24A4
> 
> -- mail from:GoogleGroups "web2py-developers" mailing list
> make speech: web2py-develop...@googlegroups.com
> unsubscribe: web2py-developers+unsubscr...@googlegroups.com
> details: http://groups.google.com/group/web2py-developers
> the project: http://code.google.com/p/web2py/
> official: http://www.web2py.com/



[web2py] Re: ldap login method bug - Allows any user to log in with blank password (AD)

2012-07-11 Thread Kory Prince
I did some digging and turned up this:
http://docs.oracle.com/javase/jndi/tutorial/ldap/security/simple.html

Which says a blank password causes the protocol to be changed to "none."

More specifically http://tools.ietf.org/html/rfc4513#section-5.1.2 tells us
 "

Clients SHOULD
   disallow an empty password input to a Name/Password Authentication
   user interface."

Therefore I submit this patch that simply performs a check for a blank 
password. If you think there is a better way, please let me know, but I think 
it would be best to follow protocol.

Thanks,
Kory

# -*- coding: utf-8 -*-
#
# last tinkered with by korylprince at gmail.com on 2012-07-11
# 

import sys
import logging
try:
import ldap
import ldap.filter
ldap.set_option( ldap.OPT_REFERRALS, 0 )
except Exception, e:
logging.error( 'missing ldap, try "easy_install python-ldap"' )
raise e

def ldap_auth( server = 'ldap', port = None,
base_dn = 'ou=users,dc=domain,dc=com',
mode = 'uid', secure = False, cert_path = None, cert_file = None,
bind_dn = None, bind_pw = None, filterstr = 'objectClass=*',
username_attrib = 'uid',
custom_scope = 'subtree',
allowed_groups = None,
manage_user = False,
user_firstname_attrib = 'cn:1',
user_lastname_attrib = 'cn:2',
user_mail_attrib = 'mail',
manage_groups = False,
db = None,
group_dn = None,
group_name_attrib = 'cn',
group_member_attrib = 'memberUid',
group_filterstr = 'objectClass=*',
logging_level = 'error' ):

"""
to use ldap login with MS Active Directory:

from gluon.contrib.login_methods.ldap_auth import ldap_auth
auth.settings.login_methods.append(ldap_auth(
mode='ad', server='my.domain.controller',
base_dn='ou=Users,dc=domain,dc=com'))

to use ldap login with Notes Domino:

auth.settings.login_methods.append(ldap_auth(
mode='domino',server='my.domino.server'))

to use ldap login with OpenLDAP:

auth.settings.login_methods.append(ldap_auth(
server='my.ldap.server', base_dn='ou=Users,dc=domain,dc=com'))

to use ldap login with OpenLDAP and subtree search and (optionally) multiple DNs:

auth.settings.login_methods.append(ldap_auth(
mode='uid_r', server='my.ldap.server',
base_dn=['ou=Users,dc=domain,dc=com','ou=Staff,dc=domain,dc=com']))

or (if using CN):

auth.settings.login_methods.append(ldap_auth(
mode='cn', server='my.ldap.server',
base_dn='ou=Users,dc=domain,dc=com'))

or you can full customize the search for user:

auth.settings.login_methods.append(ldap_auth(
mode='custom', server='my.ldap.server',
base_dn='ou=Users,dc=domain,dc=com',
username_attrib='uid',
custom_scope='subtree'))

the custom_scope can be: base, onelevel, subtree.

If using secure ldaps:// pass secure=True and cert_path="..."
If ldap is using GnuTLS then you need cert_file="..." instead cert_path because
cert_path isn't implemented in GnuTLS :(

If you need to bind to the directory with an admin account in order to search it then specify bind_dn & bind_pw to use for this.
- currently only implemented for Active Directory

If you need to restrict the set of allowed users (e.g. to members of a department) then specify
a rfc4515 search filter string.
- currently only implemented for mode in ['ad', 'company', 'uid_r']
You can manage user attribute first name, last name, email from ldap:
auth.settings.login_methods.append(ldap_auth(...as usual...,
manage_user = True,
user_firstname_attrib = 'cn:1',
user_lastname_attrib = 'cn:2',
user_mail_attrib = 'mail'
))

Where:
manage_user - let web2py handle user data from ldap
user_firstname_attrib - the attribute containing the user's first name
optionally you can specify parts.
Example: cn: "John Smith" - 'cn:1' = 'John'
user_lastname_attrib - the attribute containing the user's last name
optionally you can specify parts.
Example: cn: "John Smith" - 'cn:2' = 'Smith'
user_mail_attrib - the attribure containing the user's email address


If you need group control from ldap to web2py app's database feel free to set:

auth.settings.login_methods.append(ldap_auth(...as usual...,
manage_groups = True,
db = db,
group_dn = 'ou=Groups,dc=domain,dc=com',
group_name_attrib = 'cn',
group_member_attrib = 'memberUid',
group_filterstr = 'objectClass=*'
))

[web2py] A database design dillema

2012-07-11 Thread Najtsirk
Hello,

I have a database design dilema. I want to do a e-learning system for a 
course. The course soould have severeal lessons, each lesson can be of 
different type.

Let's say we have following model:

#for definiton of each course
db.define_table('course',

Field('title', 'string')) 

 


#for the video lesson
db.define_table('video',

Field('title', 'string'),

Field('video_url', 'string'),

Field('course_id', db.course),

Field('weight', 'integer'))


#for the tekst lesson
db.define_table('text',

Field('title', 'string'),

Field('content', 'text'),

Field('course_id', db.course),

Field('weight', 'integer'))


I know how to do this with a raw sql using UNION, like:

db.executesql('SELECT title, course_id, weight FROM video UNION SELECT 
title, course_id, weight FROM text WHERE course_id = *some_value* ORDER BY 
weight')

But i wondering if there is any way I can achieve that with DAL? Maybe I 
should design the database model in a different way?

Thank you for your replies, ideas, thoughts..

Kristjan

 


 


Re: [web2py] Any jquery gurus out there?

2012-07-11 Thread Daniel Gonzale

I don't understand a lot the pourpose of this selector

> $(document.location.hash).removeClass("hidden");
>

If the element has the id attr as the same hash you should use

> $("#"+document.location.hash).removeClass("hidden");

Or if the hash is in the href attr you can use

> $('[href="'+document.location.hash+'"]').removeClass("hidden");

In this case i don't know if you have to use the # becasue i think that it is 
included in the href tag, maybe it can be

> $('[href="#'+document.location.hash+'"]').removeClass("hidden");

Another thing you can do if nothing of this works is to use the command

console.log(document.location.hash);

To check if its really taking the hash value in IE

[web2py] Re: template.render() and whitespace [patch attached]

2012-07-11 Thread Massimo Di Pierro
I think the point of a template is that it {{.}} is turned into code but 
stuff outside is left unchanged. I'd rather leave this as it is. But thanks 
for brining this up.


On Wednesday, 11 July 2012 13:33:44 UTC-5, Rob wrote:
>
> Thanks Massimo.
>
> That prints out:
>hihihi
>
>
> If you change it to:
>  {{for d in data[:3]:
>= "hi\n" 
>pass}} 
>
> It prints out (spacing gets messed up):
>hi
> hi
> hi
>
> Anyway, you probably aren't interested in a patch (see attached), but this 
> patch has been working pretty good for me when using my original syntax. 
>  Although, I don't know if there are any unforeseen consequences since I'm 
> not using the templating engine to it's full potential right now.
>
> UPDATE: the attached patch matches template lines like{{for d in 
> data[:3]:}}{{foo = 5}}{{=foo}}   which it shouldn't (I think) and my regex 
> foo is weak :/
>
> UPDATE2:
> r_whitespace_cleanup = re.compile(r' *?(\{\{([^=])(.*?)\}\})[^\S\n]*\n*',re
> .MULTILINE)
> This is better, but still not perfect.
>
> Thanks,
> Rob
>
> On Tuesday, July 10, 2012 8:07:16 PM UTC-7, Massimo Di Pierro wrote:
>>
>> You can do
>>
>>  {{for d in data[:3]:
>>= "hi" 
>>pass}}
>>
>> to achieve when you want.
>>
>> On Tuesday, 10 July 2012 16:08:40 UTC-5, Rob wrote:
>>>
>>> Hi,
>>>
>>> I'm using the standalone template.py to generate non html files and the 
>>> excess whitespace is making this somewhat painful.
>>>
>>> For example, my view:
>>> #ifndef __BLAH__
>>> #define __BLAH__
>>> {{for d in data[:3]:}}
>>>   {{= "hi"}} 
>>> {{pass}}
>>> #endif
>>>
>>> outputs:
>>> #ifndef __BLAH__
>>> #define __BLAH__
>>> 
>>>   hi 
>>> 
>>>   hi 
>>> 
>>>   hi 
>>> 
>>> #endif
>>>
>>> I'm sure there are lots of reasons why this can't happen, but I propose 
>>> that render() simply removes lines that contain nothing but whitespace and 
>>> logic. For example, given the same view:
>>> 1 #ifndef __BLAH__
>>> 2 #define __BLAH__
>>> 3 {{for d in data[:3]:}}
>>> 4   {{= "hi"}} 
>>> 5 {{pass}}
>>> 6 #endif 
>>>
>>> Line number 3 and 6 contain nothing but template logic and whitespace 
>>> (with excess carriage returns).  Is there a reason why the rendering engine 
>>> couldn't simply remove this whitespace from the output?  IE: if the line 
>>> contains pure logic ({{...}}) and whitespace, just remove it.  If the line 
>>> contains {{=..}} and other whitespace then it stays.
>>>
>>> Does this break all sorts of HTML output?
>>>
>>> Thanks,
>>> Rob
>>>
>>

[web2py] Re: ldap login method bug - Allows any user to log in with blank password (AD)

2012-07-11 Thread Massimo Di Pierro
Thanks, in trunk. Any chance you could fix the indentation a little to 
follow pep8

I did some of it but it needs more work. This is not your fault. The pep8 
was badly broken in the original file.

Massimo

On Wednesday, 11 July 2012 17:45:04 UTC-5, Kory Prince wrote:
>
> I did some digging and turned up this:
> http://docs.oracle.com/javase/jndi/tutorial/ldap/security/simple.html
>
> Which says a blank password causes the protocol to be changed to "none."
>
> More specifically http://tools.ietf.org/html/rfc4513#section-5.1.2 tells 
> us
>  "Clients SHOULD disallow an empty password input to a Name/Password 
> Authentication user interface."
>
>
> Therefore I submit this patch that simply performs a check for a blank 
> password. If you think there is a better way,
> please let me know, but I think it would be best to follow protocol.
>
> Thanks,
> Kory
>
>

[web2py] Re: A database design dillema

2012-07-11 Thread Massimo Di Pierro
Not in a single query using dal. And to tell you the truth I do not like 
union too much. :-(



On Wednesday, 11 July 2012 17:47:06 UTC-5, Najtsirk wrote:
>
> Hello,
>
> I have a database design dilema. I want to do a e-learning system for a 
> course. The course soould have severeal lessons, each lesson can be of 
> different type.
>
> Let's say we have following model:
>
> #for definiton of each course
> db.define_table('course',
>
> Field('title', 'string')) 
>
>  
>
>
> #for the video lesson
> db.define_table('video',
>
> Field('title', 'string'),
>
> Field('video_url', 'string'),
>
> Field('course_id', db.course),
>
> Field('weight', 'integer'))
>
>
> #for the tekst lesson
> db.define_table('text',
>
> Field('title', 'string'),
>
> Field('content', 'text'),
>
> Field('course_id', db.course),
>
> Field('weight', 'integer'))
>
>
> I know how to do this with a raw sql using UNION, like:
>
> db.executesql('SELECT title, course_id, weight FROM video UNION SELECT 
> title, course_id, weight FROM text WHERE course_id = *some_value* ORDER 
> BY weight')
>
> But i wondering if there is any way I can achieve that with DAL? Maybe I 
> should design the database model in a different way?
>
> Thank you for your replies, ideas, thoughts..
>
> Kristjan
>
>  
>
>
>  
>


[web2py] Re: A database design dillema

2012-07-11 Thread Najtsirk
Yeah...i noticed that from your previous answers :)

But...what my other options?

On Thursday, 12 July 2012 01:13:06 UTC+2, Massimo Di Pierro wrote:
>
> Not in a single query using dal. And to tell you the truth I do not like 
> union too much. :-(
>
>
>
> On Wednesday, 11 July 2012 17:47:06 UTC-5, Najtsirk wrote:
>>
>> Hello,
>>
>> I have a database design dilema. I want to do a e-learning system for a 
>> course. The course soould have severeal lessons, each lesson can be of 
>> different type.
>>
>> Let's say we have following model:
>>
>> #for definiton of each course
>> db.define_table('course',
>>
>> Field('title', 'string')) 
>>
>>  
>>
>>
>> #for the video lesson
>> db.define_table('video',
>>
>> Field('title', 'string'),
>>
>> Field('video_url', 'string'),
>>
>> Field('course_id', db.course),
>>
>> Field('weight', 'integer'))
>>
>>
>> #for the tekst lesson
>> db.define_table('text',
>>
>> Field('title', 'string'),
>>
>> Field('content', 'text'),
>>
>> Field('course_id', db.course),
>>
>> Field('weight', 'integer'))
>>
>>
>> I know how to do this with a raw sql using UNION, like:
>>
>> db.executesql('SELECT title, course_id, weight FROM video UNION SELECT 
>> title, course_id, weight FROM text WHERE course_id = *some_value* ORDER 
>> BY weight')
>>
>> But i wondering if there is any way I can achieve that with DAL? Maybe I 
>> should design the database model in a different way?
>>
>> Thank you for your replies, ideas, thoughts..
>>
>> Kristjan
>>
>>  
>>
>>
>>  
>>
>

[web2py] how to deploy web2py on apache on Centos 6.2?

2012-07-11 Thread Tony Wang
I was wondering how to run web2py on apache, and is there a step-by-step
guide somewhere online?

do you recommend finishing development before deploying the application on
apache? thanks!

-- 
  ☃ (\__/)
  (='.'=)
  (")_(")
- 温 良 恭 俭 让 仁 义 礼 智 信
- Through suffering to renown


[web2py] Re: Contributor Agreement Question

2012-07-11 Thread Rhys
Hey Massimo,

Just testing the water, as I was going to contribute to another project in 
the past and fired a question like this and they didn't give me the 
response that I wanted just fluffy bits in their answer. With you though, 
straight to the point and you gave me exactly what I wanted. I've signed 
the agreement.

I'll send you a digital copy and I'll also post the original today.

Cheers,

Rhys

On Thursday, July 12, 2012 2:34:56 AM UTC+10, Massimo Di Pierro wrote:
>
> The contributor agreement serves two purposes:
>
> 1) states you can do anything you want with your contribution. The fact it 
> becomes part of web2py does not prevent you from selling or modifying or 
> reusing your contribution.
>
> 2) gives me legal rights to speak for web2py and - for example - 
> change/amend/customize the web2py license. 
>
> 2 is really important. I give you some examples:
> - In the past we had to change the license from the custom one to the 
> LGPL. I had the right to do so. Mind that it only makes sense for me 
> to exercise this right to make it more open. In fact if I were to make it 
> more restrictive, you would fork web2py.
> - A major manufacturing corporation wanted to use web2py for the interface 
> of an industrial robot. They asked me permission to do so. I told them the 
> LGPL license gives them such permission. Their legal department asked for a 
> custom agreement that explicitly allows them to do so. The contributor 
> agreement gives me the right to write such custom agreement (the agreement 
> is very much like this one: 
> http://www.sencha.com/legal/sencha-commercial-software-license-agreement/)
> - If there is any need to defend web2py in court, I have the right to do 
> it.
>
> Keep in mind that the "community" is not a legal entity. Every open source 
> project is owed by somebody. And when it is not, it does not last much. RoR 
> is owned by 37 Signals (a private company), Django is owned by the Django 
> Foundation (and a foundation is not the same as the "community", it is a 
> non-for-profit registered company).
>
> I have considered giving the web2py right to a company or a foundation 
> but, 1) it would not change for the contributor agreement (it would just 
> list a different legal entity as copyright holder). 2) it would be more 
> expensive (a company costs $1000/year and a foundation about double). 3) a 
> company or a foundation is more likely to go broke than I am as a person. 
> What would happen to the legal rights on web2py in that case?
>
> The legal agreement says you do not worry about all of this. I do. 
>
> Massimo
>
>
> On Wednesday, 11 July 2012 05:41:37 UTC-5, Rhys wrote:
>>
>> Hey Everyone,
>>
>> I have a few questions about the contributors agreement. I've gotten to 
>> that point where I would like to contribute where I can, but there are 
>> somethings which are rattling around in my head. 
>>
>> When this agreement states 'I' or 'me' who or what is that exactly. The 
>> reason I ask is because of section 2 condition 4:
>>
>> *you agree that I may register a copyright in your contribution and 
>> exercise all ownership rights associated with it;*
>>
>> If I create something which is fantastic say, I don't want an individual 
>> to own it, only the project/foundation. As a result the copyright is 
>> remains with the project not an individual.  I'm trying to really find out 
>> where does the buck stop. Is this project a single entity which supports 
>> it's contributors as no one is given full rights, or is it one individual 
>> who is given rights for others intellectual property around a project?
>>
>> No offence Massimo, but I'm a little bit confused because your name is on 
>> every bit of copyright around web2py I've seen. What is stopping you taking 
>> out a copyright where you own entire rights so if it can be sold you can 
>> take the money and run?
>>
>> I understand why you have these, yet that is a bold condition which I'm 
>> having trouble making it clear. If someone could make it clearer by showing 
>> somewhere in the agreement removes such ownership of one individual I'll 
>> sign it straight away. Maybe I've missed something?
>>
>> Cheers,
>>
>> Rhys
>>
>

[web2py] Re: A database design dillema

2012-07-11 Thread Najtsirk
Can i achieve that with joins?

On Thursday, 12 July 2012 01:20:50 UTC+2, Najtsirk wrote:
>
> Yeah...i noticed that from your previous answers :)
>
> But...what my other options?
>
> On Thursday, 12 July 2012 01:13:06 UTC+2, Massimo Di Pierro wrote:
>>
>> Not in a single query using dal. And to tell you the truth I do not like 
>> union too much. :-(
>>
>>
>>
>> On Wednesday, 11 July 2012 17:47:06 UTC-5, Najtsirk wrote:
>>>
>>> Hello,
>>>
>>> I have a database design dilema. I want to do a e-learning system for a 
>>> course. The course soould have severeal lessons, each lesson can be of 
>>> different type.
>>>
>>> Let's say we have following model:
>>>
>>> #for definiton of each course
>>> db.define_table('course',
>>>
>>> Field('title', 'string')) 
>>>
>>>  
>>>
>>>
>>> #for the video lesson
>>> db.define_table('video',
>>>
>>> Field('title', 'string'),
>>>
>>> Field('video_url', 'string'),
>>>
>>> Field('course_id', db.course),
>>>
>>> Field('weight', 'integer'))
>>>
>>>
>>> #for the tekst lesson
>>> db.define_table('text',
>>>
>>> Field('title', 'string'),
>>>
>>> Field('content', 'text'),
>>>
>>> Field('course_id', db.course),
>>>
>>> Field('weight', 'integer'))
>>>
>>>
>>> I know how to do this with a raw sql using UNION, like:
>>>
>>> db.executesql('SELECT title, course_id, weight FROM video UNION SELECT 
>>> title, course_id, weight FROM text WHERE course_id = *some_value* ORDER 
>>> BY weight')
>>>
>>> But i wondering if there is any way I can achieve that with DAL? Maybe I 
>>> should design the database model in a different way?
>>>
>>> Thank you for your replies, ideas, thoughts..
>>>
>>> Kristjan
>>>
>>>  
>>>
>>>
>>>  
>>>
>>

[web2py] Re: how to deploy web2py on apache on Centos 6.2?

2012-07-11 Thread Massimo Di Pierro
You just run 
this: 
http://code.google.com/p/web2py/source/browse/scripts/setup-web2py-ubuntu.sh

On Wednesday, 11 July 2012 18:35:07 UTC-5, ivytony wrote:
>
> I was wondering how to run web2py on apache, and is there a step-by-step 
> guide somewhere online?
>
> do you recommend finishing development before deploying the application on 
> apache? thanks!
>
> -- 
>   ☃ (\__/)
>   (='.'=)
>   (")_(") 
> - 温 良 恭 俭 让 仁 义 礼 智 信
> - Through suffering to renown
>
>

[web2py] Re: Contributor Agreement Question

2012-07-11 Thread Massimo Di Pierro
Thank you. This issues comes up once in a while and I am learning myself 
via interaction with users. The move from GPL to LGPL was proposed, for 
example, by users.

Massimo

On Wednesday, 11 July 2012 18:53:05 UTC-5, Rhys wrote:
>
> Hey Massimo,
>
> Just testing the water, as I was going to contribute to another project in 
> the past and fired a question like this and they didn't give me the 
> response that I wanted just fluffy bits in their answer. With you though, 
> straight to the point and you gave me exactly what I wanted. I've signed 
> the agreement.
>
> I'll send you a digital copy and I'll also post the original today.
>
> Cheers,
>
> Rhys
>
> On Thursday, July 12, 2012 2:34:56 AM UTC+10, Massimo Di Pierro wrote:
>>
>> The contributor agreement serves two purposes:
>>
>> 1) states you can do anything you want with your contribution. The fact 
>> it becomes part of web2py does not prevent you from selling or modifying or 
>> reusing your contribution.
>>
>> 2) gives me legal rights to speak for web2py and - for example - 
>> change/amend/customize the web2py license. 
>>
>> 2 is really important. I give you some examples:
>> - In the past we had to change the license from the custom one to the 
>> LGPL. I had the right to do so. Mind that it only makes sense for me 
>> to exercise this right to make it more open. In fact if I were to make it 
>> more restrictive, you would fork web2py.
>> - A major manufacturing corporation wanted to use web2py for the 
>> interface of an industrial robot. They asked me permission to do so. I told 
>> them the LGPL license gives them such permission. Their legal department 
>> asked for a custom agreement that explicitly allows them to do so. The 
>> contributor agreement gives me the right to write such custom agreement 
>> (the agreement is very much like this one: 
>> http://www.sencha.com/legal/sencha-commercial-software-license-agreement/
>> )
>> - If there is any need to defend web2py in court, I have the right to do 
>> it.
>>
>> Keep in mind that the "community" is not a legal entity. Every open 
>> source project is owed by somebody. And when it is not, it does not last 
>> much. RoR is owned by 37 Signals (a private company), Django is owned by 
>> the Django Foundation (and a foundation is not the same as the "community", 
>> it is a non-for-profit registered company).
>>
>> I have considered giving the web2py right to a company or a foundation 
>> but, 1) it would not change for the contributor agreement (it would just 
>> list a different legal entity as copyright holder). 2) it would be more 
>> expensive (a company costs $1000/year and a foundation about double). 3) a 
>> company or a foundation is more likely to go broke than I am as a person. 
>> What would happen to the legal rights on web2py in that case?
>>
>> The legal agreement says you do not worry about all of this. I do. 
>>
>> Massimo
>>
>>
>> On Wednesday, 11 July 2012 05:41:37 UTC-5, Rhys wrote:
>>>
>>> Hey Everyone,
>>>
>>> I have a few questions about the contributors agreement. I've gotten to 
>>> that point where I would like to contribute where I can, but there are 
>>> somethings which are rattling around in my head. 
>>>
>>> When this agreement states 'I' or 'me' who or what is that exactly. The 
>>> reason I ask is because of section 2 condition 4:
>>>
>>> *you agree that I may register a copyright in your contribution and 
>>> exercise all ownership rights associated with it;*
>>>
>>> If I create something which is fantastic say, I don't want an individual 
>>> to own it, only the project/foundation. As a result the copyright is 
>>> remains with the project not an individual.  I'm trying to really find out 
>>> where does the buck stop. Is this project a single entity which supports 
>>> it's contributors as no one is given full rights, or is it one individual 
>>> who is given rights for others intellectual property around a project?
>>>
>>> No offence Massimo, but I'm a little bit confused because your name is 
>>> on every bit of copyright around web2py I've seen. What is stopping you 
>>> taking out a copyright where you own entire rights so if it can be sold you 
>>> can take the money and run?
>>>
>>> I understand why you have these, yet that is a bold condition which I'm 
>>> having trouble making it clear. If someone could make it clearer by showing 
>>> somewhere in the agreement removes such ownership of one individual I'll 
>>> sign it straight away. Maybe I've missed something?
>>>
>>> Cheers,
>>>
>>> Rhys
>>>
>>

[web2py] Re: how to deploy web2py on apache on Centos 6.2?

2012-07-11 Thread pbreit
If you are new-ish to administering a web server, I like to advise first 
running the commands manually. Even if you're fairly experienced, it's a 
good idea to understand what is happening.

[web2py] Re: A database design dillema

2012-07-11 Thread pbreit
I don't see any reason to have more than one table "course" at this point. 
Just add a course_type=video|text (I don't think you can name a field 
"type").

[web2py] Sending an email on CRUD complete...

2012-07-11 Thread Jason Brower

I am reading in the book:
crud.settings.create_onvalidation = StorageList()
But I just don't get it.
I wanted to send an email when the form submits successfully, and I have 
created a method for that.

send_email(to_email, subject, message)
How would I do this?
BR,
Jason Brower



[web2py] GAE error (INSERT INTO auth_event fails)

2012-07-11 Thread Alexei Vinidiktov
Hello,

I'm receiving this error when trying to log in to my application:

ValueError: "INSERT INTO
auth_event(origin,user_id,description,time_stamp,client_ip)

VALUES 
('auth',2,'\xd0\x9f\xd0\xbe\xd0\xbb\xd1\x8c\xd0\xb7\xd0\xbe\xd0\xb2\xd0\xb0\xd1\x82\xd0\xb5\xd0\xbb\xd1\x8c
2 \xd0\xb2\xd0\xbe\xd1\x88\xd1\x91\xd0\xbb',
'2012-07-12 06:20:04','95.190.89.149');" has type str, but isn't in
7-bit ASCII encoding. Non-ASCII strings must be converted to unicode
objects before being added.

Can you help me understand what's going on here?

What's the description that is being inserted?

Here's the whole traceback:


   1. /user/login?_next=/ui 500 7153ms 0kb Mozilla/5.0 (Windows NT 6.2;
   rv:13.0) Gecko/20100101 Firefox/13.0.1

   95.190.89.149 - - [11/Jul/2012:23:20:11 -0700] "POST
/user/login?_next=/ui HTTP/1.1" 500 245
"http://www.vocabilis-net.appspot.com/user/login?_next=/ui";
"Mozilla/5.0 (Windows NT 6.2; rv:13.0) Gecko/20100101 Firefox/13.0.1"
"www.vocabilis-net.appspot.com" ms=7153 cpu_ms=2438 api_cpu_ms=0
cpm_usd=0.067897 instance=00c61b117ca46127ca9599783f07c494292f2e


   2.  D 2012-07-11 23:20:04.807

   select application=vocabilis

   3.  D 2012-07-11 23:20:04.808

   route: controller=default

   4.  D 2012-07-11 23:20:04.808

   route: function.ext=user.html

   5.  E 2012-07-11 23:20:11.821

   Traceback (most recent call last):
 File 
"/base/data/home/apps/s~vocabilis-net/1.360260160184278425/gluon/restricted.py",
line 205, in restricted
   exec ccode in environment
 File 
"/base/data/home/apps/s~vocabilis-net/1.360260160184278425/applications/vocabilis/controllers/default.py",
line 131, in 
 File 
"/base/data/home/apps/s~vocabilis-net/1.360260160184278425/gluon/globals.py",
line 173, in 
   self._caller = lambda f: f()
 File 
"/base/data/home/apps/s~vocabilis-net/1.360260160184278425/applications/vocabilis/controllers/default.py",
line 49, in user
   return dict(form=auth())
 File 
"/base/data/home/apps/s~vocabilis-net/1.360260160184278425/gluon/tools.py",
line 1161, in __call__
   return getattr(self,args[0])()
 File 
"/base/data/home/apps/s~vocabilis-net/1.360260160184278425/gluon/tools.py",
line 1814, in login
   self.log_event(log, user)
 File 
"/base/data/home/apps/s~vocabilis-net/1.360260160184278425/gluon/tools.py",
line 1461, in log_event
   origin=origin, user_id=user_id)
 File 
"/base/data/home/apps/s~vocabilis-net/1.360260160184278425/gluon/dal.py",
line 6829, in insert
   return self._db._adapter.insert(self,self._listify(fields))
 File 
"/base/data/home/apps/s~vocabilis-net/1.360260160184278425/gluon/dal.py",
line 928, in insert
   raise e
   ValueError: "INSERT INTO
auth_event(origin,user_id,description,time_stamp,client_ip) VALUES
('auth',2,'\xd0\x9f\xd0\xbe\xd0\xbb\xd1\x8c\xd0\xb7\xd0\xbe\xd0\xb2\xd0\xb0\xd1\x82\xd0\xb5\xd0\xbb\xd1\x8c
2 \xd0\xb2\xd0\xbe\xd1\x88\xd1\x91\xd0\xbb','2012-07-12
06:20:04','95.190.89.149');" has type str, but isn't in 7-bit ASCII
encoding. Non-ASCII strings must be converted to unicode objects
before being added.

   6.  I 2012-07-11 23:20:11.862

   Saved; key: __appstats__:004800, part: 134 bytes, full: 52828
bytes, overhead: 0.003 + 0.014; link:
http://www.vocabilis-net.appspot.com/_ah/stats/details?time=1342074004806




-- 
Alexei Vinidiktov


[web2py] Re: GAE error (INSERT INTO auth_event fails)

2012-07-11 Thread Alexei Vinidiktov
Sorry, forgot to mention that I'm using Python 2.7 and web2py 1.99.7 on GAE
.

On Thu, Jul 12, 2012 at 1:41 PM, Alexei Vinidiktov <
alexei.vinidik...@gmail.com> wrote:

> Hello,
>
> I'm receiving this error when trying to log in to my application:
>
> ValueError: "INSERT INTO 
> auth_event(origin,user_id,description,time_stamp,client_ip)
>
>
> VALUES 
> ('auth',2,'\xd0\x9f\xd0\xbe\xd0\xbb\xd1\x8c\xd0\xb7\xd0\xbe\xd0\xb2\xd0\xb0\xd1\x82\xd0\xb5\xd0\xbb\xd1\x8c
>  2 \xd0\xb2\xd0\xbe\xd1\x88\xd1\x91\xd0\xbb',
> '2012-07-12 06:20:04','95.190.89.149');" has type str, but isn't in 7-bit 
> ASCII encoding. Non-ASCII strings must be converted to unicode objects before 
> being added.
>
> Can you help me understand what's going on here?
>
> What's the description that is being inserted?
>
> Here's the whole traceback:
>
>
>1. /user/login?_next=/ui 500 7153ms 0kb Mozilla/5.0 (Windows NT 6.2;
>rv:13.0) Gecko/20100101 Firefox/13.0.1
>
>95.190.89.149 - - [11/Jul/2012:23:20:11 -0700] "POST /user/login?_next=/ui 
> HTTP/1.1" 500 245 "http://www.vocabilis-net.appspot.com/user/login?_next=/ui"; 
> "Mozilla/5.0 (Windows NT 6.2; rv:13.0) Gecko/20100101 Firefox/13.0.1" 
> "www.vocabilis-net.appspot.com" ms=7153 cpu_ms=2438 api_cpu_ms=0 
> cpm_usd=0.067897 instance=00c61b117ca46127ca9599783f07c494292f2e 
> 
>
>2.  D 2012-07-11 23:20:04.807
>
>select application=vocabilis
>
>3.  D 2012-07-11 23:20:04.808
>
>route: controller=default
>
>4.  D 2012-07-11 23:20:04.808
>
>route: function.ext=user.html
>
>5.  E 2012-07-11 23:20:11.821
>
>Traceback (most recent call last):
>  File 
> "/base/data/home/apps/s~vocabilis-net/1.360260160184278425/gluon/restricted.py",
>  line 205, in restricted
>exec ccode in environment
>  File 
> "/base/data/home/apps/s~vocabilis-net/1.360260160184278425/applications/vocabilis/controllers/default.py",
>  line 131, in 
>  File 
> "/base/data/home/apps/s~vocabilis-net/1.360260160184278425/gluon/globals.py", 
> line 173, in 
>self._caller = lambda f: f()
>  File 
> "/base/data/home/apps/s~vocabilis-net/1.360260160184278425/applications/vocabilis/controllers/default.py",
>  line 49, in user
>return dict(form=auth())
>  File 
> "/base/data/home/apps/s~vocabilis-net/1.360260160184278425/gluon/tools.py", 
> line 1161, in __call__
>return getattr(self,args[0])()
>  File 
> "/base/data/home/apps/s~vocabilis-net/1.360260160184278425/gluon/tools.py", 
> line 1814, in login
>self.log_event(log, user)
>  File 
> "/base/data/home/apps/s~vocabilis-net/1.360260160184278425/gluon/tools.py", 
> line 1461, in log_event
>origin=origin, user_id=user_id)
>  File 
> "/base/data/home/apps/s~vocabilis-net/1.360260160184278425/gluon/dal.py", 
> line 6829, in insert
>return self._db._adapter.insert(self,self._listify(fields))
>  File 
> "/base/data/home/apps/s~vocabilis-net/1.360260160184278425/gluon/dal.py", 
> line 928, in insert
>raise e
>ValueError: "INSERT INTO 
> auth_event(origin,user_id,description,time_stamp,client_ip) VALUES 
> ('auth',2,'\xd0\x9f\xd0\xbe\xd0\xbb\xd1\x8c\xd0\xb7\xd0\xbe\xd0\xb2\xd0\xb0\xd1\x82\xd0\xb5\xd0\xbb\xd1\x8c
>  2 \xd0\xb2\xd0\xbe\xd1\x88\xd1\x91\xd0\xbb','2012-07-12 
> 06:20:04','95.190.89.149');" has type str, but isn't in 7-bit ASCII encoding. 
> Non-ASCII strings must be converted to unicode objects before being added.
>
>6.  I 2012-07-11 23:20:11.862
>
>Saved; key: __appstats__:004800, part: 134 bytes, full: 52828 bytes, 
> overhead: 0.003 + 0.014; link: 
> http://www.vocabilis-net.appspot.com/_ah/stats/details?time=1342074004806
>
>
>
>
> --
> Alexei Vinidiktov
>



-- 
Alexei Vinidiktov


[web2py] Re: Interesting thing on the book website...

2012-07-11 Thread Annet
Hi Jason,

Are you guys getting this too? 
>

Yes, it crashes Firefox and make Safari hang.


Annet 


[web2py] db query not working

2012-07-11 Thread Hassan Alnatour
Dear ALL,

i am working with sqlite i have a table called "Video" like this  :



db.define_table('Videos',
Field('Title'),
Field('Hits','integer',default=1),
Field('Arabic_Title'),
Field('Bits_on_The_Run_Script'),
Field('Youtube_Video_Url'),
Field('Description','text',length=1000),
Field('Arabic_Description','text',length=1000),
Field('Publish_Date','datetime',default=now),
Field('Teacher',db.Teachers),
Field('Instroument',db.Instruments),
Field('Level',requires=IS_IN_SET(Course_level,zero=None)),
Field('Style'),

Field('Video_Type',requires=IS_IN_SET(Video_type,zero=None)),
Field('Course_ID'),
Field('Song_ID',db.Songs),
Field('Price',default=0),
Field('Full_Course_Price',default=0),
Field('Cover','upload'),
Field('PDF','upload'),

Field('Like','integer',default=1),
Field('ShowonSideBar','boolean'),
Field('HomePageVideo','boolean'),
Field('Order_Number','integer')


)

Now i use this to get recordes :

video = db().select(db.Videos.ALL) , it works fine  but when i add one 
 condition for it , it works well two but if i did this  , it just takes 
the first condition and ignore the rest :

video = db(db.Videos.Video_Type == "XXX" and db.Videos.Teacher == 
"xx").select(db.Videos.ALL) 


What do you think is the problem , what am i messing ??


Best Regards,
Hassan Alnatour




[web2py] REQUEST: Flag if database changes

2012-07-11 Thread Jason Brower

I wonder if the following would be good:
A flag would be marked True if there has been an auto-migration.
Then you could check if a change has happened and fix items in your 
database, but not need to search every time a page is run.
For example, if there are items that have a None and now need to have a 
default value from a list.

db.foo.bar.requires = IS_IN_SET([1,2,3,4])
This would make an new field have None for all existing records. That's 
not good, I would like:

if db.foo.bar.feild_changed:
#run my script
pass
BR,
Jason


Re: [web2py] Re: Vanity URLs

2012-07-11 Thread Sushant Taneja
I wrote the below line in routes.py. But I am getting a server response of 
400 instead of 404.

INFO 2012-07-11 07:21:03,242 dev_appserver.py:2952] "GET /staneja 
HTTP/1.1" 400 -

So I tried after changing 404 to 400 but it is still the same. No 
redirection or request for the target URL is made.

What might be causing the problem ?

I am using web2py 1.99.7 and running it on GAE dev_appserver (localhost)

On Sunday, July 8, 2012 7:34:47 AM UTC+5:30, Massimo Di Pierro wrote:
>
> It can be done already
>
> ('/$anything','404->/myapp/default/catchall/$anything')
>
> On Saturday, 7 July 2012 18:25:25 UTC-5, pbreit wrote:
>>
>> I wonder if we should try to support this formally. Perhaps if as a 
>> "catchall" if the router doesn't find any valid routes and before it 
>> returns a 404?
>
>

Re: [web2py] Re: Interesting thing on the book website...

2012-07-11 Thread Alec Taylor
Crashes in Waterfox and Chrome, seems to be a .js problem

On Wed, Jul 11, 2012 at 5:05 PM, Annet  wrote:
> Hi Jason,
>
>
>> Are you guys getting this too?
>
>
> Yes, it crashes Firefox and make Safari hang.
>
>
> Annet


[web2py] Website/Sqlite Backup

2012-07-11 Thread villas
Hi All,
I'm looking for any easy way to backup small websites which use Sqlite.  I 
found an interesting suggestion from Massimo:

>> Put web2py in a dropbox folder! Once a day hg commit the entire folder. 

That sounds good,  but would it make a safe copy of the data?  

In any case, does anyone have other ideas?

Regards, David


[web2py] Re: routes.py vs mod_rewrite

2012-07-11 Thread Athelionas
Than I'll go with routes.py. It's much easier than mod_rewrite and also 
100% portable which is a killer feature.
Thanks for the responses.

2012. július 10., kedd 23:51:54 UTC+2 időpontban Athelionas a következőt 
írta:
>
> What is the preferred way of rewriting URLs?
> Also, are there any advantages or disadvantages of choosing one over the 
> other?
>
> I like the idea of routes.py better because of portability, but is it any 
> good in case of static files?
>


[web2py] postgres connect problem

2012-07-11 Thread lucas
hello one and all,

i have web2py 1.99.7 under centos 6.2 with postgres 9.1.  i am trying to 
connect to postgres using the standard:

db = DAL('postgres://postgres:password@localhost/testbank')

but it does not connect properly.  i added the "self." under the dal.py 
file to ensure that line looks like:

self.driver = self.drivers.get('pg8000')

and deleted the dal.pyc and made sure it was recreated with a new date/time 
stamp.  the error i still get is:

Traceback (most recent call last):
  File "/opt/web-apps/web2py/gluon/dal.py", line 5955, in __init__
self._adapter = ADAPTERS[self._dbname](*args)
  File "/opt/web-apps/web2py/gluon/dal.py", line 1999, in __init__
self.driver = self.drivers.get('pg8000')
AttributeError: 'list' object has no attribute 'get'


postgres is running but it will not connect.  any ideas?

lucas





[web2py] Re: postgres connect problem

2012-07-11 Thread lucas
my install does recognize the pg8000 driver:

[root@q3200 web2py]# python web2py.py 
web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2011
Version 1.99.7 (2012-03-04 22:12:08) stable
Database drivers available: SQLite3, pymysql, pg8000, IMAP
Starting hardcron...



Re: [web2py] Getting drop-down value names from grandparent record

2012-07-11 Thread Johann Spies
On 11 July 2012 05:27, MichaelF  wrote:

> Didn't help. I now get the same error, this time in the function. Any idea
> what the error message is trying to tell me?


Unfortunately I don't have time to try and work out your logic.  The error
is telling you that the process could not find the key C1_2 in your
database query.  You have some logical proglem in your code.

Try and build an SQL-query to which you can translate into a function.

Regards
Johann

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


Re: [web2py] pre selected checkboxes

2012-07-11 Thread villas
Don't you need a list field type for 'usuarios'?


On Tuesday, July 10, 2012 9:49:40 PM UTC+1, Fabiano Faver wrote:
>
> controller:
>
> def gerenciar_grupos():
>
> form_not_usu = SQLFORM.factory(
> Field('usuarios', requires=IS_IN_DB(db, 
> db.auth_user,'%(email)s',multiple=True),widget=SQLFORM.widgets.checkboxes.widget,
>  
> default=True),
> )
> return dict(  form_not_usu = form_not_usu)
>
>
>
> view:
>
> {{extend 'layout.html'}}
> {{=form_not_usu.custom.begin}}
>
> 
> {{for x in form_not_usu.custom.widget.usuarios:}}
> {{=LI(x)}}
>
> {{pass}}
> 
>
> {{=form_not_usu.custom.submit}}
> {{=form_not_usu.custom.end}}
>
>
>
> Checkboxes are not checked when accessing the page.
>
> Em terça-feira, 10 de julho de 2012 16h46min48s UTC-3, Richard escreveu:
>>
>> in your model Field(..., default=True) or in the controller 
>> db.table.field.default=True
>>
>> You also need to use checkbox widget.
>>
>> Richard
>>
>> On Tue, Jul 10, 2012 at 2:39 PM, Fabiano Faver  wrote:
>>
>>> I want to creat something similar to SQLFORM(auth_membership) but I want 
>>> the user to choose a group and all users show up as checkboxes and users 
>>> who already belong to this group are checked as well.
>>>
>>> I`m downt know how to pre-select these auth_users.
>>>
>>> any tips?
>>>
>>
>>

[web2py] Re: db query not working

2012-07-11 Thread David Marko
Should not this ...
video = db(db.Videos.Video_Type == "XXX" and db.Videos.Teacher == 
"xx").select(db.Videos.ALL) 

be rather like this? (see and  vs. &)
video = db(db.Videos.Video_Type == "XXX" & db.Videos.Teacher == 
"xx").select(db.Videos.ALL)  


[web2py] Contributor Agreement Question

2012-07-11 Thread Rhys
Hey Everyone,

I have a few questions about the contributors agreement. I've gotten to 
that point where I would like to contribute where I can, but there are 
somethings which are rattling around in my head. 

When this agreement states 'I' or 'me' who or what is that exactly. The 
reason I ask is because of section 2 condition 4:

*you agree that I may register a copyright in your contribution and 
exercise all ownership rights associated with it;*

If I create something which is fantastic say, I don't want an individual to 
own it, only the project/foundation. As a result the copyright is remains 
with the project not an individual.  I'm trying to really find out where 
does the buck stop. Is this project a single entity which supports it's 
contributors as no one is given full rights, or is it one individual who is 
given rights for others intellectual property around a project?

No offence Massimo, but I'm a little bit confused because your name is on 
every bit of copyright around web2py I've seen. What is stopping you taking 
out a copyright where you own entire rights so if it can be sold you can 
take the money and run?

I understand why you have these, yet that is a bold condition which I'm 
having trouble making it clear. If someone could make it clearer by showing 
somewhere in the agreement removes such ownership of one individual I'll 
sign it straight away. Maybe I've missed something?

Cheers,

Rhys


[web2py] Re: postgres connect problem

2012-07-11 Thread lucas
and i did "CREATE DATABASE testbank;" under psql and it does exist as an 
empty database at this point.


Re: [web2py] Vaildating hexadecimal field

2012-07-11 Thread Jonathan Lundell
On 10 Jul 2012, at 11:21 PM, Annet wrote:
> I have a table in which users enter hexadecimal values to set colors and 
> background-colors. I'd like to validate the values the user enter, 
> requires=IS_HEX() would be ideal, but there is no such validator. I wonder 
> whether any one has done hexadecimal validation and could provide me with a 
> validator.

IS_MATCH(r'([\da-fA-F]{3}|[\da-fA-F]{6})', strict=True)

That's assuming you want a web color, restricted to 3 or 6 hex digits. You 
could of course edit it as required.

Re: [web2py] Re: routes.py vs mod_rewrite

2012-07-11 Thread Jonathan Lundell
On 11 Jul 2012, at 1:19 AM, Athelionas wrote:
> Than I'll go with routes.py. It's much easier than mod_rewrite and also 100% 
> portable which is a killer feature.

There's also no reason you can't use both. Go with routes.py and add an Apache 
rewrite if you want to speed up static accesses. There are examples in the 
scripts directory.

> Thanks for the responses.
> 
> 2012. július 10., kedd 23:51:54 UTC+2 időpontban Athelionas a következőt írta:
> What is the preferred way of rewriting URLs?
> Also, are there any advantages or disadvantages of choosing one over the 
> other?
> 
> I like the idea of routes.py better because of portability, but is it any 
> good in case of static files?




[web2py] Re: postgres connect problem

2012-07-11 Thread Cliff Kachinske
Have you created a postgres user?
Does the user own the database?
Does the user have a password?

If not, make these things happen.  A Google search will take you to the 
Postgres manual pages.

If there is a user named "testuser" with a password "testword" then your 
connection string should look like this:

db = DAL('postgres://testuser:testword@localhost:5432/testbank')

Note the 5432.  That's the default postgres connection port.

Undo your changes to the dal code.

On Wednesday, July 11, 2012 8:25:25 AM UTC-4, lucas wrote:
>
> and i did "CREATE DATABASE testbank;" under psql and it does exist as an 
> empty database at this point.
>


[web2py] Re: Custom auth table, auth_membership insert failing in Admin

2012-07-11 Thread Massimo Di Pierro
Do you have a longer traceback? It would help to know which line in 
tools.py is causing the problem.

It is true that Auth assumes the id field for auth tables to be called id. 
Perhaps this can be changed. 

Massimo

On Wednesday, 11 July 2012 01:10:17 UTC-5, Jerry wrote:
>
> Hello,
>
> I have a legacy MS SQL db with a User table with lots of old data:
>
> db3.define_table('People',
> Field('People_ID', 'id'),
> Field('LastName', length=50),
> Field('FirstName', length=50),
> 
> migrate = False
> )
> custom_auth_table = db3['People']
>
> # tell Auth to use this table
> auth.settings.table_user = custom_auth_table 
>
> # have Auth create the group, membership etc. tables
> auth.define_tables()
>
> I can view tables, including the legacy People via Admin - the new auth 
> tables don't contain any data - and create a new group in auth_group no 
> problem.
>
> When I try to insert a new auth_membership:
> /appadmin/insert/db3/auth_membership
> CPU utilization goes to 100% for a couple of seconds and I get an error:
>
>   File "\web2py\gluon\dal.py", line 5648, in __getitem__
> return dict.__getitem__(self, key)
> KeyError: 'id'
>
> Variables self  0x0...lete_record':  at 0x08A866B0>}>  dict.__getitem__ 
>  '__getitem__' of 'dict' objects>  builtindict   key 'id'
> I suspect the error has something to do with the 'id' field of the User 
> table ('People') being 'People_ID' instead of 'id'.
> However looking at the db auth_membership table definition, the 'user_id' 
> column seems correct - a Foreign Key pointing to 'People' / 'People_ID'.
> I'm stumped.
>
> Any ideas?
>
> Thanks,
>
> Jerry.
>


Re: [web2py] Re: db query not working

2012-07-11 Thread hasan alnator
Dear David,

the '&' is not supported when i use it i get this :

 unsupported operand type(s) for &: 'str' and 'Field'




On Wed, Jul 11, 2012 at 1:41 PM, David Marko  wrote:

> Should not this ...
> video = db(db.Videos.Video_Type == "XXX" and db.Videos.Teacher ==
> "xx").select(db.Videos.ALL)
>
> be rather like this? (see and  vs. &)
> video = db(db.Videos.Video_Type == "XXX" & db.Videos.Teacher ==
> "xx").select(db.Videos.ALL)
>


Re: [web2py] Re: db query not working

2012-07-11 Thread Jonathan Lundell
On 11 Jul 2012, at 7:09 AM, hasan alnator wrote:
> Dear David,
> 
> the '&' is not supported when i use it i get this : 
> 
>  unsupported operand type(s) for &: 'str' and 'Field'
> 

video = db((db.Videos.Video_Type == "XXX") & (db.Videos.Teacher == 
"xx")).select(db.Videos.ALL)  


> On Wed, Jul 11, 2012 at 1:41 PM, David Marko  wrote:
> Should not this ...
> video = db(db.Videos.Video_Type == "XXX" and db.Videos.Teacher == 
> "xx").select(db.Videos.ALL) 
> 
> be rather like this? (see and  vs. &)
> video = db(db.Videos.Video_Type == "XXX" & db.Videos.Teacher == 
> "xx").select(db.Videos.ALL)  
> 




[web2py] Re: REQUEST: Flag if database changes

2012-07-11 Thread Massimo Di Pierro

Excellent idea. In trunk

db._migrated gives you a list of table that currently migrated.

On Wednesday, 11 July 2012 02:16:20 UTC-5, encompass wrote:
>
> I wonder if the following would be good: 
> A flag would be marked True if there has been an auto-migration. 
> Then you could check if a change has happened and fix items in your 
> database, but not need to search every time a page is run. 
> For example, if there are items that have a None and now need to have a 
> default value from a list. 
> db.foo.bar.requires = IS_IN_SET([1,2,3,4]) 
> This would make an new field have None for all existing records. That's 
> not good, I would like: 
> if db.foo.bar.feild_changed: 
>  #run my script 
>  pass 
> BR, 
> Jason 
>


Re: [web2py] Re: Vanity URLs

2012-07-11 Thread Massimo Di Pierro
Can I see your full routes?

On Wednesday, 11 July 2012 02:26:04 UTC-5, Sushant Taneja wrote:
>
> I wrote the below line in routes.py. But I am getting a server response of 
> 400 instead of 404.
>
> INFO 2012-07-11 07:21:03,242 dev_appserver.py:2952] "GET /staneja 
> HTTP/1.1" 400 -
>
> So I tried after changing 404 to 400 but it is still the same. No 
> redirection or request for the target URL is made.
>
> What might be causing the problem ?
>
> I am using web2py 1.99.7 and running it on GAE dev_appserver (localhost)
>
> On Sunday, July 8, 2012 7:34:47 AM UTC+5:30, Massimo Di Pierro wrote:
>>
>> It can be done already
>>
>> ('/$anything','404->/myapp/default/catchall/$anything')
>>
>> On Saturday, 7 July 2012 18:25:25 UTC-5, pbreit wrote:
>>>
>>> I wonder if we should try to support this formally. Perhaps if as a 
>>> "catchall" if the router doesn't find any valid routes and before it 
>>> returns a 404?
>>
>>

Re: [web2py] Re: db query not working

2012-07-11 Thread hasan alnator
ohh thank you Jonathan its working now , but can you tell me why ? i dont
understand

On Wed, Jul 11, 2012 at 5:14 PM, Jonathan Lundell wrote:

> On 11 Jul 2012, at 7:09 AM, hasan alnator wrote:
>
> Dear David,
>
> the '&' is not supported when i use it i get this :
>
>  unsupported operand type(s) for &: 'str' and 'Field'
>
>
> video = db((db.Videos.Video_Type == "XXX") & (db.Videos.Teacher ==
> "xx")).select(db.Videos.ALL)
>
>
> On Wed, Jul 11, 2012 at 1:41 PM, David Marko  wrote:
>
>> Should not this ...
>> video = db(db.Videos.Video_Type == "XXX" and db.Videos.Teacher ==
>> "xx").select(db.Videos.ALL)
>>
>> be rather like this? (see and  vs. &)
>> video = db(db.Videos.Video_Type == "XXX" & db.Videos.Teacher ==
>> "xx").select(db.Videos.ALL)
>>
>
>
>
>


Re: [web2py] Re: Vanity URLs

2012-07-11 Thread Sushant Taneja
Yes, sure. I have attached my routes.py with this reply.

On Wednesday, July 11, 2012 7:49:12 PM UTC+5:30, Massimo Di Pierro wrote:
>
> Can I see your full routes?
>
> On Wednesday, 11 July 2012 02:26:04 UTC-5, Sushant Taneja wrote:
>>
>> I wrote the below line in routes.py. But I am getting a server response 
>> of 400 instead of 404.
>>
>> INFO 2012-07-11 07:21:03,242 dev_appserver.py:2952] "GET /staneja 
>> HTTP/1.1" 400 -
>>
>> So I tried after changing 404 to 400 but it is still the same. No 
>> redirection or request for the target URL is made.
>>
>> What might be causing the problem ?
>>
>> I am using web2py 1.99.7 and running it on GAE dev_appserver (localhost)
>>
>> On Sunday, July 8, 2012 7:34:47 AM UTC+5:30, Massimo Di Pierro wrote:
>>>
>>> It can be done already
>>>
>>> ('/$anything','404->/myapp/default/catchall/$anything')
>>>
>>> On Saturday, 7 July 2012 18:25:25 UTC-5, pbreit wrote:

 I wonder if we should try to support this formally. Perhaps if as a 
 "catchall" if the router doesn't find any valid routes and before it 
 returns a 404?
>>>
>>>#!/usr/bin/python
# -*- coding: utf-8 -*-

# default_application, default_controller, default_function
# are used when the respective element is missing from the
# (possibly rewritten) incoming URL
#
default_application = 'devekayan'# ordinarily set in base routes.py
default_controller = 'default'  # ordinarily set in app-specific routes.py
default_function = 'index'  # ordinarily set in app-specific routes.py

# routes_app is a tuple of tuples.  The first item in each is a regexp that will
# be used to match the incoming request URL. The second item in the tuple is
# an applicationname.  This mechanism allows you to specify the use of an
# app-specific routes.py. This entry is meaningful only in the base routes.py.
#
# Example: support welcome, admin, app and myapp, with myapp the default:


#routers = dict(
  #BASE  = dict(default_application='devekayan'),
#)


#routes_app = ((r'/(?Pwelcome|admin|app)\b.*', r'\g'),
  #(r'(.*)', r'devekayan'),
  #(r'/?(.*)', r'devekayan'))

# routes_in is a tuple of tuples.  The first item in each is a regexp that will
# be used to match the incoming request URL. The second item in the tuple is
# what it will be replaced with.  This mechanism allows you to redirect incoming
# routes to different web2py locations
#
# Example: If you wish for your entire website to use init's static directory:
#
#   routes_in=( (r'/static/(?P[\w./-]+)', r'/init/static/\g') )
#

routes_in = (
  ('/$anything','404->/devekayan/view/user/$anything'),
)

routes_out = [(x, y) for (y, x) in routes_in]

# routes_out, like routes_in translates URL paths created with the web2py URL()
# function in the same manner that route_in translates inbound URL paths.
#

#routes_out = ((r'.*http://otherdomain.com.* /app/ctr(?P.*)', r'\g'),
  #(r'/app(?P.*)', r'\g'))

# Specify log level for rewrite's debug logging
# Possible values: debug, info, warning, error, critical (loglevels),
#  off, print (print uses print statement rather than logging)
# GAE users may want to use 'off' to suppress routine logging.
#
logging = 'debug'

# Error-handling redirects all HTTP errors (status codes >= 400) to a specified
# path.  If you wish to use error-handling redirects, uncomment the tuple
# below.  You can customize responses by adding a tuple entry with the first
# value in 'appName/HTTPstatusCode' format. ( Only HTTP codes >= 400 are
# routed. ) and the value as a path to redirect the user to.  You may also use
# '*' as a wildcard.
#
# The error handling page is also passed the error code and ticket as
# variables.  Traceback information will be stored in the ticket.
#
# routes_onerror = [
# (r'init/400', r'/init/default/login')
#,(r'init/*', r'/init/static/fail.html')
#,(r'*/404', r'/init/static/cantfind.html')
#,(r'*/*', r'/init/error/index')
# ]

# specify action in charge of error handling
#
# error_handler = dict(application='error',
#  controller='default',
#  function='index')

# In the event that the error-handling page itself returns an error, web2py will
# fall back to its old static responses.  You can customize them here.
# ErrorMessageTicket takes a string format dictionary containing (only) the
# "ticket" key.

# error_message = '%s'
# error_message_ticket = 'Internal errorTicket issued: %(ticket)s'

# specify a list of apps that bypass args-checking and use request.raw_args
#
#routes_apps_raw=['myapp']
#routes_apps_raw=['myapp', 'myotherapp']

def __routes_doctest():
'''
Dummy function for doctesting routes.py.

Use filter_url() to test incoming or outgoing routes;
filter_err() for error redirection.

filter_url() accepts overrides for method and remote host:
filter_url(url, method='get', remote='0.0.0.0', out=False)

filter_err() accepts overrides for application and ticket:
f

[web2py] Re: Interesting thing on the book website...

2012-07-11 Thread Massimo Di Pierro
I think it is a bug with jQuery.highlight. Definitively not a serverside 
problem.

On Wednesday, 11 July 2012 01:54:25 UTC-5, encompass wrote:
>
> When I search for || It stops at the first | and crashes my browser.   
> Are you guys getting this too? 
> BR, 
> Jason 
>
>

Re: [web2py] Re: db query not working

2012-07-11 Thread Jonathan Lundell
On 11 Jul 2012, at 7:19 AM, hasan alnator wrote:
> ohh thank you Jonathan its working now , but can you tell me why ? i dont 
> understand 

web2py overloads & to perform a logical-and role here, but it can't alter 
Python's operator precedence. The & operator has higher precedence than ==, 
unlike the 'and' operator (or the '&&' operator in C). So this:

video = db(db.Videos.Video_Type == "XXX" & db.Videos.Teacher == 
"xx").select(db.Videos.ALL)

evaluates the same as this:

video = db(db.Videos.Video_Type == ("XXX" & db.Videos.Teacher) == 
"xx").select(db.Videos.ALL)


> 
> On Wed, Jul 11, 2012 at 5:14 PM, Jonathan Lundell  wrote:
> On 11 Jul 2012, at 7:09 AM, hasan alnator wrote:
>> Dear David,
>> 
>> the '&' is not supported when i use it i get this : 
>> 
>>  unsupported operand type(s) for &: 'str' and 'Field'
>> 
> 
> video = db((db.Videos.Video_Type == "XXX") & (db.Videos.Teacher == 
> "xx")).select(db.Videos.ALL)  
> 
> 
>> On Wed, Jul 11, 2012 at 1:41 PM, David Marko  wrote:
>> Should not this ...
>> video = db(db.Videos.Video_Type == "XXX" and db.Videos.Teacher == 
>> "xx").select(db.Videos.ALL) 
>> 
>> be rather like this? (see and  vs. &)
>> video = db(db.Videos.Video_Type == "XXX" & db.Videos.Teacher == 
>> "xx").select(db.Videos.ALL)  
> 




[web2py] Re: Website/Sqlite Backup

2012-07-11 Thread Massimo Di Pierro
If you pay the $100, dropbox has a 6month restore. I do not know if it will 
save all the versions of the file, or only some snapshot.

On Wednesday, 11 July 2012 03:16:29 UTC-5, villas wrote:
>
> Hi All,
> I'm looking for any easy way to backup small websites which use Sqlite.  I 
> found an interesting suggestion from Massimo:
>
> >> Put web2py in a dropbox folder! Once a day hg commit the entire folder. 
>
> That sounds good,  but would it make a safe copy of the data?  
>
> In any case, does anyone have other ideas?
>
> Regards, David
>


[web2py] Re: Custom auth table, auth_membership insert failing in Admin

2012-07-11 Thread Jerry
Hi Massimo,

Traceback (most recent call last):
  File "\web2py\gluon\restricted.py", line 205, in restricted
exec ccode in environment
  File "/web2py/applications/pg/controllers/appadmin.py" 
, line 
410, in 
  File "\web2py\gluon\globals.py", line 173, in 
self._caller = lambda f: f()
  File "/web2py/applications/pg/controllers/appadmin.py" 
, line 
126, in insert
form = SQLFORM(db[table], ignore_rw=ignore_rw)
  File "\web2py\gluon\sqlhtml.py", line 868, in __init__
inp = self.widgets.options.widget(field, default)
  File "\web2py\gluon\sqlhtml.py", line 216, in widget
options = requires[0].options()
  File "\web2py\gluon\validators.py", line 465, in options
self.build_set()
  File "\web2py\gluon\validators.py", line 458, in build_set
self.theset = [str(r[self.kfield]) for r in records]
  File "\web2py\gluon\dal.py", line 5648, in __getitem__
return dict.__getitem__(self, key)
KeyError: 'id'


Thanks,

Jerry.

On Wednesday, July 11, 2012 7:07:16 AM UTC-7, Massimo Di Pierro wrote:
>
> Do you have a longer traceback? It would help to know which line in 
> tools.py is causing the problem.
>
> It is true that Auth assumes the id field for auth tables to be called id. 
> Perhaps this can be changed. 
>
> Massimo
>
> On Wednesday, 11 July 2012 01:10:17 UTC-5, Jerry wrote:
>>
>> Hello,
>>
>> I have a legacy MS SQL db with a User table with lots of old data:
>>
>> db3.define_table('People',
>> Field('People_ID', 'id'),
>> Field('LastName', length=50),
>> Field('FirstName', length=50),
>> 
>> migrate = False
>> )
>> custom_auth_table = db3['People']
>>
>> # tell Auth to use this table
>> auth.settings.table_user = custom_auth_table 
>>
>> # have Auth create the group, membership etc. tables
>> auth.define_tables()
>>
>> I can view tables, including the legacy People via Admin - the new auth 
>> tables don't contain any data - and create a new group in auth_group no 
>> problem.
>>
>> When I try to insert a new auth_membership:
>> /appadmin/insert/db3/auth_membership
>> CPU utilization goes to 100% for a couple of seconds and I get an error:
>>
>>   File "\web2py\gluon\dal.py", line 5648, in __getitem__
>> return dict.__getitem__(self, key)
>> KeyError: 'id'
>>
>> Variables self > 0x0...lete_record':  at 0x08A866B0>}>  dict.__getitem__ 
>> > '__getitem__' of 'dict' objects>  builtindict   key 'id'
>> I suspect the error has something to do with the 'id' field of the User 
>> table ('People') being 'People_ID' instead of 'id'.
>> However looking at the db auth_membership table definition, the 'user_id' 
>> column seems correct - a Foreign Key pointing to 'People' / 'People_ID'.
>> I'm stumped.
>>
>> Any ideas?
>>
>> Thanks,
>>
>> Jerry.
>>
>

Re: [web2py] Re: postgres connect problem

2012-07-11 Thread Bruce Wade
There is a bug with the version of the web2py you are using update to a
newer version. There has been a few posts in this group about that.

The other solution is to install psycopg2 and use that driver.

On Wed, Jul 11, 2012 at 7:05 AM, Cliff Kachinske  wrote:

> Have you created a postgres user?
> Does the user own the database?
> Does the user have a password?
>
> If not, make these things happen.  A Google search will take you to the
> Postgres manual pages.
>
> If there is a user named "testuser" with a password "testword" then your
> connection string should look like this:
>
> db = DAL('postgres://testuser:testword@localhost:5432/testbank')
>
> Note the 5432.  That's the default postgres connection port.
>
> Undo your changes to the dal code.
>
> On Wednesday, July 11, 2012 8:25:25 AM UTC-4, lucas wrote:
>>
>> and i did "CREATE DATABASE testbank;" under psql and it does exist as an
>> empty database at this point.
>>
>


-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.fittraineronline.com - Fitness Personal Trainers Online
http://www.warplydesigned.com


Re: [web2py] Re: Website/Sqlite Backup

2012-07-11 Thread Jonathan Lundell
On 11 Jul 2012, at 7:25 AM, Massimo Di Pierro wrote:
> If you pay the $100, dropbox has a 6month restore. I do not know if it will 
> save all the versions of the file, or only some snapshot.

I wouldn't count on dropbox to safely back up a live sqlite database, for the 
same reason you can't simply copy the file: you might get the database in an 
inconsistent state. Use the sqlite3 .backup command instead to take a snapshot. 
Send its output to a dropbox folder if you like.

> 
> On Wednesday, 11 July 2012 03:16:29 UTC-5, villas wrote:
> Hi All,
> I'm looking for any easy way to backup small websites which use Sqlite.  I 
> found an interesting suggestion from Massimo:
> 
> >> Put web2py in a dropbox folder! Once a day hg commit the entire folder. 
> 
> That sounds good,  but would it make a safe copy of the data?  
> 
> In any case, does anyone have other ideas?
> 
> Regards, David




Re: [web2py] Re: db query not working

2012-07-11 Thread Jonathan Lundell
On 11 Jul 2012, at 7:25 AM, Jonathan Lundell wrote:
> 
> On 11 Jul 2012, at 7:19 AM, hasan alnator wrote:
>> ohh thank you Jonathan its working now , but can you tell me why ? i dont 
>> understand 
> 
> web2py overloads & to perform a logical-and role here, but it can't alter 
> Python's operator precedence. The & operator has higher precedence than ==, 
> unlike the 'and' operator (or the '&&' operator in C). So this:
> 
> video = db(db.Videos.Video_Type == "XXX" & db.Videos.Teacher == 
> "xx").select(db.Videos.ALL)
> 
> evaluates the same as this:
> 
> video = db(db.Videos.Video_Type == ("XXX" & db.Videos.Teacher) == 
> "xx").select(db.Videos.ALL)

I added a line to the book pointing this out.

> 
> 
>> 
>> On Wed, Jul 11, 2012 at 5:14 PM, Jonathan Lundell  wrote:
>> On 11 Jul 2012, at 7:09 AM, hasan alnator wrote:
>>> Dear David,
>>> 
>>> the '&' is not supported when i use it i get this : 
>>> 
>>> unsupported operand type(s) for &: 'str' and 'Field'
>>> 
>> 
>> video = db((db.Videos.Video_Type == "XXX") & (db.Videos.Teacher == 
>> "xx")).select(db.Videos.ALL)  
>> 
>> 
>>> On Wed, Jul 11, 2012 at 1:41 PM, David Marko  wrote:
>>> Should not this ...
>>> video = db(db.Videos.Video_Type == "XXX" and db.Videos.Teacher == 
>>> "xx").select(db.Videos.ALL) 
>>> 
>>> be rather like this? (see and  vs. &)
>>> video = db(db.Videos.Video_Type == "XXX" & db.Videos.Teacher == 
>>> "xx").select(db.Videos.ALL)  
> 




[web2py] Re: Authorization w/ Janrain

2012-07-11 Thread Dave
That may be just the ticket.  Especially if I modify the list to be a db 
table that can be maintained by the site admin.  I will give that a try and 
see what I come up with :)

On Tuesday, July 10, 2012 6:15:23 PM UTC-4, Massimo Di Pierro wrote:
>
> How about this:
>
> AUTHORIZED_EMAILS = ['t...@example.com']
> url1 = URL('default','you_are_not_authorized')
> auth.settings.extra_fields['auth_user']=[Field('authorized','boolean',default=False,compute=lambda
>  
> row: row.email in AUTHORIZED_EMAILS)]
> if auth.user and not auth.user.authorized and not URL()==url1: 
> redirect(url1)
>
>
>
>
>
> On Tuesday, 10 July 2012 13:15:44 UTC-5, Dave wrote:
>>
>> Agreed.  It is not a Janrain specific issue, I am sure the same applies 
>> for other non-local authentication schemes.  In other systems I have 
>> implemented in the past I would allow authentication externally, but 
>> configured authorization separately.  An example from my past:  I have a 
>> webapp that I would like to use Active Directory authentication for. 
>>  Unfortunately, the audience of authorized users is not the entire company. 
>>  In that case a local database table with a list of authorized users was 
>> appropriate.
>>
>> In other cases maybe it makes sense to allow users to "request access" 
>> and that access to be approved or denied by a system admin.  { similar to 
>> the approval functionality in the default/user/register code }
>>
>> I suppose as a broader question, I should ask...  First, is there already 
>> a mechanism to separate the functions of authentication and authorization? 
>>  It seems to me that currently if authentication succeeds, that is it... 
>>  There is no authorization step.  Second, if the first answer is no, would 
>> it be desirable to add an extensible authorization capability to the 
>> framework?
>>
>> Thoughts?
>>
>>
>>
>> On Tuesday, July 10, 2012 1:45:00 PM UTC-4, Massimo Di Pierro wrote:
>>>
>>> Your problem is limiting the number of users who can sign in. I am not 
>>> sure this is a janrain issue.
>>> You need to handle it somehow at the web2py level and it should be 
>>> independent on which method you use for authentication (janrain or other).
>>>
>>> It can be done but how it is done depends on the details of your policy.
>>>
>>>
>>>
>>>
>>> On Tuesday, 10 July 2012 11:40:08 UTC-5, Dave wrote:

 I spent some time searching for this and have not come up with much.

 Has anybody implemented or tried to implement user authorization (read: 
 limit users that may sign in) with Janrain?

 I think there are two possibilities here...  The first possibility 
 falls under standard authorization where you define a "list" of users that 
 are authorized somewhere in db.auth* which is consulted at login.  Of 
 course, there is a potential issue with impersonation where someone other 
 than the intended user registers a FaceBook, LinkedIn, etc account...

 The other path would be to either gate registration similar 
 to auth.settings.registration_requires_approval = True for builtin 
 authentication.  That should be fairly easy to implement.  OR..  Leave the 
 Janrain user creation alone and assign a group permission to controller 
 methods.  The downside here is existing site code would have to be 
 refactored if someone wants to go from local auth to janrain.  For 
 example, 
 @auth.requires_login() would have to become 
 @auth.requires_membership('authorized') for the same level of security.

 Would anybody (besides me) be interested in this?

 I could work up some code

>>>

Re: [web2py] Re: db query not working

2012-07-11 Thread hasan alnator
Where ??

On Wed, Jul 11, 2012 at 6:00 PM, Jonathan Lundell wrote:

> On 11 Jul 2012, at 7:25 AM, Jonathan Lundell wrote:
> >
> > On 11 Jul 2012, at 7:19 AM, hasan alnator wrote:
> >> ohh thank you Jonathan its working now , but can you tell me why ? i
> dont understand
> >
> > web2py overloads & to perform a logical-and role here, but it can't
> alter Python's operator precedence. The & operator has higher precedence
> than ==, unlike the 'and' operator (or the '&&' operator in C). So this:
> >
> > video = db(db.Videos.Video_Type == "XXX" & db.Videos.Teacher ==
> "xx").select(db.Videos.ALL)
> >
> > evaluates the same as this:
> >
> > video = db(db.Videos.Video_Type == ("XXX" & db.Videos.Teacher) ==
> "xx").select(db.Videos.ALL)
>
> I added a line to the book pointing this out.
>
> >
> >
> >>
> >> On Wed, Jul 11, 2012 at 5:14 PM, Jonathan Lundell 
> wrote:
> >> On 11 Jul 2012, at 7:09 AM, hasan alnator wrote:
> >>> Dear David,
> >>>
> >>> the '&' is not supported when i use it i get this :
> >>>
> >>> unsupported operand type(s) for &: 'str' and 'Field'
> >>>
> >>
> >> video = db((db.Videos.Video_Type == "XXX") & (db.Videos.Teacher ==
> "xx")).select(db.Videos.ALL)
> >>
> >>
> >>> On Wed, Jul 11, 2012 at 1:41 PM, David Marko 
> wrote:
> >>> Should not this ...
> >>> video = db(db.Videos.Video_Type == "XXX" and db.Videos.Teacher ==
> "xx").select(db.Videos.ALL)
> >>>
> >>> be rather like this? (see and  vs. &)
> >>> video = db(db.Videos.Video_Type == "XXX" & db.Videos.Teacher ==
> "xx").select(db.Videos.ALL)
> >
>
>
>


[web2py] Profile link

2012-07-11 Thread Kevin Miller
Hi all,

I have created a custom view for profile. However, I don't know where to
look to change the profile link (auth.navbar) to use my link.

Thanks.


Re: [web2py] Re: db query not working

2012-07-11 Thread Jonathan Lundell
On 11 Jul 2012, at 8:03 AM, hasan alnator wrote:
> Where ??

In the DAL chapter, toward the end of the "Logical operators" section.

http://web2py.com/books/default/chapter/29/6#Logical-operators

> 
> On Wed, Jul 11, 2012 at 6:00 PM, Jonathan Lundell  wrote:
> On 11 Jul 2012, at 7:25 AM, Jonathan Lundell wrote:
> >
> > On 11 Jul 2012, at 7:19 AM, hasan alnator wrote:
> >> ohh thank you Jonathan its working now , but can you tell me why ? i dont 
> >> understand
> >
> > web2py overloads & to perform a logical-and role here, but it can't alter 
> > Python's operator precedence. The & operator has higher precedence than ==, 
> > unlike the 'and' operator (or the '&&' operator in C). So this:
> >
> > video = db(db.Videos.Video_Type == "XXX" & db.Videos.Teacher == 
> > "xx").select(db.Videos.ALL)
> >
> > evaluates the same as this:
> >
> > video = db(db.Videos.Video_Type == ("XXX" & db.Videos.Teacher) == 
> > "xx").select(db.Videos.ALL)
> 
> I added a line to the book pointing this out.
> 




[web2py] Re: Profile link

2012-07-11 Thread Anthony
The navbar assumes all the Auth actions are handled by the same function, 
with the action being specified via request.args[0]. If that's not your 
setup, then you'll have to create a custom navbar, or manipulate the navbar 
after it is generated.

Anthony

On Wednesday, July 11, 2012 11:15:21 AM UTC-4, dundee wrote:
>
> Hi all,
>
> I have created a custom view for profile. However, I don't know where to 
> look to change the profile link (auth.navbar) to use my link.
>
> Thanks.
>


Re: [web2py] Getting drop-down value names from grandparent record

2012-07-11 Thread MichaelF
Okay; I understand. Let me explain using a simpler version, and also come 
up with SQL that would do the equivalent.

Here's a simpler version. This example shows the problem, and simply uses a 
grandparent table (A), a parent table (B), and a child table (C). That is, 
C is a child of B, and B is a child of A:

db.define_table('A',
Field('A_name', 'string', required=True),
format='%(A_name)s')

db.define_table('B',
Field('A_id', db.A),
Field('B_name', 'string', required=True),
format='%(B_name)s')

db.define_table('C',
Field('B_id', db.B),
Field('C_name', 'string', required=True),
format='%(C_name)s')
db.C.B_id.requires=IS_IN_DB(db, 'B.id',
  lambda r : '%s' % (db.A[db.B[r.B_id].A_id].A_name)
  )

If I leave the lambda out, then the drop-down values are B.id values. I can 
make that be B.B_name values easily, but what I want are A.A_name values. 
The lambda is fairly straightforward (although I'm obviously missing 
something).

  lambda r : '%s' % (db.A[db.B[r.B_id].A_id].A_name)

The 'r' is the current record, and we're looking at a C record, so it first 
evaluates r.B_id, B_id being the foreign key in the C record of its parent 
B record. Let's say this evaluates to 123 (for example), which would then 
be id 123 in the B table. Now, replacing r.B_id with 123 we get:

  lambda r : '%s' % (db.A[db.B[123].A_id].A_name)

So now it evaluates db.B[123].A_id, A_id being the foreign key in the B 
record of its parent A record:

  lambda r : '%s' % (db.A[db.B[123].A_id].A_name)

Let's say that evaluates to 456, which would then be id 456 in the A table. 
Replacing db.B[123].A_id with 456 we get:

  lambda r : '%s' % (db.A[456].A_name)

So now it evaluates db.A[456].A_name, which is what I'd like to see in the 
drop-down. And yet the error I get is:
 'B_id'

An equivalent SQL to get the A_name for each C id would be:

SELECT C.id, A.A_name
FROM A  INNER JOIN
 B ON A.id = B.A_id INNER JOIN
 C ON B.id = C.B_id;

Thoughts?

Thanks.

On Wednesday, July 11, 2012 3:24:41 AM UTC-6, Johann Spies wrote:
>
> On 11 July 2012 05:27, MichaelF  wrote:
>
>> Didn't help. I now get the same error, this time in the function. Any 
>> idea what the error message is trying to tell me?
>
>
> Unfortunately I don't have time to try and work out your logic.  The error 
> is telling you that the process could not find the key C1_2 in your 
> database query.  You have some logical proglem in your code.
>
> Try and build an SQL-query to which you can translate into a function.
>
> Regards
> Johann
>  
> -- 
> Because experiencing your loyal love is better than life itself, 
> my lips will praise you.  (Psalm 63:3)
>
>

Re: [web2py] Re: Profile link

2012-07-11 Thread Kevin Miller
Thanks for the reply. That is my setup. The only edit I want is to change
the link on profile to point to my custom profile. Apart from that, I don't
want to edit any other function of the Auth system. Thanks. I kind a see
where it might be possible in gluon/tools.py, but I don't want to touch the
source code directly. I was hoping there was some settings I could alter.

I also did not want to create a custom navbar. However manipulating it
after it is generated seems an option. How do you do that to change the
link on the profile?

Thanks.

On Wed, Jul 11, 2012 at 10:31 AM, Anthony  wrote:

> The navbar assumes all the Auth actions are handled by the same function,
> with the action being specified via request.args[0]. If that's not your
> setup, then you'll have to create a custom navbar, or manipulate the navbar
> after it is generated.
>
> Anthony
>
>
> On Wednesday, July 11, 2012 11:15:21 AM UTC-4, dundee wrote:
>>
>> Hi all,
>>
>> I have created a custom view for profile. However, I don't know where to
>> look to change the profile link (auth.navbar) to use my link.
>>
>> Thanks.
>>
>


-- 
Kevin Miller
Acting Data Controller
Department of Computing
UWI, Mona
Kingston 7


[web2py] Re: Contributor Agreement Question

2012-07-11 Thread Massimo Di Pierro
The contributor agreement serves two purposes:

1) states you can do anything you want with your contribution. The fact it 
becomes part of web2py does not prevent you from selling or modifying or 
reusing your contribution.

2) gives me legal rights to speak for web2py and - for example - 
change/amend/customize the web2py license. 

2 is really important. I give you some examples:
- In the past we had to change the license from the custom one to the LGPL. 
I had the right to do so. Mind that it only makes sense for me 
to exercise this right to make it more open. In fact if I were to make it 
more restrictive, you would fork web2py.
- A major manufacturing corporation wanted to use web2py for the interface 
of an industrial robot. They asked me permission to do so. I told them the 
LGPL license gives them such permission. Their legal department asked for a 
custom agreement that explicitly allows them to do so. The contributor 
agreement gives me the right to write such custom agreement (the agreement 
is very much like this 
one: http://www.sencha.com/legal/sencha-commercial-software-license-agreement/)
- If there is any need to defend web2py in court, I have the right to do it.

Keep in mind that the "community" is not a legal entity. Every open source 
project is owed by somebody. And when it is not, it does not last much. RoR 
is owned by 37 Signals (a private company), Django is owned by the Django 
Foundation (and a foundation is not the same as the "community", it is a 
non-for-profit registered company).

I have considered giving the web2py right to a company or a foundation but, 
1) it would not change for the contributor agreement (it would just list a 
different legal entity as copyright holder). 2) it would be more expensive 
(a company costs $1000/year and a foundation about double). 3) a company or 
a foundation is more likely to go broke than I am as a person. What would 
happen to the legal rights on web2py in that case?

The legal agreement says you do not worry about all of this. I do. 

Massimo


On Wednesday, 11 July 2012 05:41:37 UTC-5, Rhys wrote:
>
> Hey Everyone,
>
> I have a few questions about the contributors agreement. I've gotten to 
> that point where I would like to contribute where I can, but there are 
> somethings which are rattling around in my head. 
>
> When this agreement states 'I' or 'me' who or what is that exactly. The 
> reason I ask is because of section 2 condition 4:
>
> *you agree that I may register a copyright in your contribution and 
> exercise all ownership rights associated with it;*
>
> If I create something which is fantastic say, I don't want an individual 
> to own it, only the project/foundation. As a result the copyright is 
> remains with the project not an individual.  I'm trying to really find out 
> where does the buck stop. Is this project a single entity which supports 
> it's contributors as no one is given full rights, or is it one individual 
> who is given rights for others intellectual property around a project?
>
> No offence Massimo, but I'm a little bit confused because your name is on 
> every bit of copyright around web2py I've seen. What is stopping you taking 
> out a copyright where you own entire rights so if it can be sold you can 
> take the money and run?
>
> I understand why you have these, yet that is a bold condition which I'm 
> having trouble making it clear. If someone could make it clearer by showing 
> somewhere in the agreement removes such ownership of one individual I'll 
> sign it straight away. Maybe I've missed something?
>
> Cheers,
>
> Rhys
>


Re: [web2py] Re: Vanity URLs

2012-07-11 Thread Massimo Di Pierro
Are you sure you are sing web2py trunk? Earlier version do not support the 
404->

On Wednesday, 11 July 2012 09:24:03 UTC-5, Sushant Taneja wrote:
>
> Yes, sure. I have attached my routes.py with this reply.
>
> On Wednesday, July 11, 2012 7:49:12 PM UTC+5:30, Massimo Di Pierro wrote:
>>
>> Can I see your full routes?
>>
>> On Wednesday, 11 July 2012 02:26:04 UTC-5, Sushant Taneja wrote:
>>>
>>> I wrote the below line in routes.py. But I am getting a server response 
>>> of 400 instead of 404.
>>>
>>> INFO 2012-07-11 07:21:03,242 dev_appserver.py:2952] "GET /staneja 
>>> HTTP/1.1" 400 -
>>>
>>> So I tried after changing 404 to 400 but it is still the same. No 
>>> redirection or request for the target URL is made.
>>>
>>> What might be causing the problem ?
>>>
>>> I am using web2py 1.99.7 and running it on GAE dev_appserver (localhost)
>>>
>>> On Sunday, July 8, 2012 7:34:47 AM UTC+5:30, Massimo Di Pierro wrote:

 It can be done already

 ('/$anything','404->/myapp/default/catchall/$anything')

 On Saturday, 7 July 2012 18:25:25 UTC-5, pbreit wrote:
>
> I wonder if we should try to support this formally. Perhaps if as a 
> "catchall" if the router doesn't find any valid routes and before it 
> returns a 404?



Re: [web2py] Re: Vanity URLs

2012-07-11 Thread pbreit
I guess this is the key line:
('/$anything','404->/devekayan/view/user/$anything')

That would require a controller file called "view.py" and a function "def 
user():"


[web2py] Re: postgres connect problem

2012-07-11 Thread Massimo Di Pierro
Not sure but I am sure this issue was fixed in trunk.

On Wednesday, 11 July 2012 03:40:55 UTC-5, lucas wrote:
>
> hello one and all,
>
> i have web2py 1.99.7 under centos 6.2 with postgres 9.1.  i am trying to 
> connect to postgres using the standard:
>
> db = DAL('postgres://postgres:password@localhost/testbank')
>
> but it does not connect properly.  i added the "self." under the dal.py 
> file to ensure that line looks like:
>
> self.driver = self.drivers.get('pg8000')
>
> and deleted the dal.pyc and made sure it was recreated with a new 
> date/time stamp.  the error i still get is:
>
> Traceback (most recent call last):
>   File "/opt/web-apps/web2py/gluon/dal.py", line 5955, in __init__
> self._adapter = ADAPTERS[self._dbname](*args)
>   File "/opt/web-apps/web2py/gluon/dal.py", line 1999, in __init__
> self.driver = self.drivers.get('pg8000')
> AttributeError: 'list' object has no attribute 'get'
>
>
> postgres is running but it will not connect.  any ideas?
>
> lucas
>
>
>
>

Re: [web2py] Re: Website/Sqlite Backup

2012-07-11 Thread Massimo Di Pierro
You are right.

On Wednesday, 11 July 2012 09:47:17 UTC-5, Jonathan Lundell wrote:
>
> On 11 Jul 2012, at 7:25 AM, Massimo Di Pierro wrote:
>
> If you pay the $100, dropbox has a 6month restore. I do not know if it 
> will save all the versions of the file, or only some snapshot.
>
>
> I wouldn't count on dropbox to safely back up a live sqlite database, for 
> the same reason you can't simply copy the file: you might get the database 
> in an inconsistent state. Use the sqlite3 .backup command instead to take a 
> snapshot. Send its output to a dropbox folder if you like.
>
>
> On Wednesday, 11 July 2012 03:16:29 UTC-5, villas wrote:
>>
>> Hi All,
>> I'm looking for any easy way to backup small websites which use Sqlite.  
>> I found an interesting suggestion from Massimo:
>>
>> >> Put web2py in a dropbox folder! Once a day hg commit the entire folder.
>>  
>>
>> That sounds good,  but would it make a safe copy of the data?  
>>
>> In any case, does anyone have other ideas?
>>
>> Regards, David
>
>
>
>

Re: [web2py] Re: Vanity URLs

2012-07-11 Thread Sushant Taneja
Oh... that might be the problem since I am not using the source from the 
trunk. I am using the current stable version 1.99.7 available at :
http://www.web2py.com/examples/default/download



On Wednesday, July 11, 2012 10:12:28 PM UTC+5:30, Massimo Di Pierro wrote:
>
> Are you sure you are sing web2py trunk? Earlier version do not support the 
> 404->
>
> On Wednesday, 11 July 2012 09:24:03 UTC-5, Sushant Taneja wrote:
>>
>> Yes, sure. I have attached my routes.py with this reply.
>>
>> On Wednesday, July 11, 2012 7:49:12 PM UTC+5:30, Massimo Di Pierro wrote:
>>>
>>> Can I see your full routes?
>>>
>>> On Wednesday, 11 July 2012 02:26:04 UTC-5, Sushant Taneja wrote:

 I wrote the below line in routes.py. But I am getting a server response 
 of 400 instead of 404.

 INFO 2012-07-11 07:21:03,242 dev_appserver.py:2952] "GET /staneja 
 HTTP/1.1" 400 -

 So I tried after changing 404 to 400 but it is still the same. No 
 redirection or request for the target URL is made.

 What might be causing the problem ?

 I am using web2py 1.99.7 and running it on GAE dev_appserver (localhost)

 On Sunday, July 8, 2012 7:34:47 AM UTC+5:30, Massimo Di Pierro wrote:
>
> It can be done already
>
> ('/$anything','404->/myapp/default/catchall/$anything')
>
> On Saturday, 7 July 2012 18:25:25 UTC-5, pbreit wrote:
>>
>> I wonder if we should try to support this formally. Perhaps if as a 
>> "catchall" if the router doesn't find any valid routes and before it 
>> returns a 404?
>
>

Re: [web2py] Re: Vanity URLs

2012-07-11 Thread Sushant Taneja
Yes, I have the controller with the name view.py and the function user

On Wednesday, July 11, 2012 10:14:17 PM UTC+5:30, pbreit wrote:
>
> I guess this is the key line:
> ('/$anything','404->/devekayan/view/user/$anything')
>
> That would require a controller file called "view.py" and a function "def 
> user():"
>


[web2py] Re: Any jquery gurus out there?

2012-07-11 Thread pbreit
Have you checked the Javascript console?

http://blogs.msdn.com/b/cbowen/archive/2011/06/24/internet-explorer-9-developer-tools-deep-dive-part-3-debugging-javascript.aspx


Re: [web2py] Re: Profile link

2012-07-11 Thread Anthony
Just to clarify, are you saying your profile page has a custom URL (i.e., 
something other than /default/user/profile), or that it simply has a custom 
view (i.e., you need to use a view other than the standard 
/views/default/user.html view)? If the latter, there are two options. 
First, rather than having a separate view file, you could add a condition 
to the user.html view that displays a custom view when request.args(0) == 
'profile'. The other option is specifying a custom view in the user() 
function:

def user():
if request.args(0) == 'profile':
response.view = 'default/profile.html'

Anthony

Thanks for the reply. That is my setup. The only edit I want is to change 
> the link on profile to point to my custom profile. Apart from that, I don't 
> want to edit any other function of the Auth system. Thanks. I kind a see 
> where it might be possible in gluon/tools.py, but I don't want to touch the 
> source code directly. I was hoping there was some settings I could alter. 
>
> I also did not want to create a custom navbar. However manipulating it 
> after it is generated seems an option. How do you do that to change the 
> link on the profile?
>
> Thanks.
>
> On Wed, Jul 11, 2012 at 10:31 AM, Anthony wrote:
>
>> The navbar assumes all the Auth actions are handled by the same function, 
>> with the action being specified via request.args[0]. If that's not your 
>> setup, then you'll have to create a custom navbar, or manipulate the navbar 
>> after it is generated.
>>
>> Anthony
>>
>>
>> On Wednesday, July 11, 2012 11:15:21 AM UTC-4, dundee wrote:
>>>
>>> Hi all,
>>>
>>> I have created a custom view for profile. However, I don't know where to 
>>> look to change the profile link (auth.navbar) to use my link.
>>>
>>> Thanks.
>>>
>>
>
>
> -- 
> Kevin Miller
> Acting Data Controller
> Department of Computing
> UWI, Mona
> Kingston 7
>


[web2py] Asyncronous Application Sync

2012-07-11 Thread Alfonso de la Guarda
Hi,


I have a web2py app in 2 places:
- City location
- Rainforest location

The app is the same for both cases, however the city app is the "main".

I need to synchronize the information entered in the location of the
jungle to the city but not bi-directionally due to low bandwidth, in
addition should be automatic as soon as there is availability of
connectivity (ie queue management / messaging).

Has anyone had experiences like this with web2py specifically? ( I can
surely work with rabbitmq, hornetmq, etc. but there is an approach for
web2py?)


Saludos,


Alfonso de la Guarda
Twitter: @alfonsodg
Redes sociales: alfonsodg
   Telef. 991935157
1024D/B23B24A4
5469 ED92 75A3 BBDB FD6B  58A5 54A1 851D B23B 24A4