[web2py] Dependent drop downs
Hello, I have db.define_table('type', SQLField('name','string',length=2) SQLField('parent','reference db.type') ) db.define_table('member', SQLField('name','string'), SQLField('type',db.type), SQLField('subtype',db.type), ) I want when select a value of type the drop down of subtype changed according to selection. when am searching on it i found a solution that someone posted it before $('#tourplan_city').change(function(){ $.ajax( ) } But i don't know what is the $.ajax( ) and where i will write my query that compute result of subtype dropdown? Could anyone help me ? Thanks in advance Neveen
[web2py] Re: uploads problem
The update_image(): function resides here: .../cms/homepage/update_image where cms is the application. Whereas I would like the image to be uploaded to this folder: .../init/uploads/company_xxx where init is the application How do I have to adjust this line of code to get it to work. db.image.file.uploadfolder=os.path.join(request.folder,uploads/%i % auth.user.company_id) To append the company_id to company_ what is the best way: uploads/ company_%i % auth.user.company_id or uploads/%i % company_ + auth.user.company_id I realize I could also upload the images to the .../cms/uploads/ company_xxx folder and then change the downloads function in the .../ init/homepage/ controller to download the images from the cms/uploads/ company_xxx folder, is this a better way to proceed? Kind regards, Annet.
[web2py] Re: Autoincrement field
I guess the point here is, generally speaking, what is a secure way to make two or more subsequent DAL operations are performed without race condition. Is a kind of lock needed? An example to describe the problem (but not solving it): def index(): with a_lock_to_prevent_concurrent_requests: # but how? latest_data = db(...).select(...) new_data = do_something_with( latest_data ) db.mytable.insert( new_data ) See also: http://groups.google.com/group/web2py/browse_frm/thread/35be6bba0c02eab0# On May28, 5:25am, mdipierro mdipie...@cs.depaul.edu wrote: What is wrong with the default id field that web2py creates for every table? On May 27, 3:16 pm, matclab mathieu.clab...@gmail.com wrote: Hello, I'm finding this message in a thread from February... I thought that autoincremented field would guaranty unicity in the table. I'm afraid the provided solution would allow two record to have the same autonumber field (think about an access from two users at the same time). I guess the autoincrement should be done on the DAL or database side, inside a transaction What do you think about it ? On 19 jan, 21:38, Thadeus Burgess thade...@thadeusb.com wrote: max_id= db(db.table.autonumber1).select(db.table.autonumber, # select all records, and only pull the autonumber column orderby=~db.table.autonumber, # descending sort on the autonumber, (highest first) limitby=(0,1) # limit the query and only select the first record ).first().autonumber # pull the first record from the web2py rows object, and get its autonumber member db.table.autonumber.default = max_id + 1 # Set the table default as the last autonumber and incremented by one. db.table.autonumber.writable = False form = crud.create(db.table) -Thadeus On Tue, Jan 19, 2010 at 4:32 AM, ceriox cer...@gmail.com wrote: thanks for the reply but i'm not a good web2py programmer ... i writing my first real app you can write the code for my request? (i can't understand the post of your link) -- You received this message because you are subscribed to the Google Groups web2py-users group. To post to this group, send email to web...@googlegroups.com. To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com. For more options, visit this group athttp://groups.google.com/group/web2py?hl=en.
[web2py] Re: Dependent drop downs
On May28, 2:38pm, Neveen Adel nevo.a...@gmail.com wrote: Hello, I have db.define_table('type', SQLField('name','string',length=2) SQLField('parent','reference db.type') ) db.define_table('member', SQLField('name','string'), SQLField('type',db.type), SQLField('subtype',db.type), ) I want when select a value of type the drop down of subtype changed according to selection. when am searching on it i found a solution that someone posted it before $('#tourplan_city').change(function(){ $.ajax( ) } But i don't know what is the $.ajax( ) and where i will write my query that compute result of subtype dropdown? Could anyone help me ? Thanks in advance Neveen web2py book is your friend. :) http://web2py.com/book/default/section/10/3?search=ajax
Re: [web2py] Re: Autoincrement field
I guess that one may want some more constraints on the autoincrement field. For example, it shall begin at 100 for ecample. It may be because for example, before the application exists some paper records where made which were referenced by number 100) For such a problem, I've set up with: Field('ref_number', compute=lambda r: r['id'] + 100) Which I hope would eliminate the race solution as it is calculate upon insertion in the database... Is it the case ? -Mathieu On Thu, May 27, 2010 at 23:25, mdipierro mdipie...@cs.depaul.edu wrote: What is wrong with the default id field that web2py creates for every table? On May 27, 3:16 pm, matclab mathieu.clab...@gmail.com wrote: Hello, I'm finding this message in a thread from February... I thought that autoincremented field would guaranty unicity in the table. I'm afraid the provided solution would allow two record to have the same autonumber field (think about an access from two users at the same time). I guess the autoincrement should be done on the DAL or database side, inside a transaction What do you think about it ? On 19 jan, 21:38, Thadeus Burgess thade...@thadeusb.com wrote: max_id= db(db.table.autonumber1).select(db.table.autonumber, # select all records, and only pull the autonumber column orderby=~db.table.autonumber, # descending sort on the autonumber, (highest first) limitby=(0,1) # limit the query and only select the first record ).first().autonumber # pull the first record from the web2py rows object, and get its autonumber member db.table.autonumber.default = max_id + 1 # Set the table default as the last autonumber and incremented by one. db.table.autonumber.writable = False form = crud.create(db.table) -Thadeus On Tue, Jan 19, 2010 at 4:32 AM, ceriox cer...@gmail.com wrote: thanks for the reply but i'm not a good web2py programmer ... i writing my first real app you can write the code for my request? (i can't understand the post of your link) -- You received this message because you are subscribed to the Google Groups web2py-users group. To post to this group, send email to web...@googlegroups.com. To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.comweb2py%2bunsubscr...@googlegroups.com . For more options, visit this group athttp:// groups.google.com/group/web2py?hl=en.
Re: [web2py] Re: Group some fields into a div
Ok... I'll try with that. On Fri, May 28, 2010 at 03:11, Candid roman.bat...@gmail.com wrote: Use form.custom.widget. See http://web2py.com/book/default/section/7/7 for details. On May 27, 4:48 pm, Mathieu Clabaut mathieu.clab...@gmail.com wrote: Hello In my model, I've a table defined as STATUS_TYPE = ('identification','analyse') db.define_table('faq', Field('status', 'string', requires=[IS_IN_SET(STATUS_TYPE, multiple=True), IS_NOT_EMPTY(), IS_ORDERED(STATUS_TYPE)], default=STATUS_TYPE[0], widget=SQLFORM.widgets.checkboxes.widget), Field('identification', 'text', requires=IS_NOT_EMPTY(), notnull=True), Field('identification_author',db.auth_user, default=me), Field('identification_date', 'date', ), Field('analyse', 'text'), Field('analyse_author',db.auth_user), Field('analyse_date', 'date'), ) I'd like the corresponding form to group fields beginning with 'identification' in a single div name='identification', and the fields beginning with 'analyse' in a single div name='analyse'/div (so as I can slide them up and down with a jquery depending of the status selection). My question is : what is the best way to achieve that ? Is there a magical option in the Field initialisation ? Shall I define a customize form widget using form.customs.widget[field] with a logic to encapsulate the wanted fields ? I'm interested by your experience on this topic... -Mathieu PS. I guess it is quite a newbie question, but it is indeed the first time I address form customization...
[web2py] Re: Moving apps outside /applications
Thanks guys, I think symlinking will work perfectly. cheers
Re: [web2py] where is : scripts/web2py-wsgi.conf
Hi Alexandre, Ok! What I understand so far is... I have to create a file call web2py.pid in /users/www-data/web2py Do I am right? Still have the admin disabled because unable to access password file message. Thanks Jonhy 2010/5/27 Alexandre Andrade alexandrema...@gmail.com using the script setup***ubuntu.sh will work fine. 2010/5/27 Jean Guy jean...@gmail.com Hi dear web2py crew, I was trying to deploy web2py in production with apache2 under ubuntu server. I follow those informations in the web2py book : http://web2py.com/book/default/section/11/2 I got : admin disabled because unable to access password file What do I have to do... scripts/web2py-wsgi.conf doesn't exist in the web2py build I have 1.7.8.3 Do I should give access by .htaccess?? In wich folder I should do, if the preceding answer is yes? Thanks Jonhy -- Atenciosamente -- = Alexandre Andrade Hipercenter.com
[web2py] Storing API credentials
I'm implementing PayPal on my site and would like to know the best practice for securely storing my API credentials (user, pass, signature). Can this go in the database (say in a 'credentials' table), or should it be elsewhere?
[web2py] How to duplicate a record
Hi all, how i can duplicate a record ?
[web2py] Re: Storing API credentials
you cold do it the following way: add this to models/db.py import os.path from ConfigParser import ConfigParser class Config: ''' to configure please use the config file that is created with this class under unix systems you will find it under /home/YOURNAME/.pyMantis/plugin_mailinglist_config ''' __borg_dict = {'parser': None} _config_path = os.path.join(os.path.expanduser('~'), '.pyMantis') _config_file = os.path.join(_config_path,'plugin_mailinglist_config') def __init__(self): self.__dict__ = self.__borg_dict if not self.parser: self.parser = ConfigParser() self.parser.add_section('smtp') self.parser.set('smtp','server','mail.abcde.com:1234') self.parser.set('smtp','login','user:password') self.parser.read(self._config_file) def get(self, section, option): return self.parser.get(section, option).strip() def set(self, section, option, value): self.parser.set(section, option, value) def write(self): if not os.path.isdir(self._config_path): os.mkdir(self._config_path) self.parser.write(open(self._config_file,'w')) plugin_mailinglist_config = Config() plugin_mailinglist_config.write() now you can to in you controller host, port = plugin_mailinglist_config.get('smtp','server').split(':') user, passw = plugin_mailinglist_config.get('smtp','login').split(':') On May 28, 1:34 pm, scausten scaus...@googlemail.com wrote: I'm implementing PayPal on my site and would like to know the best practice for securely storing my API credentials (user, pass, signature). Can this go in the database (say in a 'credentials' table), or should it be elsewhere?
[web2py] Plugin_jqgrid problem
Hi,everyone, i'm a newbie for web2py,I'm in trouble when I use the plugin_jqgrid. this is my code: my dbmodel: db.define_table(data, SQLField(name, notnull=True, default=None), SQLField(date,notnull=True), SQLField(number, notnull=True, default=None), SQLField(later_times, integer, default=None), SQLField(leave_early_times, integer, default=None), SQLField(absenteeism_times, integer, default=None), SQLField(later_time,default=None), SQLField(leave_early_time, default=None), SQLField(work_time, default=None), SQLField(department,default=None), SQLField(description,default=None)) my controller: def index(): grid=plugin_jqgrid(db.All_work_data,columns=['id','name','date','number','later_times','leave_early_times','absenteeism_times','later_time','leave_early_time','work_time','department','description'],,col_width=75,height=600) return dict(grid=grid) my view: default/index.html {{extend 'layout.html'}} h2 1.all data /h2 {{ =grid}} h22.all data /h2 {{ =grid}} I found just one grid display in my page when i run the code. where is the problem?
[web2py] Re: Plugin_jqgrid problem
Hi,everyone, i'm a newbie for web2py,I'm in trouble when I use the plugin_jqgrid. this is my code: my dbmodel: db.define_table(data, SQLField(name, notnull=True, default=None), SQLField(date,notnull=True), SQLField(number, notnull=True, default=None), SQLField(later_times, integer, default=None), SQLField(leave_early_times, integer, default=None), SQLField(absenteeism_times, integer, default=None), SQLField(later_time,default=None), SQLField(leave_early_time, default=None), SQLField(work_time, default=None), SQLField(department,default=None), SQLField(description,default=None)) my controller: def index(): grid=plugin_jqgrid(db.data,columns=['id','name','date','number','later_times','leave_early_times','absenteeism_times','later_time','leave_early_time','work_time','department','description'],,col_width=75,height=600) return dict(grid=grid) my view: default/index.html {{extend 'layout.html'}} h2 1.all data /h2 {{ =grid}} h22.all data /h2 {{ =grid}} I found just one grid display in my page when i run the code. where is the problem?
[web2py] Question on IS_IN_DB and sort order
Is there a way, how to specify order(sorting) in IS_IN_DB ? Its easy to use it for validator and let web2py to generate combobox. How can I specifiy 'order' form db query, so dropdown items are in good order? Something like db().select(db.person.ALL, orderby=db.person.name) ? Thank you, David
Re: [web2py] where is : scripts/web2py-wsgi.conf
I start getting to the point... I mean, it seems that Location /admin Deny from all /Location LocationMatch ^/([^/]+)/appadmin Deny from all /LocationMatch As to be to Allow from all Is that correct? But it's not working so far. Jonhy 2010/5/28 Jean Guy jean...@gmail.com Hi Alexandre, Ok! What I understand so far is... I have to create a file call web2py.pid in /users/www-data/web2py Do I am right? Still have the admin disabled because unable to access password file message. Thanks Jonhy 2010/5/27 Alexandre Andrade alexandrema...@gmail.com using the script setup***ubuntu.sh will work fine. 2010/5/27 Jean Guy jean...@gmail.com Hi dear web2py crew, I was trying to deploy web2py in production with apache2 under ubuntu server. I follow those informations in the web2py book : http://web2py.com/book/default/section/11/2 I got : admin disabled because unable to access password file What do I have to do... scripts/web2py-wsgi.conf doesn't exist in the web2py build I have 1.7.8.3 Do I should give access by .htaccess?? In wich folder I should do, if the preceding answer is yes? Thanks Jonhy -- Atenciosamente -- = Alexandre Andrade Hipercenter.com
Re: [web2py] where is : scripts/web2py-wsgi.conf
I got it! I miss the setup script!!! God. I am going to test it right now. Thanks. Jonhy 2010/5/27 Alexandre Andrade alexandrema...@gmail.com using the script setup***ubuntu.sh will work fine. 2010/5/27 Jean Guy jean...@gmail.com Hi dear web2py crew, I was trying to deploy web2py in production with apache2 under ubuntu server. I follow those informations in the web2py book : http://web2py.com/book/default/section/11/2 I got : admin disabled because unable to access password file What do I have to do... scripts/web2py-wsgi.conf doesn't exist in the web2py build I have 1.7.8.3 Do I should give access by .htaccess?? In wich folder I should do, if the preceding answer is yes? Thanks Jonhy -- Atenciosamente -- = Alexandre Andrade Hipercenter.com
[web2py] Re: Autoincrement field
yes On May 28, 3:44 am, Mathieu Clabaut mathieu.clab...@gmail.com wrote: I guess that one may want some more constraints on the autoincrement field. For example, it shall begin at 100 for ecample. It may be because for example, before the application exists some paper records where made which were referenced by number 100) For such a problem, I've set up with: Field('ref_number', compute=lambda r: r['id'] + 100) Which I hope would eliminate the race solution as it is calculate upon insertion in the database... Is it the case ? -Mathieu On Thu, May 27, 2010 at 23:25, mdipierro mdipie...@cs.depaul.edu wrote: What is wrong with the default id field that web2py creates for every table? On May 27, 3:16 pm, matclab mathieu.clab...@gmail.com wrote: Hello, I'm finding this message in a thread from February... I thought that autoincremented field would guaranty unicity in the table. I'm afraid the provided solution would allow two record to have the same autonumber field (think about an access from two users at the same time). I guess the autoincrement should be done on the DAL or database side, inside a transaction What do you think about it ? On 19 jan, 21:38, Thadeus Burgess thade...@thadeusb.com wrote: max_id= db(db.table.autonumber1).select(db.table.autonumber, # select all records, and only pull the autonumber column orderby=~db.table.autonumber, # descending sort on the autonumber, (highest first) limitby=(0,1) # limit the query and only select the first record ).first().autonumber # pull the first record from the web2py rows object, and get its autonumber member db.table.autonumber.default = max_id + 1 # Set the table default as the last autonumber and incremented by one. db.table.autonumber.writable = False form = crud.create(db.table) -Thadeus On Tue, Jan 19, 2010 at 4:32 AM, ceriox cer...@gmail.com wrote: thanks for the reply but i'm not a good web2py programmer ... i writing my first real app you can write the code for my request? (i can't understand the post of your link) -- You received this message because you are subscribed to the Google Groups web2py-users group. To post to this group, send email to web...@googlegroups.com. To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.comweb2py%2bunsubscr...@googlegroups.com . For more options, visit this group athttp:// groups.google.com/group/web2py?hl=en.
Re: [web2py] How to duplicate a record
myrecord = db.table[5] db.table.insert(a = myrecord.a, b = myrecord.b, c = myrecord.c) Are you looking for an audit logging ability? http://www.web2pyslices.com/main/slices/take_slice/35 -- Thadeus On Fri, May 28, 2010 at 7:13 AM, ceriox cer...@gmail.com wrote: Hi all, how i can duplicate a record ?
[web2py] Better record deletion in SQLFORM
Hello Massimo, This proposal tries to address the last point mentioned in [1], quoted below. .. when deleting a record, form variables should be cleared which is not the case here. In my openion this’s not a good idea in fact, and needs to be fixed because it’s really tempting to see the variables still in the form and makes one clicks the ['submit'] button again to see what would happen and it returns ‘object not found’ error message. An easy idea, which was also suggested in [1], is to use redirect(...) after successful record deletion. But that is not one-size-fits-all because developers need to provide target URL in every case. Then I planned to somehow compulsively replace the form object with a string such as delete ok, but it would cause backward compatibility problem when a customized view file expecting a real form object. Finally I got the idea. SQLFORM.accepts() can disable all form fields after deletion, to indicating a successful deletion and also avoid further operation! crud also benefits from this improvement. Try the patch. From line 920 of sqlhtml.py: if record_delete: .. self.errors.clear() self.components.append(SCRIPT(jQuery(document).ready(function(){ jQuery('input, select').attr('disabled', 'disabled'); }), _type=text/javascript)) # to emphasize the record is deleted and avoid further operation return True [1] http://web2py.wordpress.com/2010/05/02/record-deletion-and-keepvalues-in-forms/ Sincerely, Iceberg, 2010-May-28, 03:07(AM), Fri
[web2py] Filter records based on Subdomain value when running on GAE
Here is the code to print a certain record to match a subdomain or print all -- in case someone asks: try: appname = request.env.http_host.split('.')[0] app_id = db(db.app.name ==str.lower(appname)).select().first().id apps=db(db.app.id==app_id).select() return dict(apps=apps) except: apps=db().select(db.app.ALL,orderby=db.app.name) return dict(apps=apps)
[web2py] Re: New to web app development -- is web2py a good choice
On May 6, 6:01 pm, mdipierro mdipie...@cs.depaul.edu wrote: I have not done a good job at keep track. These are two outdated lists: http://www.appliedstacks.com/PoweredBy/web2py http://web2py.com/poweredby Note, the Powered By list on web2py.com includes a link to www.sahanapy.org (which now redirects to eden.sahanafoundation.org). However, that's just the trac site for the Sahana Eden project (i.e., it's not actually powered by web2py). When you get around to creating a new Powered By list, you should instead link to the live demo of the Sahana Eden application, which _is_ powered by web2py: http://demo.eden.sahanafoundation.org (it even has a web2py icon on the bottom). In fact, that Sahana demo is probably the single most impressive publicly accessible example of what web2py can do (though www.radbox.me is also very cool and aesthetically well designed). I had been at the Sahana project site once before and (a) mistakenly thought _that_ was what was powered by web2py (just taking a quick look at sites on the Powered By list), (b) wasn't that impressed (due to (a)), and (c) failed to get to the demo and become properly impressed with web2py. It might also be worth pointing people to http://eden.sahanafoundation.org/wiki/FrequentlyAskedQuestionsWeb2Py.
[web2py] Complicated Join...
I tried doing this last year and I was close and couldn't figure it out. I need to complete implementing it and wondered if you could help out. Using the attatched model I want to do the following: I need to have a list of all the users that have similar tags to the user that is logged in. I need those tag names as well. As an added sugar candy bonus I wonder if there is an easy way to could them or should I just count them as I sort throw them in the view. I think I am close with this, it modified from something done last year. Am I doing this right? Best Regards, Jason Brower My pertinent controller function: --- @auth.requires_login() def your_connections(): related_tags = db(( db.auth_user.id==db.user_tags.user_id)(db.user_tags.tag_id==db.tag.id)(db.user_tags.tag_id.belongs( db(db.user_tags.user_id==auth.user.id)._select( db.user_tags.tag_id.select( db.auth_user.ALL,db.tag.ALL,groupby=db.auth_user.id) return dict(related_tags = related_tags) --- from datetime import datetime, date, time now = datetime.utcnow() today = date.today() db = SQLDB('sqlite://interestID.db') ### # Authentication System ### from gluon.tools import Mail, Auth mail = Mail() mail.settings.server='smtp.gmail.com:587' mail.settings.sender= 'interes...@gmail.com' mail.settings.login='interes...@gmail.com:' auth = Auth(globals(), db) # after # auth = Auth(globals(),db) auth_table = db.define_table(auth.settings.table_user_name, Field('first_name', length=128, default=''), Field('last_name', length=128, default=''), Field('email', length=128, default='', unique=True), Field('password', 'password', length=256, readable=False, label='Password'), Field('registration_key', length=128, default= '', writable=False, readable=False), Field('nickname', 'string', length=20, unique=True), Field('phone_number', 'string', length=15), Field('university_affiliation', 'string', length=100), Field('created', 'datetime', default=now, writable=False, readable=False), Field('avatar', 'upload'), Field('short_description','text'), Field('sex','text') ) auth_table.first_name.requires = \ IS_NOT_EMPTY(error_message=auth.messages.is_empty) auth_table.last_name.requires = \ IS_NOT_EMPTY(error_message=auth.messages.is_empty) auth_table.password.requires = [CRYPT()] auth_table.email.requires = [ IS_EMAIL(error_message=auth.messages.invalid_email), IS_NOT_IN_DB(db, auth_table.email)] auth.settings.table_user = auth_table auth_table.nickname.requires = IS_NOT_IN_DB(db,'auth_user.nickname') auth_table.created.requires = IS_NOT_EMPTY() auth_table.sex.requires = IS_IN_SET([Male,Female,Unset]) auth.settings.mailer = mail auth.define_tables() db.define_table('tag', Field('name', 'string'), Field('description', 'text'), Field('logo', 'upload'), Field('created', 'date', default=now, writable=False), Field('creator', 'string', writable=False)) db.define_table('user_tags', Field('tag_id',db.tag), Field('user_id', db.auth_user)) db.define_table('user_photos', Field('photo', 'upload'), Field('description', 'text'), Field('tag', db.tag), Field('date_added', 'datetime', default=request.now, readable=False, writable=False), Field('creator', 'integer')) db.user_photos.tag.requires = IS_IN_DB(db, db.tag.id, '%(name)s') db.user_tags.tag_id.requires = IS_IN_DB(db,'tag.id', '%(name)s') db.user_tags.user_id.requires = IS_IN_DB(db, 'auth_user.id', '%(nickname)s') db.tag.name.requires = [IS_NOT_EMPTY(), IS_NOT_IN_DB(db,'tag.name')] db.tag.description.requires = IS_NOT_EMPTY() db.tag.logo.requires = IS_NOT_EMPTY() db.tag.created.requires = IS_NOT_EMPTY() #Special condition to default to the current user. if auth.user: user_id=auth.user.email else: user_id=0 db.tag.creator.default=user_id db.user_photos.creator.default=user_id
[web2py] Re: Complicated Join...
check out www.tenthrow.com, click on a concert and you will see an other concerts box. those are generated following several rules, the first if finding concerts that share tags with this concert. My tags have a magnitude or a weighting, so some are more valued than others. hence the magnitude references below. otherwise my tag and concert_tag tables mimic what you have in your model. I don't display the tag name that they share though. my relevant queries: #active_playlist is a record, passed to my function. tags = db(db.concert_tag.playlist== \ active_playlist.id).select(db.concert_tag.tag) count = db.concert_tag.id.count() sum = db.concert_tag.magnitude.sum() query = db((db.concert_tag.tag.belongs([t.tag for t in tags])) (db.concert_tag.playlist != active_playlist.id) (db.playlist.id == db.concert_tag.playlist) ) rows = query.select(db.playlist.name, db.concert_tag.playlist, db.playlist.uid, count, sum, groupby=db.concert_tag.playlist| db.playlist.uid, orderby=~count|~sum|~db.playlist.date, limitby=(0,NUM_RELATED_LINKS)) dunno if that helps or not... On May 28, 1:31 pm, Jason Brower encomp...@gmail.com wrote: I tried doing this last year and I was close and couldn't figure it out. I need to complete implementing it and wondered if you could help out. Using the attatched model I want to do the following: I need to have a list of all the users that have similar tags to the user that is logged in. I need those tag names as well. As an added sugar candy bonus I wonder if there is an easy way to could them or should I just count them as I sort throw them in the view. I think I am close with this, it modified from something done last year. Am I doing this right? Best Regards, Jason Brower My pertinent controller function: --- @auth.requires_login() def your_connections(): related_tags = db(( db.auth_user.id==db.user_tags.user_id)(db.user_tags.tag_id==db.tag.id)(db.user_tags.tag_id.belongs( db(db.user_tags.user_id==auth.user.id)._select( db.user_tags.tag_id.select( db.auth_user.ALL,db.tag.ALL,groupby=db.auth_user.id) return dict(related_tags = related_tags) --- db.py 3KViewDownload
[web2py] Re: Better record deletion in SQLFORM
Another extrange behaviour I noted is in T3. 1) I defined a table and I inserted a value in a int record. 2) I noted I was worng with the type field, I wanted a string, so I deleted the record and redefined type field in define_table 3) I changed the type of record from int to string, web2py respoonded me OK 4) reallyr web2py doesn't changes type field, but models has type string at define_table I had to use SqliteManager to change table. On 28 mayo, 17:55, Iceberg iceb...@21cn.com wrote: Hello Massimo, This proposal tries to address the last point mentioned in [1], quoted below. .. when deleting a record, form variables should be cleared which is not the case here. In my openion this’s not a good idea in fact, and needs to be fixed because it’s really tempting to see the variables still in the form and makes one clicks the ['submit'] button again to see what would happen and it returns ‘object not found’ error message. An easy idea, which was also suggested in [1], is to use redirect(...) after successful record deletion. But that is not one-size-fits-all because developers need to provide target URL in every case. Then I planned to somehow compulsively replace the form object with a string such as delete ok, but it would cause backward compatibility problem when a customized view file expecting a real form object. Finally I got the idea. SQLFORM.accepts() can disable all form fields after deletion, to indicating a successful deletion and also avoid further operation! crud also benefits from this improvement. Try the patch. From line 920 of sqlhtml.py: if record_delete: .. self.errors.clear() self.components.append(SCRIPT(jQuery(document).ready(function(){ jQuery('input, select').attr('disabled', 'disabled'); }), _type=text/javascript)) # to emphasize the record is deleted and avoid further operation return True [1]http://web2py.wordpress.com/2010/05/02/record-deletion-and-keepvalues... Sincerely, Iceberg, 2010-May-28, 03:07(AM), Fri
[web2py] Re: Plugin_jqgrid problem
did you insert any record? On 28 mayo, 15:28, leo leo...@gmail.com wrote: Hi,everyone, i'm a newbie for web2py,I'm in trouble when I use the plugin_jqgrid. this is my code: my dbmodel: db.define_table(data, SQLField(name, notnull=True, default=None), SQLField(date,notnull=True), SQLField(number, notnull=True, default=None), SQLField(later_times, integer, default=None), SQLField(leave_early_times, integer, default=None), SQLField(absenteeism_times, integer, default=None), SQLField(later_time,default=None), SQLField(leave_early_time, default=None), SQLField(work_time, default=None), SQLField(department,default=None), SQLField(description,default=None)) my controller: def index(): grid=plugin_jqgrid(db.All_work_data,columns=['id','name','date','number','later_times','leave_early_times','absenteeism_times','later_time','leave_early_time','work_time','department','description'],,col_width=75,height=600) return dict(grid=grid) my view: default/index.html {{extend 'layout.html'}} h2 1.all data /h2 {{ =grid}} h22.all data /h2 {{ =grid}} I found just one grid display in my page when i run the code. where is the problem?
[web2py] Re: Question on IS_IN_DB and sort order
db.your_table.your_field.requires = IS_IN_DB(db, 'person.id', '% (name)s', orderby='person.name')) On May 28, 9:38 am, David Marko dma...@tiscali.cz wrote: Is there a way, how to specify order(sorting) in IS_IN_DB ? Its easy to use it for validator and let web2py to generate combobox. How can I specifiy 'order' form db query, so dropdown items are in good order? Something like db().select(db.person.ALL, orderby=db.person.name) ? Thank you, David
[web2py] Question about the wiki
I'm not sure if the group is the correct place to ask questions about the wiki or not, so if it's not the right place please let me know what is... I've used python a bit in the past but needed a refresher so I started going through the tutorial in the web2py book and ran across the following: http://web2py.com/book/default/section/2/11 At the top of the page it states: * Attributes are generally associated with the instance, not the class (except when declared as class attributes, which is the same as static member variables in C++/Java). * further down the page however it states: *All variables are local variables of the method except variables declared outside methods. For example, z is a class variable, equivalent to a C++ static member variable that holds the same value for all instances of the class. * So is there a difference between an attribute and a variable? Is z a class variable? a class attribute? both? Seems that the page needs to be cleaned up to use consistent wording, unless there is an actual difference between the two. Thanks, -Doug