[web2py] Re: request - mmodal examples

2011-07-18 Thread niknok
bump.

No takers? :s

On Jul 16, 8:23 am, niknok  wrote:
> I just "discovered" this modal plugin: web2py.com/plugins/default/
> mmodal
>
> Sorry for being a little slow, but would someone please post an
> example of how I can use crud inside modals?


[web2py] Re: Custom fields for each record????

2011-07-18 Thread Adi
I would do it in this way:

Let's say there are two tables building and room_detail. Let building
be

> > db.define_table('building',
> >     Field('name','string'),
> >     Field('comment', 'string'))

Let room_details be:

db.define_table('room_detail',
Field('detail_key', string),
Field('detail_value', string),
Field('building', db.building))

For every new information for a room, you can use a new record with a
distinct detail_key like 'name', 'owner', etc. Further, every
detail_key can be a value from a lookup table like
'room_detail_lookup' which contains the superset of all possible
detail_key values:

db.define_table('room_detail_lookup', Field('lookup_name', string))

OR use a validator in the room_detail table:

db.room_detail.detail_key.requires = IS_IN_SET(['OWNER', 'NAME',...])

Hope this helps.

On Jul 19, 12:19 am, Jonathan Lundell  wrote:
> On Jul 18, 2011, at 9:29 AM, Ismael Serratos wrote:
>
> > Hi!! How could I make custom fields for each record in a model, I mean:
>
> Seems like the answer depends on knowing more than we do about the apps 
> requirements.
>
> If you don't need direct SQL (eg search) access to the custom fields, you 
> could serialize an info dictionary into a blob in the room table.
>
> If you do need direct access, and all the info fields have the same type 
> (string, for example), then how about a roominfo table, with a key and a 
> value field, along with a room ID? Another buildinginfo table could contain 
> the info keys legal for each building.
>
>
>
>
>
>
>
>
>
> > I have:
>
> > db.define_table('building',
> >     Field('name','string'),
> >     Field('comment', 'string'))
>
> > db.define_table('room',
> >     Field('name','string'),
> >     Field('owner','string'),
> >     Field('building',db.building))
>
> > But every building need some extra info about each room, for example
>
> > Building1 needed info:
>
> > room.name room.owner room.building room.xinfo room.yinfo
>
> > Building 2 needed info:
>
> > room.name room.owner room.building room.ainfo room.binfo
>
> > etc, etc.
>
> > Basically following this structure:  
>
> > project                                   room                custom_attribs
> > -                                     -             
> > --
> > attrib_assoc_id    -->         id                  <--  assoc_id
> > ...                                      


[web2py] Re: form.errors problem.

2011-07-18 Thread annet
Replacing the flash with:


elif form2.errors:
print form2.errors

... and submitting the form prints this:




... which is odd, because it contains the same data as when I submit
the form after removing the autocomplete widget.


Any ideas?


Kind regards,

Annet.


[web2py] Re: jQuery .focus()

2011-07-18 Thread annet
Hi Chris,

Thanks for your reply. Problem solved and something learned.


Kind regards,

Annet.


[web2py] Still need help with jQuery - replacing div contents

2011-07-18 Thread Cliff
I would be extremely grateful if somebody were to point me in the
right direction here.

When I use jQuery :eval to update div contents, the browser shows me
the updated contents as expected.

However, when I look at the source code, I see the old contents.  I
think this is causing a problem, because buttons embedded in the div
no longer work.

For example, I could have a table like this:

First rowDelete it
Second rowDelete it


I would have a jQuery event set to trigger on click for buttons of
class "delete_it."   The event sends ajax to the server to delete a
row in a linking table.  Then the called server side function returns
a jQuery command to reload div that contains the table.

On first page load, if I click the "Delete it" button in the first
row, everything appears to work. The row in the linking table gets
deleted and the browser appears to reload the table with the first row
absent.  Except all is not well.

If I then click the Delete it button in row 2, it no longer works.
The click no longer fires.  If I look at the page source, the first
row is still there.

I suspect jQuery thinks the page is still in the state it was when
document.ready() first fired at page load time.  How can I tell jQuery
to refresh its view of the document without refreshing the whole page?


Re: [web2py] Re: CRON or Background script?

2011-07-18 Thread Ismael Serratos
I tried putting it into a controller, also as a separated file into private
folder




On Mon, Jul 18, 2011 at 8:36 PM, pbreit  wrote:

> Where is this code located and how are you calling it? If it's in a
> controller, you may need to call bookings() with an argument.
>
> Did you review this:
>
> http://web2py.com/book/default/chapter/04?#Background-Processes-and-Task-Queues
>


[web2py] Re: SQLFORM with divs or ordered lists instead of tables (for easier control with CSS)

2011-07-18 Thread Anthony
See the 'formstyle' argument: 
http://web2py.com/book/default/chapter/07?search=formstyle

On Monday, July 18, 2011 11:04:10 PM UTC-4, Luis Goncalves wrote:

>
> Tables are hard to control in CSS, is there a way to have SQLFORM use divs 
> or lists instead?
>
> I have seen many(!) posts about redefining SQLFORM and making it more 
> flexible, but I'm not sure if any conclusion has been reached.
>
> Thanks,
> Luis.
>
>
>

[web2py] SQLFORM with divs or ordered lists instead of tables (for easier control with CSS)

2011-07-18 Thread Luis Goncalves

Tables are hard to control in CSS, is there a way to have SQLFORM use divs 
or lists instead?

I have seen many(!) posts about redefining SQLFORM and making it more 
flexible, but I'm not sure if any conclusion has been reached.

Thanks,
Luis.




Re: [web2py] Oh Noes! template parsing conflict!

2011-07-18 Thread Anthony
I'm not sure you can pass 'delimiters' to response.render() -- you might 
have to follow this method: 
https://groups.google.com/d/topic/web2py/4IFFE-7vq1I/discussion.
 
Anthony

On Monday, July 18, 2011 9:29:01 PM UTC-4, elffikk wrote:

> you can change template delimiters 
>
> in controller
> def myf():
> return response.render('myf.html', delimiters=('{%','%}')) 
>
> now you can use python code in myf.html 
>
> {%if True:%}It works! {%pass%}
>


[web2py] Re: CRON or Background script?

2011-07-18 Thread pbreit
Where is this code located and how are you calling it? If it's in a 
controller, you may need to call bookings() with an argument.

Did you review this:
http://web2py.com/book/default/chapter/04?#Background-Processes-and-Task-Queues


Re: [web2py] Oh Noes! template parsing conflict!

2011-07-18 Thread Vasile Ermicioi
you can change template delimiters

in controller
def myf():
return response.render('myf.html', delimiters=('{%','%}'))

now you can use python code in myf.html

{%if True:%}It works! {%pass%}


[web2py] Oh Noes! template parsing conflict!

2011-07-18 Thread blackthorne
While editing a javascript code to adapt the behavior of an addthis
button I got something unexpected...
Checkout this JS code and thing about web2py template code:
var addthis_share = {
  templates: { twitter: 'check out {{title}} @ {{url}}' }
}


First try:
  templates: { twitter: 'check out '{{="{{title}} @ {{url}}"}}' }

if real parsing was going on here, this should work but probably the
template engine just uses regular expressions to find the ending
{{ mark after the beginning {{ and ignores everything else. So, it is
a fail...

Second try:
  templates: { twitter: 'check out
'{{=chr(123)+chr(123)+'title'+chr(125)+chr(125)+' @
'+chr(123)+chr(123)+'url'+chr(125)+chr(125)}}' }

ok, this is sort of hacking the own framework but it works. It's ugly
but it works

Can we make it prettier without throwing this to a javascript file?


[web2py] Re: Can't get linkto working in SQLFORM

2011-07-18 Thread tcab
Ok - added issue as http://code.google.com/p/web2py/issues/detail?id=340

On Jul 15, 9:45 am, Anthony  wrote:
> Please submit an issue on Google 
> Code:http://code.google.com/p/web2py/issues/list
>
>
>
>
>
>
>
> On Friday, July 15, 2011 1:33:22 AM UTC-4, tcab wrote:
> > I get this too - a spurious "list_records." prepended to the query.
> > Latest web2py 1.97.1
>
> > -Andy
>
> > On Jul 12, 10:08 pm, jc  wrote:
> > > Hi,
> > > Trying to use linkto, so following example in web2py book<
> >http://www.web2py.com/book/default/chapter/07#Links-to-Referencing-Re...>
> > first,
> > > to try to understand.
>
> > > I have copied the example with person and dog tables, in particular in
> > def
> > > display_form(): I have
>
> > > link = URL('list_records')
> > > form = SQLFORM(db.person, record, deletable=True,
> > >                   upload=url, linkto=link, labels = {'dog.owner':"This
> > > person's dogs"})
>
> > > as described in the book.
>
> > > The books says the link generated will be
> > > "/test/default/list_records/dog?query=dog.owner%3D5" but in fact the link
>
> > > which appears when I visit /test/default/display_form/1 is
> > >  "/test/default/list_records/dog?query=list_records.dog.owner%3D%3D1",
> > i.e.
> > > there is a spurious list.records and a spurious %3D. Not surprisingly the
>
> > > link doesn't work. Can anybody tell me what I am doing wrong?
>
> > > Thanks.


[web2py] Re: A(cid=request.cid) inside a component inside another component ? bug or working as expected ?

2011-07-18 Thread Anthony
On Monday, July 18, 2011 3:18:44 PM UTC-4, sebastian wrote: 
>
> H All,
>
> there is a component COMP_OUT which has a couple of A links with 
> cid=request.cid. So that the result of A will be loaded inside the component 
> itself.
>
> then there is another component COMP_IN which also has also some A links 
> with cid=request.cid
>
> so far so good...
>
> now, I would like to use the component COMP_IN inside of the component 
> COMP_OUT at this point there are cid conflicts and responses of the 
> links (A) of the COMP_OUT are rendered in the wrong places (removing COMP_IN 
> the links work again)

 
Where are the COMP_OUT links rendering? They should be replacing the entire 
contents of COMP_OUT. Are you saying instead they are only replacing the 
contents of COMP_IN, or is the content going somewhere else?
 
Are both of the components set to ajax=True?
 

>
> Is it a A(cid=request.cid) limitation or it is a bug ?
>
> (actually in the code I'm using 
> cid=request.env.http_web2py_component_elemen)

 
Is this just a typo in your posting -- it should end with "element" (not 
"elemen")?
 
Maybe try specifying specific targets for each component, and reference 
those target names in your A() links to see if that works. For example:
 
LOAD(..., target='outer')
A(..., cid='outer')
 
and
 
LOAD(..., target='inner')
A(..., cid='inner'
 
 
Anthony


Re: [web2py] Attn: jQuery ajax noobies: don't fall into this trap

2011-07-18 Thread Anthony
On Monday, July 18, 2011 4:28:51 PM UTC-4, David J wrote:

> Cliff thanks for the heads up 
>
> Except I am not sure what :eval means in that context.
>
The third argument to the ajax() function is 'target', which is the div 
where the returned response should be loaded. However, if target=':eval', it 
will instead assume the response is Javascript, and it will eval() the 
Javascript code. See http://web2py.com/book/default/chapter/10#Eval-target.
 
Anthony
 



[web2py] Re: mapreduce.appspot.com

2011-07-18 Thread Rip Ryness
I don't think there is a way to use the DAL with mapreduce.  When I used 
mapreduce I did it completely outside of the DAL which was a bit of a 
learning curve but wasn't too bad.

The plus side is you get a bit leaner process.

-Rip


[web2py] Re: proper way to mobile and desktop 'skins'

2011-07-18 Thread Luis Goncalves
I've been away to conferences and somehow missed these replies!

Thank you all for the replies!

I send the same content, so in principle CSS definitions should be able to 
restyle satisfactorily.

I actually found two books that seem quite helpful: by Jonathan Stark, 
published by O'Reilly, "Building iPhone apps with HTML, CSS, and JavaScript 
without ObjectiveC or Cocoa", and "Building Android apps with HTML, CSS, and 
JavaScript".   The two books are very similar, and they describe a way to 
create native apps by way of creating a webapp and using PhoneGap.  (We are 
happy enough just having a web app that looks good!!!).

Thanks!!
L.  


Re: [web2py] Attn: jQuery ajax noobies: don't fall into this trap

2011-07-18 Thread David J.

Cliff thanks for the heads up

Except I am not sure what :eval means in that context.

Thanks.



On 7/18/11 4:10 PM, Cliff wrote:

Notice the ':eval' as the last parameter to the ajax call.

ajax('{{=URL('revive_parrot')}}', ['dead_parrot_id'], ':eval')

If 'revive_parrot' ends with the following it will not work because
the call to set the html chokes on the newlines.

return '''jQuery('#parrot_state').html("bla bla
bla bla")'''

This will work.

out = '''jQuery('#parrot_state').html("bla bla
bla bla")'''
return out.replace("\n", '')

Don't ask me how long it took this 'experienced programmer' to find
this out.






Re: [web2py] Re: DAL: query sorted by calculated column ?

2011-07-18 Thread Sebastian E. Ovide
perfect, thanks cfh !

On Sun, Jul 17, 2011 at 10:45 PM, howesc  wrote:

> i see 2 options:
>
> db.define_table('tabletest',  Field('yes', 'integer'), Field('no',
> 'integer'), Field('tot', 'integer', compute=lambda r:r.yes-r.no))
>
> will compute the value upon write and store it in the db, sort like any
> other field.
>
> or
>
> db.define_table('tabletest',  Field('yes', 'integer'), Field('no',
> 'integer'))
>
> class vf():
>   def tot(self):
> return self.tabletest.yes-self.tabletest.no
>
> db.tabletest.virtualfields.append(vf)
>
> will create a virtual field that is computed on read.  to sort by the
> virtual field you can:
>
> db(db.tabletest.id>0).select().sort(lambda r: r.tot)
>
> hope that helps.  (i did not test my code, just typed quickly, beware of
> typos)
>
> cfh
>



-- 
Sebastian E. Ovide


[web2py] Attn: jQuery ajax noobies: don't fall into this trap

2011-07-18 Thread Cliff
Notice the ':eval' as the last parameter to the ajax call.

ajax('{{=URL('revive_parrot')}}', ['dead_parrot_id'], ':eval')

If 'revive_parrot' ends with the following it will not work because
the call to set the html chokes on the newlines.

return '''jQuery('#parrot_state').html("bla bla
bla bla")'''

This will work.

out = '''jQuery('#parrot_state').html("bla bla
bla bla")'''
return out.replace("\n", '')

Don't ask me how long it took this 'experienced programmer' to find
this out.



Re: [web2py] Custom fields for each record????

2011-07-18 Thread Jonathan Lundell
On Jul 18, 2011, at 9:29 AM, Ismael Serratos wrote:
> Hi!! How could I make custom fields for each record in a model, I mean:

Seems like the answer depends on knowing more than we do about the apps 
requirements.

If you don't need direct SQL (eg search) access to the custom fields, you could 
serialize an info dictionary into a blob in the room table.

If you do need direct access, and all the info fields have the same type 
(string, for example), then how about a roominfo table, with a key and a value 
field, along with a room ID? Another buildinginfo table could contain the info 
keys legal for each building.

> 
> I have:
> 
> db.define_table('building',
> Field('name','string'),
> Field('comment', 'string'))
> 
> db.define_table('room',
> Field('name','string'),
> Field('owner','string'),
> Field('building',db.building))
> 
> 
> But every building need some extra info about each room, for example
> 
> Building1 needed info:
> 
> room.name room.owner room.building room.xinfo room.yinfo
> 
> 
> Building 2 needed info:
> 
> room.name room.owner room.building room.ainfo room.binfo
> 
> etc, etc.
> 
> 
> Basically following this structure:  
> 
> 
> project   roomcustom_attribs
> - - 
> --
> attrib_assoc_id--> id  <--  assoc_id
> ...  
> 
> 
>
> 




[web2py] A(cid=request.cid) inside a component inside another component ? bug or working as expected ?

2011-07-18 Thread Sebastian E. Ovide
H All,

there is a component COMP_OUT which has a couple of A links with
cid=request.cid. So that the result of A will be loaded inside the component
itself.

then there is another component COMP_IN which also has also some A links
with cid=request.cid

so far so good...

now, I would like to use the component COMP_IN inside of the component
COMP_OUT at this point there are cid conflicts and responses of the
links (A) of the COMP_OUT are rendered in the wrong places (removing COMP_IN
the links work again)

Is it a A(cid=request.cid) limitation or it is a bug ?

(actually in the code I'm using
cid=request.env.http_web2py_component_elemen)

thanks

-- 
Sebastian E. Ovide


[web2py] CRON or Background script?

2011-07-18 Thread Ismael Serratos
hi! I need to run this


import time
def bookings():

import datetime

allBookings = db(db.current_bookings).select()
db.commit()

for booking in allBookings:
if booking.enddate >= datetime.datetime.now():
buildingName = booking.project
room= booking.platform

table = getattr(db, '%s'%buildingName )

toUpdate = db(table.id == room).select()
db.commit()

for t in toUpdate:
t.update_record(room_owner = 'Free')
db.commit()

booking.delete()

db.commit()

else:
pass


while True:
 bookings()
 time.sleep(1)





as a background service, I tried with cron (nothing happened) could you tell
me if is something wrong with my script?? or how should I run it?? as a
command line script?? or via cron??


Re: [web2py] powertable ( multiple tables on the same page )

2011-07-18 Thread Roberto Perdomo
I now discover that only show the details only for the first 10 records.

I send you to your mail my app, because is very hevy for the group mail.

2011/7/18 Bruno Rocha 

> include ownTable._id = "something" and ownTable._class = "something" to set
> different class and id to the tables.
>
>
>
> On Mon, Jul 18, 2011 at 12:57 PM, Chris Baron wrote:
>
>> How do you do it ?
>>
>>
>> Here is my controller :
>>
>>
>> ownDataSource = db( db.gtree.contributor == '
>> '.join( [ auth.user.first_name, auth.user.last_name ] ) ).select()
>>
>>class ownVirtualFields(object):
>>@virtualsettings(label='Tree')
>>def tree_url(self):
>>gtree = self.gtree.id
>>u = URL(c="gtree",f="view",args=self.gtree.id,
>> vars=dict(treeType='grafted'))
>>return A('grafted', _href=u)
>>
>>ownTable = plugins.powerTable
>>ownTable.datasource = ownDataSource
>>ownTable.dtfeatures["sScrollY"] = "200px"
>>ownTable.dtfeatures["sScrollX"] = "100%"
>>ownTable.virtualfields = ownVirtualFields()
>>ownTable.headers = "labels"
>>ownTable.showkeycolumn = False
>>ownTable.dtfeatures["bJQueryUI"] =
>> request.vars.get("jqueryui",True)
>>## ownTable.uitheme = request.vars.get("theme","cupertino")
>>ownTable.uitheme = request.vars.get("theme","smoothness")
>>ownTable.dtfeatures["iDisplayLength"] = 25
>>ownTable.dtfeatures["aaSorting"] = [[6,'desc']]
>>ownTable.dtfeatures["sPaginationType"] = request.vars.get(
>>"pager","full_numbers"
>>) # two_button scrolling
>>ownTable.columns = ["gtree.id",
>>  "virtual.tree_url",
>>  "gtree.mtime",
>>  "gtree.title",
>>  "gtree.comment" ]
>>
>>ownTable.extra = dict(autoresize=True)
>>
>>
>>
>>uniqueUserId = db( db.user_map.auth_user_id ==
>> auth.user.id ).select()[0].unique_user_id
>>
>>shareDataSource = db( ( db.gtree.id == db.gtree_share.gtree ) &
>>  ( db.gtree_share.user ==
>> uniqueUserId ) ).select()
>>
>>class shareVirtualFields(object):
>>@virtualsettings(label='Tree')
>>def tree_url(self):
>>gtree = self.gtree.id
>>u = URL(c="gtree",f="view",args=self.gtree.id,
>> vars=dict(treeType='grafted'))
>>return A('grafted', _href=u)
>> shareTable = plugins.powerTable
>>shareTable.datasource = shareDataSource
>>shareTable.dtfeatures["sScrollY"] = "200px"
>>shareTable.dtfeatures["sScrollX"] = "100%"
>>shareTable.virtualfields = shareVirtualFields()
>>shareTable.headers = "labels"
>>shareTable.showkeycolumn = False
>>shareTable.dtfeatures["bJQueryUI"] =
>> request.vars.get("jqueryui",True)
>>## shareTable.uitheme = request.vars.get("theme","cupertino")
>>shareTable.uitheme = request.vars.get("theme","smoothness")
>>shareTable.dtfeatures["iDisplayLength"] = 25
>>shareTable.dtfeatures["aaSorting"] = [[6,'desc']]
>>shareTable.dtfeatures["sPaginationType"] = request.vars.get(
>>"pager","full_numbers"
>>) # two_button scrolling
>>shareTable.columns = ["gtree.id",
>>  "virtual.tree_url",
>>  "gtree.mtime",
>>  "gtree.title",
>>  "gtree.comment" ]
>>
>>shareTable.extra = dict(autoresize=True)
>>
>>return dict( ownedByUser = ownTable.create(), sharedWithUser =
>> ownTable.create() )
>>
>>
>>
>> Here is my view :
>>
>> 
>>
>>
>>Grafted Tables You Own
>>{{=ownedByUser}}
>>
>>
>>
>>Grafted Tables Shared With You
>>{{=sharedWithUser}}
>>
>>
>>
>> 
>
>
>
>
> --
>
>
>
> --
> Bruno Rocha
> [ About me: http://zerp.ly/rochacbruno ]
> [ Aprenda a programar: http://CursoDePython.com.br ]
> [ O seu aliado nos cuidados com os animais: http://AnimalSystem.com.br ]
> [ Consultoria em desenvolvimento web: http://www.blouweb.com ]
>
>


[web2py] Availablity Calendar Requirement

2011-07-18 Thread IK
Hi all,

This is my first post. I've been playing with web2py for few months now. 
After trying out number of other frameworks, I decided to build my app with 
web2py because of known reasons, it rocks :) 

Although, I have number of years of experience with html, css and to some 
extent php, this is my first project using python and jquery. Python side is 
working out fine but with jquery (AJAX) is causing me some grief.

My app requires availability calendar, I already used this solution 
http://www.ajaxavailabilitycalendar.com/ (built with mootools, php)  for 
other projects and it is closest open source solution which meets my 
requirements. here is demo:

ww.ajaxavailabilitycalendar.com/demo 

and admin demo:

http://www.ajaxavailabilitycalendar.com/calendar/ac-admin/.

To chance it and go with easy route, did anybody built something similar, or 
if not, would anybody be interested building this app/plugin for web2py? :)

I was searching trough previous posts and couldn't find examples which would 
help me. In one older post there was reference to booking.w2p but this app 
is no longer available on web2py.com site (I guess it was superseded by 
appointment app).

I will have to build something similar either way, but it will take me much 
longer, due to my newbie status, so if you have any suggestion or pointers 
how to start with this please let me know.

In brief these functionalities are required (model is below).

1. How to display jquery calendar (e.g pop up calendar) as inline calendar 
without visible  input form field (3 months or 12 months view). something 
like this http://jqueryui.com/demos/datepicker/#inline
2. When view is loaded, app should query db; table listing_item with id as 
criteria (sent through args[0]) and auth.user; display marked dates in 
in-line calendar (or other better method). I could probably build this 
function my self but again, integration with jquery is the problem for me)
3. how to use ajax to create/update database records with onclick events 
(multiple onclick on single date in calendar should change record in state 
field in booking table which is looping through all the field states in 
booking_states table)? non-existing db record, for particular date, will use 
create and existing record, for particular date, will use update (crud or 
SQLForm...)
4.  view one: with above features, so read/write for listing_item for 
auth.user
5. view two: displaying read only calendar populated with records from db 
(depending on listing_item.id)
6 generally every booking entry will be whole day event, (based on 
booking_state.class_name), 

If anybody could provide examples for first three points, it would help me 
alot.

Let say this is the model (might have mistakes - just a concept for now, 
database structure is inspired by above mentioned open source project)

db.define_table("booking_state",
Field('name',type='string',length=64, label="Booking State"),
Field('code',type='string',length=64, label="Booking Code"),
Field('active',type='boolean', label="Active",default=1),
Field('class_name', type='string', length=30), 
format="%(name)s")
db.booking_state.name.requires = IS_NOT_IN_DB(db,"booking_state.name")


booking state CSV
booking_state.idbooking_state.namebooking_state.code
booking_state.activebooking_state.class_name
1Bookedb1booked
2Booked amb_am1booked_am
3Booked pmb_pm1booked_pm
4Provisionalpr1booked_pr
5Provisional ampr_am1booked_pr_am
6Provisional pmpr_pm1booked_pr_pm
7Change Over Day1changeover
8Special Offer1offer


db.define_table("booking",
Field('listing',db.listing_item, label="Listing ID"),
Field('state',db.booking_state),
Field('sortable',type="integer", default),
Field('the_date',type='date', widget=date_widget, label="The Date"),  
##I was only playing with date widget, not required
Field('posted_by',db.auth_user,writable=False))
   
db.booking.state.requires = IS_IN_DB(db,"booking_state.id","%(name)s")
db.booking.posted_by.default = auth.user.id if auth.user else 0



db.define_table("listing_item",
Field('title',length=128),
Field('body',type='text'),
Field('posted_on','datetime',writable=False),
Field('posted_by',db.auth_user,writable=False),
Field('client',default=request.client,writable=False,readable=False))

db.listing_item.title.requires = [IS_NOT_EMPTY(), 
IS_NOT_IN_DB(db,'listing_item.title')]
db.listing_item.posted_by.default = auth.user.id if auth.user else 0
db.listing_item.posted_by.writable = 
db.listing_item.posted_by.readable=False
db.listing_item.title.requires = IS_LENGTH(minsize=3, maxsize=128)
db.listing_item.body.requires = IS_LENGTH(minsize=10)



Thanks and regards,
Ivica

 
 


Re: [web2py] Re: Load view or controllers without load

2011-07-18 Thread Roberto Perdomo
Bruno, finally i fix that, changing "live" to "bind" in
plugin_powertable.py.

If you consideer update the plugin code to fix this error.

Thanks you so much.

2011/7/18 apple 

> If you have multiple tables then you must give each table a unique id.
>
> Bruno tells me this can be done in web2py controller:
>table = plugins.PowerTable
>table._id = "mytable1"
>
> On Jul 18, 3:31 am, Roberto Perdomo  wrote:
> > Hi, i have problems loading powertables with LOAD and I wonder if
> > there is a way
> > to get from one view to another controller without using LOAD or view as
> > hereby POWERTABLES tables do not work properly.
> >
> > Mainly I like to charge two or three tables from a controller in a view.
> >
> > thanks in advance
>


Re: [web2py] Re: view for email message

2011-07-18 Thread Nicolas Palumbo
for emails I used this, that allows you to place emails templates as views...
quite useful 
http://wiki.web2py.com/Sending_Email_with_Plain_Text_HTML_Versions_plus_Attachments

On Mon, Jul 18, 2011 at 3:23 PM, Anthony  wrote:
> If you want to call the function from another function in the same
> controller, you could do something like this:
>
> def message():
>     # Code to create variables needed for output.
>     return dict(var1=...,var2=...,etc.)
>
> def mail_sender():
>     # Call the message() function and render its output using the
> message.email view.
>     email_content=response.render('default/message.email', message())
>     # Code to send the email message.
>     return # whatever this function should return
>
>
> If you need to call message() from somewhere else, you could move the part
> of the code that generates the variables for the output to a module or maybe
> a model. Or you could try using urllib2.urlopen() or the web2py fetch()
> function (see
> http://web2py.com/book/default/chapter/12#Fetching-an-external-URL). Just
> create a message.email view and use the .email extension when calling the
> URL.
>
> Anthony
>
> On Monday, July 18, 2011 5:47:31 AM UTC-4, Manuele wrote:
>>
>> hi *,
>>
>> I woulld like to reuse a controller function with a different view to
>> get an html message to send via email... how is it possible?
>>
>> Is there a way from python code to get the html text that is returned
>> when a browser call an url that correspond to my controller "dressed" by
>> my view with the same name of my controller and, for example, with
>> .email extension?
>>
>> many thanks
>>
>> Manuele
>


[web2py] Re: powertable ( multiple tables on the same page )

2011-07-18 Thread Chris Baron
Thanks! - I appreciate the help.

However, now I'm receiving a javascript error : "Cannot read property
'aoColumns' of null"

On Jul 18, 11:34 am, Bruno Rocha  wrote:
> include ownTable._id = "something" and ownTable._class = "something" to set
> different class and id to the tables.
>
> On Mon, Jul 18, 2011 at 12:57 PM, Chris Baron wrote:
>
>
>
>
>
>
>
>
>
> > How do you do it ?
>
> > Here is my controller :
>
> > ownDataSource = db( db.gtree.contributor == '
> > '.join( [ auth.user.first_name, auth.user.last_name ] ) ).select()
>
> >    class ownVirtualFields(object):
> >        @virtualsettings(label='Tree')
> >        def tree_url(self):
> >            gtree = self.gtree.id
> >            u = URL(c="gtree",f="view",args=self.gtree.id,
> > vars=dict(treeType='grafted'))
> >            return A('grafted', _href=u)
>
> >    ownTable = plugins.powerTable
> >    ownTable.datasource = ownDataSource
> >    ownTable.dtfeatures["sScrollY"] = "200px"
> >    ownTable.dtfeatures["sScrollX"] = "100%"
> >    ownTable.virtualfields = ownVirtualFields()
> >    ownTable.headers = "labels"
> >    ownTable.showkeycolumn = False
> >    ownTable.dtfeatures["bJQueryUI"] =
> > request.vars.get("jqueryui",True)
> >    ## ownTable.uitheme = request.vars.get("theme","cupertino")
> >    ownTable.uitheme = request.vars.get("theme","smoothness")
> >    ownTable.dtfeatures["iDisplayLength"] = 25
> >    ownTable.dtfeatures["aaSorting"] = [[6,'desc']]
> >    ownTable.dtfeatures["sPaginationType"] = request.vars.get(
> >        "pager","full_numbers"
> >        ) # two_button scrolling
> >    ownTable.columns = ["gtree.id",
> >                          "virtual.tree_url",
> >                          "gtree.mtime",
> >                          "gtree.title",
> >                          "gtree.comment" ]
>
> >    ownTable.extra = dict(autoresize=True)
>
> >    
>
> >    uniqueUserId = db( db.user_map.auth_user_id ==
> > auth.user.id ).select()[0].unique_user_id
>
> >    shareDataSource = db( ( db.gtree.id == db.gtree_share.gtree ) &
> >                          ( db.gtree_share.user ==
> > uniqueUserId ) ).select()
>
> >    class shareVirtualFields(object):
> >        @virtualsettings(label='Tree')
> >        def tree_url(self):
> >            gtree = self.gtree.id
> >            u = URL(c="gtree",f="view",args=self.gtree.id,
> > vars=dict(treeType='grafted'))
> >            return A('grafted', _href=u)
> > shareTable = plugins.powerTable
> >    shareTable.datasource = shareDataSource
> >    shareTable.dtfeatures["sScrollY"] = "200px"
> >    shareTable.dtfeatures["sScrollX"] = "100%"
> >    shareTable.virtualfields = shareVirtualFields()
> >    shareTable.headers = "labels"
> >    shareTable.showkeycolumn = False
> >    shareTable.dtfeatures["bJQueryUI"] =
> > request.vars.get("jqueryui",True)
> >    ## shareTable.uitheme = request.vars.get("theme","cupertino")
> >    shareTable.uitheme = request.vars.get("theme","smoothness")
> >    shareTable.dtfeatures["iDisplayLength"] = 25
> >    shareTable.dtfeatures["aaSorting"] = [[6,'desc']]
> >    shareTable.dtfeatures["sPaginationType"] = request.vars.get(
> >        "pager","full_numbers"
> >        ) # two_button scrolling
> >    shareTable.columns = ["gtree.id",
> >                          "virtual.tree_url",
> >                          "gtree.mtime",
> >                          "gtree.title",
> >                          "gtree.comment" ]
>
> >    shareTable.extra = dict(autoresize=True)
>
> >    return dict( ownedByUser = ownTable.create(), sharedWithUser =
> > ownTable.create() )
>
> > Here is my view :
>
> > 
>
> >    
> >        Grafted Tables You Own
> >        {{=ownedByUser}}
> >    
>
> >    
> >        Grafted Tables Shared With You
> >        {{=sharedWithUser}}
> >    
>
> > 
>
> --
>
> --
> Bruno Rocha
> [ About me:http://zerp.ly/rochacbruno]
> [ Aprenda a programar:http://CursoDePython.com.br]
> [ O seu aliado nos cuidados com os animais:http://AnimalSystem.com.br]
> [ Consultoria em desenvolvimento web:http://www.blouweb.com]


Re: [web2py] powertable ( multiple tables on the same page )

2011-07-18 Thread Bruno Rocha
include ownTable._id = "something" and ownTable._class = "something" to set
different class and id to the tables.



On Mon, Jul 18, 2011 at 12:57 PM, Chris Baron wrote:

> How do you do it ?
>
>
> Here is my controller :
>
>
> ownDataSource = db( db.gtree.contributor == '
> '.join( [ auth.user.first_name, auth.user.last_name ] ) ).select()
>
>class ownVirtualFields(object):
>@virtualsettings(label='Tree')
>def tree_url(self):
>gtree = self.gtree.id
>u = URL(c="gtree",f="view",args=self.gtree.id,
> vars=dict(treeType='grafted'))
>return A('grafted', _href=u)
>
>ownTable = plugins.powerTable
>ownTable.datasource = ownDataSource
>ownTable.dtfeatures["sScrollY"] = "200px"
>ownTable.dtfeatures["sScrollX"] = "100%"
>ownTable.virtualfields = ownVirtualFields()
>ownTable.headers = "labels"
>ownTable.showkeycolumn = False
>ownTable.dtfeatures["bJQueryUI"] =
> request.vars.get("jqueryui",True)
>## ownTable.uitheme = request.vars.get("theme","cupertino")
>ownTable.uitheme = request.vars.get("theme","smoothness")
>ownTable.dtfeatures["iDisplayLength"] = 25
>ownTable.dtfeatures["aaSorting"] = [[6,'desc']]
>ownTable.dtfeatures["sPaginationType"] = request.vars.get(
>"pager","full_numbers"
>) # two_button scrolling
>ownTable.columns = ["gtree.id",
>  "virtual.tree_url",
>  "gtree.mtime",
>  "gtree.title",
>  "gtree.comment" ]
>
>ownTable.extra = dict(autoresize=True)
>
>
>
>uniqueUserId = db( db.user_map.auth_user_id ==
> auth.user.id ).select()[0].unique_user_id
>
>shareDataSource = db( ( db.gtree.id == db.gtree_share.gtree ) &
>  ( db.gtree_share.user ==
> uniqueUserId ) ).select()
>
>class shareVirtualFields(object):
>@virtualsettings(label='Tree')
>def tree_url(self):
>gtree = self.gtree.id
>u = URL(c="gtree",f="view",args=self.gtree.id,
> vars=dict(treeType='grafted'))
>return A('grafted', _href=u)
> shareTable = plugins.powerTable
>shareTable.datasource = shareDataSource
>shareTable.dtfeatures["sScrollY"] = "200px"
>shareTable.dtfeatures["sScrollX"] = "100%"
>shareTable.virtualfields = shareVirtualFields()
>shareTable.headers = "labels"
>shareTable.showkeycolumn = False
>shareTable.dtfeatures["bJQueryUI"] =
> request.vars.get("jqueryui",True)
>## shareTable.uitheme = request.vars.get("theme","cupertino")
>shareTable.uitheme = request.vars.get("theme","smoothness")
>shareTable.dtfeatures["iDisplayLength"] = 25
>shareTable.dtfeatures["aaSorting"] = [[6,'desc']]
>shareTable.dtfeatures["sPaginationType"] = request.vars.get(
>"pager","full_numbers"
>) # two_button scrolling
>shareTable.columns = ["gtree.id",
>  "virtual.tree_url",
>  "gtree.mtime",
>  "gtree.title",
>  "gtree.comment" ]
>
>shareTable.extra = dict(autoresize=True)
>
>return dict( ownedByUser = ownTable.create(), sharedWithUser =
> ownTable.create() )
>
>
>
> Here is my view :
>
> 
>
>
>Grafted Tables You Own
>{{=ownedByUser}}
>
>
>
>Grafted Tables Shared With You
>{{=sharedWithUser}}
>
>
>
> 




-- 



--
Bruno Rocha
[ About me: http://zerp.ly/rochacbruno ]
[ Aprenda a programar: http://CursoDePython.com.br ]
[ O seu aliado nos cuidados com os animais: http://AnimalSystem.com.br ]
[ Consultoria em desenvolvimento web: http://www.blouweb.com ]


[web2py] Custom fields for each record????

2011-07-18 Thread Ismael Serratos
Hi!! How could I make custom fields for each record in a model, I mean:

I have:

db.define_table('building',
Field('name','string'),
Field('comment', 'string'))

db.define_table('room',
Field('name','string'),
Field('owner','string'),
Field('building',db.building))


But every building need some extra info about each room, for example

Building1 needed info:

room.name room.owner room.building room.xinfo room.yinfo


Building 2 needed info:

room.name room.owner room.building room.ainfo room.binfo

etc, etc.


Basically following this structure:


project   roomcustom_attribs
- -
--
attrib_assoc_id--> id  <--  assoc_id
...


[web2py] Re: mail date

2011-07-18 Thread Anthony
Looks like mail.send() calls time.gmtime(). What happens if you do the 
following:
 
def time_test():
import time
return time.strftime("%a, %d %b %Y %H:%M:%S +", time.gmtime())
 
 
and go to the default/time_test URL -- do you get the correct time?
 
Anthony

On Monday, July 18, 2011 10:06:35 AM UTC-4, Manuele wrote:

> hi *, 
>
> a strange thing happens calling this controller function by the browser 
> with its direct url... the mail arrives with no time information so my 
> client sees it with the date 1/1/1970 1:00... any idea why? 
>
> is there a way at least to force the message date? 
>
> many thanks 
>
> PS
> I leave all the code but this function essentially has to write a table 
> with HTML so don't mind the msg assignment 
>
> Manuele 
>
> def send_mail_msg():
>  pannello_out=pannello()
>  panel_data = pannello_out['panel_data']
>  available_sites = pannello_out['available_sites'] 
>
>  a = [TH(' ')] + [TH(dates.num2date(d).strftime('%d/%m')) for d in 
> panel_data['x']] + [TH(' ')] 
>
>  c = list()
>  for site in available_sites:
>  b = list()
>  for i in panel_data['x']:
>  l = list()
>  for j in ['forecast_wind', 'measured_energy']:
>  try:
>  l.append(str(panel_data[site.site.id][j][str(i)]))
>  except:
>  l.append('np')
>  b.append(TD(l[0], BR(), l[1]))
>  x = [TD(site.site.full_name)] + b + 
> [TD(SiteMaxEnergy(site.power_curve.file_name, 
> power_curves_folder)*24/1000)]
>  c += [TR(*x, _valign="middle", _align="center")] 
>
>  msg = str(HTML(BODY(
>  TABLE(
>  TR(
>  TH("Sito"), TH("Energia prevista", BR(), "Energia 
> immessa", BR(), "(dove disponibile)", BR(), "[%]", _colspan="5"),
>  TH("Max produzione", BR(), "giornaliera", BR(), 
> "[MWh]"),
>  _valign="middle", _align="center"),
>  TR(*a, _valign="middle", _align="center"),
>  *c,
>  _cellpadding="0", _cellspacing="0", _border="1")
>  ), doctype='tag'))[4:] 
>
>  recipient_list = (
>  'm...@mail.org',
>  ) 
>
>  subject = 'ALERT %s' %(request.now.strftime('%d-%m-%Y %H:%M')) 
>
>  res = mail.send(to=recipient_list, subject=subject, message=(None, 
> msg)) 
>
>  return res
>
>  

[web2py] powertable ( multiple tables on the same page )

2011-07-18 Thread Chris Baron
How do you do it ?


Here is my controller :


ownDataSource = db( db.gtree.contributor == '
'.join( [ auth.user.first_name, auth.user.last_name ] ) ).select()

class ownVirtualFields(object):
@virtualsettings(label='Tree')
def tree_url(self):
gtree = self.gtree.id
u = URL(c="gtree",f="view",args=self.gtree.id,
vars=dict(treeType='grafted'))
return A('grafted', _href=u)

ownTable = plugins.powerTable
ownTable.datasource = ownDataSource
ownTable.dtfeatures["sScrollY"] = "200px"
ownTable.dtfeatures["sScrollX"] = "100%"
ownTable.virtualfields = ownVirtualFields()
ownTable.headers = "labels"
ownTable.showkeycolumn = False
ownTable.dtfeatures["bJQueryUI"] =
request.vars.get("jqueryui",True)
## ownTable.uitheme = request.vars.get("theme","cupertino")
ownTable.uitheme = request.vars.get("theme","smoothness")
ownTable.dtfeatures["iDisplayLength"] = 25
ownTable.dtfeatures["aaSorting"] = [[6,'desc']]
ownTable.dtfeatures["sPaginationType"] = request.vars.get(
"pager","full_numbers"
) # two_button scrolling
ownTable.columns = ["gtree.id",
  "virtual.tree_url",
  "gtree.mtime",
  "gtree.title",
  "gtree.comment" ]

ownTable.extra = dict(autoresize=True)



uniqueUserId = db( db.user_map.auth_user_id ==
auth.user.id ).select()[0].unique_user_id

shareDataSource = db( ( db.gtree.id == db.gtree_share.gtree ) &
  ( db.gtree_share.user ==
uniqueUserId ) ).select()

class shareVirtualFields(object):
@virtualsettings(label='Tree')
def tree_url(self):
gtree = self.gtree.id
u = URL(c="gtree",f="view",args=self.gtree.id,
vars=dict(treeType='grafted'))
return A('grafted', _href=u)
shareTable = plugins.powerTable
shareTable.datasource = shareDataSource
shareTable.dtfeatures["sScrollY"] = "200px"
shareTable.dtfeatures["sScrollX"] = "100%"
shareTable.virtualfields = shareVirtualFields()
shareTable.headers = "labels"
shareTable.showkeycolumn = False
shareTable.dtfeatures["bJQueryUI"] =
request.vars.get("jqueryui",True)
## shareTable.uitheme = request.vars.get("theme","cupertino")
shareTable.uitheme = request.vars.get("theme","smoothness")
shareTable.dtfeatures["iDisplayLength"] = 25
shareTable.dtfeatures["aaSorting"] = [[6,'desc']]
shareTable.dtfeatures["sPaginationType"] = request.vars.get(
"pager","full_numbers"
) # two_button scrolling
shareTable.columns = ["gtree.id",
  "virtual.tree_url",
  "gtree.mtime",
  "gtree.title",
  "gtree.comment" ]

shareTable.extra = dict(autoresize=True)

return dict( ownedByUser = ownTable.create(), sharedWithUser =
ownTable.create() )



Here is my view :




Grafted Tables You Own
{{=ownedByUser}}



Grafted Tables Shared With You
{{=sharedWithUser}}






[web2py] Re: view for email message

2011-07-18 Thread Anthony
If you want to call the function from another function in the same 
controller, you could do something like this:
 
def message():
# Code to create variables needed for output.
return dict(var1=...,var2=...,etc.)
 
def mail_sender():
# Call the message() function and render its output using the 
message.email view.
email_content=response.render('default/message.email', message())
# Code to send the email message.
return # whatever this function should return
 
 
If you need to call message() from somewhere else, you could move the part 
of the code that generates the variables for the output to a module or maybe 
a model. Or you could try using urllib2.urlopen() or the web2py fetch() 
function (see 
http://web2py.com/book/default/chapter/12#Fetching-an-external-URL). Just 
create a message.email view and use the .email extension when calling the 
URL.
 
Anthony
 

On Monday, July 18, 2011 5:47:31 AM UTC-4, Manuele wrote:

> hi *, 
>
> I woulld like to reuse a controller function with a different view to 
> get an html message to send via email... how is it possible? 
>
> Is there a way from python code to get the html text that is returned 
> when a browser call an url that correspond to my controller "dressed" by 
> my view with the same name of my controller and, for example, with 
> .email extension? 
>
> many thanks 
>
> Manuele
>
>  

[web2py] mail date

2011-07-18 Thread Manuele Pesenti

hi *,

a strange thing happens calling this controller function by the browser 
with its direct url... the mail arrives with no time information so my 
client sees it with the date 1/1/1970 1:00... any idea why?


is there a way at least to force the message date?

many thanks

PS
I leave all the code but this function essentially has to write a table 
with HTML so don't mind the msg assignment


Manuele

def send_mail_msg():
pannello_out=pannello()
panel_data = pannello_out['panel_data']
available_sites = pannello_out['available_sites']

a = [TH(' ')] + [TH(dates.num2date(d).strftime('%d/%m')) for d in 
panel_data['x']] + [TH(' ')]


c = list()
for site in available_sites:
b = list()
for i in panel_data['x']:
l = list()
for j in ['forecast_wind', 'measured_energy']:
try:
l.append(str(panel_data[site.site.id][j][str(i)]))
except:
l.append('np')
b.append(TD(l[0], BR(), l[1]))
x = [TD(site.site.full_name)] + b + 
[TD(SiteMaxEnergy(site.power_curve.file_name, power_curves_folder)*24/1000)]

c += [TR(*x, _valign="middle", _align="center")]

msg = str(HTML(BODY(
TABLE(
TR(
TH("Sito"), TH("Energia prevista", BR(), "Energia 
immessa", BR(), "(dove disponibile)", BR(), "[%]", _colspan="5"),
TH("Max produzione", BR(), "giornaliera", BR(), 
"[MWh]"),

_valign="middle", _align="center"),
TR(*a, _valign="middle", _align="center"),
*c,
_cellpadding="0", _cellspacing="0", _border="1")
), doctype='tag'))[4:]

recipient_list = (
'm...@mail.org',
)

subject = 'ALERT %s' %(request.now.strftime('%d-%m-%Y %H:%M'))

res = mail.send(to=recipient_list, subject=subject, message=(None, 
msg))


return res


Re: [web2py] Re: Help on Authentication with Janrain

2011-07-18 Thread Offray Vladimir Luna Cárdenas

Hi,

There is also an experimental single login method from mozilla:

https://browserid.org/users

Cheers,

Offray


El 21/02/11 16:57, Anthony escribió:

Janrain is probably the simplest way to do third party authentication, but
you can also integrate directly with OpenID and OAuth providers. See this
section of the book for details:
http://web2py.com/book/default/chapter/08#Other-Login-Methods-and-Login-Forms

Anthony

On Monday, February 21, 2011 4:43:35 PM UTC-5, Pystar wrote:


I am thinking of including third party authentication mechanisms like
Twitter and facebook onto my site, but according to web2py
documentation I have to register with Janrain before I can use it.
Here's the catch, this is a new website, no income yet from it, but
according to Janrain, the free version they are offering only supports
2,500 unique users, I do hope that my site picks up and gets more than
2500 users, now I am a little sceptical, I would like to know if they
are other methods I can use to include 3rd party authentication and
authorization mechanisms onto my site?
Thanks
Pystar








[web2py] Re: jQuery .focus()

2011-07-18 Thread Chris May
To select an element by ID in jQuery, you can use the CSS-like syntax
#id.

jQuery("#key1).focus();


Your jQuery("input.key1").focus(); statement told jQuery to look for
an input with the class property of "key1".

On Jul 18, 3:54 am, annet  wrote:
> In web2py_ajax.html I have the following line of code to set focus on
> the first visible field in forms:
>
> jQuery("input:text:not(.date):first:visible").focus();
>
> In a view with three forms, named form1, form2, form3, the focus is
> set on the first field of form2 whereas I want the focus to be set on
> the first field of form1. I tried:
>
> jQuery("input:text:not(.date):first:visible").focus();
> jQuery("input.key1").focus();
>
> ... but that doesn't work. How do I set focus on the field with id
> key1?
>
> Kind regards,
>
> Annet.


[web2py] Re: Load view or controllers without load

2011-07-18 Thread apple
If you have multiple tables then you must give each table a unique id.

Bruno tells me this can be done in web2py controller:
table = plugins.PowerTable
table._id = "mytable1"

On Jul 18, 3:31 am, Roberto Perdomo  wrote:
> Hi, i have problems loading powertables with LOAD and I wonder if
> there is a way
> to get from one view to another controller without using LOAD or view as
> hereby POWERTABLES tables do not work properly.
>
> Mainly I like to charge two or three tables from a controller in a view.
>
> thanks in advance


[web2py] view for email message

2011-07-18 Thread Manuele Pesenti

hi *,

I woulld like to reuse a controller function with a different view to 
get an html message to send via email... how is it possible?


Is there a way from python code to get the html text that is returned 
when a browser call an url that correspond to my controller "dressed" by 
my view with the same name of my controller and, for example, with 
.email extension?


many thanks

Manuele


[web2py] Re: form.errors problem.

2011-07-18 Thread annet
By the way, regions are defined like this:
Field('regio',length=2,default='',notnull=True,unique=True) and the
field regio contains regions between 00 and 99.

Maybe this is what's causing the problem???


[web2py] form.errors problem.

2011-07-18 Thread annet
I've been struggling with this problem for days now and still don't
see why the form contains an error. This is the relevant part of the
function:

def index():
   ...
form1=SQLFORM.factory(
Field('key1',label='wat',length=72,requires=IS_NOT_EMPTY(),\
widget=lambda self,
value:INPUT(_id='key1',_name='key1',_class='ac_input',_type='text',requires=self.requires)),
Field('city',label='plaats',length=42,requires=IS_NOT_EMPTY(),
\
widget=lambda self,
value:INPUT(_id='city',_name='city',_class='ac_input',_type='text',requires=self.requires)))
form2=SQLFORM.factory(
Field('key2',label='wat',length=72,requires=IS_NOT_EMPTY(),\
widget=lambda self,
value:INPUT(_id='key2',_name='key2',_class='ac_input',_type='text',requires=self.requires)),
Field('region',label='regio',requires=IS_NOT_EMPTY(),\
widget=lambda self,
value:INPUT(_id='zipStandard',_name='zipStandard',_class='ac_input',_type='text',requires=self.requires)))
if form1.accepts(request.vars,session,formname='form1'):
session.key1=request.vars.key1
session.city=request.vars.city
redirect(URL(r=request,c='locator',f='city'))
elif form1.errors:
response.flash='response.flash_searcherror form1'
if form2.accepts(request.vars,session,formname='form2'):
session.key2=request.vars.key2
session.region=request.vars.region
redirect(URL(r=request,c='locator',f='zipcode'))
elif form2.errors:
response.flash='response.flash_searcherror form2'
return dict(form1=form1,form2=form2)


Form1 does work, form2 does work when I remove this part of the code:

widget=lambda self,
value:INPUT(_id='zipStandard',_name='zipStandard',_class='ac_input',_type='text',requires=self.requires)


It is based on the Pengoworks autocomplete, in web2py_ajax.html I put:

response.files.insert(6,URL(r=request,c='static',f='init/css/
jquery.autocomplete.css'))
response.files.insert(7,URL(r=request,c='static',f='init/js/
jquery.autocomplete.js'))

$('#zipStandard').autocomplete("/init/handlers/zipStandardAC",
{maxItemsToShow:12});

... and in the handlers controller:

def zipStandardAC():
q=''
if request.vars:
q=request.vars.q
if not q:
return q
rows=db(db.postcoderegio.regio.like('%s%%'%q.capitalize()))\
.select(db.postcoderegio.regio,distinct=True,orderby=db.postcoderegio.regio)
r=''
for row in rows:
r='%s%s\n'%(r,row.regio)
return r

... the function queries this table:

db.define_table('postcoderegio',
Field('regio',length=2,default='',notnull=True,unique=True),
 
Field('codemin',type='integer',default='',notnull=True,unique=True),
 
Field('codemax',type='integer',default='',notnull=True,unique=True),
Field('provincie_id',
db.provincie,default='',notnull=True,ondelete='RESTRICT'),
migrate=False)

db.postcoderegio.regio.requires=[IS_LENGTH(2,error_message='lengte
overschreidt 2
tekens'),IS_NOT_EMPTY(),IS_NOT_IN_DB(db,'postcoderegio.regio',error_message='regio
al in database')]


The autocomplete bit works, however, when I submit the form I get
"response.flash_searcherror form2" flashed. I have no idea why, I hope
one of you does ...


Kind regards,

Annet.


[web2py] Re: superfish.css overridden : menu sent to back of jqgrid

2011-07-18 Thread Vineet
Got it !
In addition to the "z-index:" property, it is required to specify
"position:absolute" for menu div (which is required to be on top).
After this, the "flash" div goes behind.
So I needed to alter these 2 properties for "flash" also.
Now it works.

But someone pl. tell me if this is a right approach to modify z-index
& position:absolute of certain elements (without breaking any other
functionality of web2py).

If OK, then I would continue with my newly found solution.

Thanks.

On Jul 16, 6:59 pm, Vineet  wrote:
> Hello List !
> I am trying to facelift my app by completely overriding the
> superfish.css.
> In most of the forms, the new-look menu is working superbly.
> But only in those forms containing "jqgrid" or "dataTable" controls,
> the menu is sent to back to the table control.
> Tried by setting "z-index:" property of  containing the menu at
> higher value. But no success.
> I am wondering why this behaviour (only in case of jqgrid &
> dataTable).
>
> Anybody got any idea?
>
> (If the problem description is too short, pl. tell me sothat I can
> post the code in this thread).
>
> Thanks.
> :-)


[web2py] jQuery .focus()

2011-07-18 Thread annet
In web2py_ajax.html I have the following line of code to set focus on
the first visible field in forms:

jQuery("input:text:not(.date):first:visible").focus();


In a view with three forms, named form1, form2, form3, the focus is
set on the first field of form2 whereas I want the focus to be set on
the first field of form1. I tried:

jQuery("input:text:not(.date):first:visible").focus();
jQuery("input.key1").focus();

... but that doesn't work. How do I set focus on the field with id
key1?


Kind regards,

Annet.


[web2py] cron latency

2011-07-18 Thread Manuele Pesenti

Ciao *,

is there some time gap between when I install a new app in my web2py 
installation and when the commands in crontab start to are executed?


if so, is there a way to make the web2py crontab available for execution 
 immediately?


thanks

M.


Re: [web2py] Re: Inner join on subselect

2011-07-18 Thread Vasile Ermicioi
what database do you use?
I tested with sqlite on a table of mine and it works

SELECT id, category,  max(added_on) , title FROM articles GROUP BY category
HAVING added_on=max(added_on)

that query shows latest article from each category