how to retreive the body text alone of a webpage

2010-10-02 Thread jimgardener
hi I am writing an application to find out if the body text of a web page of given url has been modified-added or removed.Is there some way to find out the length of body text alone? I wrote a function that can read and return the data length.But is there some way I can read the body text alone ?T

Re: how to retreive the body text alone of a webpage

2010-10-02 Thread jimgardener
thanks guys, I tried this.. from BeautifulSoup import BeautifulSoup import urllib def get_page_body_text(url): h=urllib.urlopen(url) data=h.read() soup=BeautifulSoup(data) body_texts = soup.body(text=True) text = ''.join(body_texts) return text ... while True:

cannot find django.core.management

2010-10-04 Thread jimgardener
hi In my django app I wanted to use some task scheduling .So ,i built and installed celery from celery-2.0.3.tar.gz.Then later I found a blog about django-celery and ghettoq at http://bitkickers.blogspot.com/2010/07/djangocelery-quickstart-or-how-i.html I installed those two through easy-install ,

unit test :how to call a single test method alone

2010-10-05 Thread jimgardener
hi In my application,I have the following structure for tests myapp---__init__.py | | tests- __init__.py #contains from functional import * from utility import * | | functional - __init__.py | -utility__init__.py #from myutil_tests import *

unittest fixture doesn't load from TestCase

2010-10-07 Thread jimgardener
hi I have a 'sample.json' that has some data I use for unittesting my app.I have put it in fixtures folder of myapp alongside 'initial_data.json'.In my TestCase subclass,I put it as, class MyTC(TestCase): fixtures=['sample.json'] def setUp(self): ... However,when I run the unitte

dictionary doesn't get properly updated

2010-10-07 Thread jimgardener
hi In my django view ,I am creating a Thread subclass and adding it to a ThreadManager TM to keep in a dictionary with name of thread as key and instance as value.I have implemented TM as a singleton and verified that only one instance of TM exists .However,when the view calls tm.add_mythread() ,I

Re: dictionary doesn't get properly updated

2010-10-07 Thread jimgardener
 pm, jimgardener wrote: > What is the MySingleton superclass? There's nothing in the code you've > posted that shows that TM is actually a singleton. > -- > DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to

Re: dictionary doesn't get properly updated

2010-10-07 Thread jimgardener
I am using the development server..will that cause such a problem? jim > Are you sure that everything is being run in the same process? If (for > example) you are using Apache as a front-end then, as I understand it, > there are no guarantees about that. > > regards >  Steve > -- > DjangoCon US 20

Re: dictionary doesn't get properly updated

2010-10-07 Thread jimgardener
right..that is what was happening.. thanks for pointing it out.. regards jim On Oct 7, 11:41 pm, Doug wrote: > Could it be that garbage collection is deleting your "tm" instance > when it falls out of scope at the end of the view call?  If that is > the only place you've instantiated it, I'm gues

how to avoid error opening a url

2010-10-10 Thread jimgardener
hi In my application I am taking user given url strings.The user is likely to enter 'www.google.com' instead of 'http:// www.google.com' .When I try to open the url import urllib2 page=urllib2.urlopen(url) can give a ValueError if the user fails to enter 'http'.How can this problem be addressed?d

design problem..how to store web page's data for later comparison

2010-10-11 Thread jimgardener
hi I am trying to write an application that checks a web page today and again checks it after somedays and compares them.For this purpose I need to store the page data on these 2 occassions in my program . How can I do this?I can get the page data of current moment as a string using urllib.urlop

Re: design problem..how to store web page's data for later comparison

2010-10-12 Thread jimgardener
thank Jonathan..it was very helpful.. jim > Good luck, > Jonathan > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+

how to add login info while opening url

2010-10-12 Thread jimgardener
hi I was trying to get data from different web pages using urlopen and read. from urllib import urlopen def get_page_data(url): f=urlopen(url) return f.read() when I gave this url ,it produces a 'forbidden' response print get_page_data('http://groups.google.com/group/django-users/ topics

file read/write location

2010-10-16 Thread jimgardener
hi I have a django project at /home/dev/python/django/myproject .In an app in this project I have some utility programs which has a file writing function. myproject/myapp/utilities/filewritingutility.py def write_to_file(filename,data): with open(filename,'w') as f: f.write(

Re: file read/write location

2010-10-16 Thread jimgardener
I was writing a lot of wep page content to the files for later comparison.So I thought ,writing to file was better than writing to db.. thanks jim > Also, if you dont mind me asking, why not just use the database for > recording and retrieving data, thats whats its there for. > > Rob :) -- You r

how to use tkinter widget in django

2010-10-26 Thread jimgardener
is it possible to use the sliderlike Scale widget from tkinter in django?I am coding a web app where I need to get a numerical value entered by the user.I thought ,instead of asking the user to enter a value in a textfield ,I would provide a slider which he can move between the minimum and maximum

Re: how to use tkinter widget in django

2010-10-26 Thread jimgardener
thanks for the replies.. I am wondering if javascript is the only alternative if I want to use such a custom widget. If anyone knows about any such python widget please tell me.. regards jim -- You received this message because you are subscribed to the Google Groups "Django users" group. To pos

Re: how to use tkinter widget in django

2010-10-26 Thread jimgardener
hi thanks for the link. I tried this,In firefox3.6.11 ,it is rendered as a text field In chrome it shows a slider. ... select numerical value using slider: {{myform.user_entry.errors}} ... However,I am getting validation error upon processing the form I put the field as an IntegerField in m

Re: how to use tkinter widget in django

2010-10-26 Thread jimgardener
thanks elijah..that worked how come id="id_user_entry" not enough? regards jim On Oct 26, 11:54 pm, elijah rutschman wrote: > >   >       min="0" > >       max="1000" > >       step="2" > >       value="6" id="id_user_entry"/> > > Try adding a name="user_entry" attribute to the input. -- You r

for loop logic in template

2010-10-26 Thread jimgardener
hi I have a model with 3 fields class Employee(models.Model): name=models.CharField(max_length=50) home_address=models.TextField(blank=True) change_filter=models.IntegerField() I am creating a modelform using this class as model. class EmployeeForm(ModelForm): class Meta: m

how to do object lookup using hour ,minute

2010-02-06 Thread jimgardener
hi I am a beginner with python and django and am writing my first application.I need to retrieve some objects of my model class created at different minutes in an hour.The class stores a datetime value in a 'creationtime' ( DateTimeField )and have an associated 'subject' string which can get rep

problem with get_absolute_url

2010-02-07 Thread jimgardener
hi I am new to django..and was trying out the permalink method I have defined a get_absolute_url for my Entry class and used permalink. class MyEntry(models.Model): pub_time=models.DateTimeField(default=datetime.now) mycategory=models.ForeignKey() def __unicode__(self):

Re: problem with get_absolute_url

2010-02-07 Thread jimgardener
Thanks Mike for the reply. I rewrote the method as @models.permalink def get_absolute_url(self): return("myapp_entry_detail",(),{'id':self.id}) When I go to the admin interface's edit page for an entry and click the viewsite button it causes the following error, NoReverseMatch,Reverse for 'm

editing an entry ,how to call the form action

2010-02-08 Thread jimgardener
hi I created a view function to edit an entry. def edit_entry(request,id): entry=get_object_or_404(MyEntry,id=id) if request.method=='POST': form=MyEntryForm(request.POST,instance=entry) if form.is_valid(): form.save()

Re: editing an entry ,how to call the form action

2010-02-08 Thread jimgardener
thanks rebus -jim > > > {{entryform.as_ul }} > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@goog

newbie doubt about editing an objects field

2010-02-24 Thread jimgardener
hi, I am new to this framework and was trying out some code..I created a MySubject model with name and description fields.I am using name as a unique field and description can be an empty string.I provided add and edit views as well as a ModelForm.I wanted to deal with the following usecases. In

Re: newbie doubt about editing an objects field

2010-02-24 Thread jimgardener
On Feb 24, 9:55 pm, Timothy Kinney wrote: >Just add > the option *unique=True* when you define the field in the model and the > database will not allow two entries with the same value for that field. I have defined the name field to be unique in the model. name=models.CharField(unique=True

Re: newbie doubt about editing an objects field

2010-02-24 Thread jimgardener
On Feb 24, 10:51 pm, Timothy Kinney wrote: > You can define a variable called error_message which is None when you pass > it into the template initially. Then you can fill it with the desired > message and do something like this: > {% if error_message %} >    # display some information Well,ac

displaying validation errors

2010-02-24 Thread jimgardener
hello guys, I wanted to display validation errors in the form .I tried this class BookForm(ModelForm): class Meta: model=Book def clean_bookname(self): bkname=self.cleaned_data['bookname'] bkname=bkname.strip() if Book.objects.filter(bookname__iexact=bkname)

Re: how to check size of a dict or list in template

2010-03-03 Thread jimgardener
what exactly does object_status.0 mean? I got an error when I tried it in python shell jim On Mar 3, 1:10 pm, Alessandro Pasotti wrote: > 2010/3/3 harryos > >  {%if not  object_status.0 %} > > -- You received this message because you are subscribed to the Google Groups "Django users" group.

how to add author to entry,newbie doubt about IntegrityError

2010-03-08 Thread jimgardener
hi, I am more or less a beginner with django and databases.I was trying to set the author field of an entry from the request.user instead of letting the user select from a drop down list of users.I designed the models like class Entry(models.Model): pub_date=models.DateField(default=date.toda

Re: how to start with django

2010-03-08 Thread jimgardener
grab the ebook written by James Bennet, one of the best ever written Subhransu Sekhar Mishra wrote: > hi,i am subhransu and new to django . i want to know how to start > django ?i have not done any project before. -- You received this message because you are subscribed to the Google Groups "Dj

making query using filter()

2010-03-10 Thread jimgardener
Hi I need to make a query as follows Select all entries where categories=mycategory In the db there are entries and categories as follows Category.objects.all() -->[ ,,] MyEntry.objects.all() --> [ ,, ] I tried like this mycategory=Category.objects.get(name='mycategory') MyEntry.objects.filter