Beispiel #1
0
from iap_utils import *

import cgi
form = cgi.FieldStorage(keep_blank_values=True)

# Establish connection to the database
db = connect_to_iap_db()
cursor = db.cursor()

print "Content-type: text/html"
print

redirect_to("cm-articles.php")

# Add the article to the articles table.
article = iapArticle(cursor, debug=True)
article.add_record(title=form.getvalue("title"),
                   subtitle=form.getvalue("subtitle"),
                   topic=form.getvalue("topic"))

# Add the article to the resources table.
resource_article = Resource(cursor, debug=True)
resource_article.add_resource("Article")

article.link_to_resource(resource_article)

with open('../resources/' + article.id + '.php', 'wb') as fb:
    fb.write(form["file"].file.read())

db.commit()
Beispiel #2
0
import cgi
form = cgi.FieldStorage(keep_blank_values=True)

# Establish connection to the database
db = connect_to_iap_db()
cursor = db.cursor()

print "Content-type: text/html"
print

redirect_to("cm-images.php")

# Add the image to the resources table.
resource_image = Resource(cursor)
resource_image.debug = True
resource_image.add_resource("Image")

# Add a file extension resource.
resource_extension = Resource(cursor)
resource_extension.debug = True
resource_extension.add_resource("String", "Extension", form["extension"].value)
resource_extension.link_to_parent(resource_image)

# Add a title resource.
resource_title = Resource(cursor)
resource_title.debug = True
resource_title.add_resource("String", "Title", form["title"].value)
resource_title.link_to_parent(resource_image)

# Add a location resource.
resource_location = Resource(cursor)