Skip to content

Commit f58a64a

Browse files
author
purp
committed
rm old invalid example, add fbsample which works well on django-1.1
1 parent 13c3f2f commit f58a64a

File tree

20 files changed

+278
-222
lines changed

20 files changed

+278
-222
lines changed

.project

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>pyfacebook</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.python.pydev.PyDevBuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.python.pydev.pythonNature</nature>
16+
</natures>
17+
</projectDescription>

.pydevproject

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<?eclipse-pydev version="1.0"?>
3+
4+
<pydev_project>
5+
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.6</pydev_property>
6+
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
7+
</pydev_project>

examples/examples.py

Lines changed: 0 additions & 107 deletions
This file was deleted.

examples/fbsample/.project

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>fbsample</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.python.pydev.PyDevBuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.python.pydev.pythonNature</nature>
16+
</natures>
17+
</projectDescription>

examples/fbsample/.pydevproject

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<?eclipse-pydev version="1.0"?>
3+
4+
<pydev_project>
5+
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.6</pydev_property>
6+
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
7+
</pydev_project>

examples/fbsample/db.sqlite3

26 KB
Binary file not shown.

examples/fbsample/fbapp/models.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
from django.db import models
2+
3+
# get_facebook_client lets us get the current Facebook object
4+
# from outside of a view, which lets us have cleaner code
5+
from facebook.djangofb import get_facebook_client
6+
7+
8+
def _2int(d, k):
9+
try:
10+
d = d.__dict__
11+
except:
12+
pass
13+
14+
t = d.get(k, '')
15+
if t == 'None':
16+
t = 0
17+
else:
18+
t = int(t)
19+
return t
20+
21+
class UserManager(models.Manager):
22+
"""Custom manager for a Facebook User."""
23+
24+
def get_current(self):
25+
"""Gets a User object for the logged-in Facebook user."""
26+
facebook = get_facebook_client()
27+
user, created = self.get_or_create(id=_2int(facebook, 'uid'))
28+
if created:
29+
# we could do some custom actions for new users here...
30+
pass
31+
return user
32+
33+
class User(models.Model):
34+
"""A simple User model for Facebook users."""
35+
36+
# We use the user's UID as the primary key in our database.
37+
id = models.IntegerField(primary_key=True)
38+
39+
# TODO: The data that you want to store for each user would go here.
40+
# For this sample, we let users let people know their favorite progamming
41+
# language, in the spirit of Extended Info.
42+
language = models.CharField(max_length=64, default='Python')
43+
44+
# Add the custom manager
45+
objects = UserManager()
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<fb:header>
2+
{% comment %}
3+
We can use {{ fbuser }} to get at the current user.
4+
{{ fbuser.id }} will be the user's UID, and {{ fbuser.language }}
5+
is his/her favorite language (Python :-).
6+
{% endcomment %}
7+
Welcome, <fb:name uid="{{ fbuser.id }}" firstnameonly="true" useyou="false" />!
8+
</fb:header>
9+
10+
<div class="clearfix" style="float: left; border: 1px #d8dfea solid; padding: 10px 10px 10px 10px; margin-left: 30px; margin-bottom: 30px; width: 500px;">
11+
Your favorite language is {{ fbuser.language|escape }}.
12+
<br /><br />
13+
14+
<div class="grayheader clearfix">
15+
<br /><br />
16+
17+
<form action="." method="POST">
18+
<input type="text" name="language" value="{{ fbuser.language|escape }}" />
19+
<input type="submit" value="Change" />
20+
</form>
21+
</div>
22+
</div>

0 commit comments

Comments
 (0)