allura.model.artifact
¶
- class allura.model.artifact.Artifact¶
Base class for anything you want to keep track of.
Automatically indexed into Solr (see index() method)
Has a discussion thread that can have files attached to it
- Variables:
mod_date – last-modified
datetime
acl – dict of permission name => [roles]
labels – list of plain old strings
- __json__(posts_limit=None, is_export=False, user=None)¶
Return a JSON-encodable
dict
representation of this Artifact.
- classmethod artifacts_labeled_with(label, app_config)¶
Return all artifacts of type
cls
that have the labellabel
and are in the tool denoted byapp_config
.- Parameters:
label – str
app_config –
allura.model.project.AppConfig
instance
- attach(filename, fp, **kw)¶
Attach a file to this Artifact.
- Parameters:
filename – file name
fp – a file-like object (implements
read()
)kw – passed through to Attachment class constructor
- delete()¶
Delete this Artifact.
- property email_domain¶
Return domain part of email address for this Artifact
- email_link(subject='artifact')¶
Return a ‘mailto’ URL for this Artifact, with optional subject.
- get_discussion_thread(data=None)¶
Return the discussion thread and parent_id for this artifact.
- Returns:
(
allura.model.discuss.Thread
, parent_thread_id (int))
- index()¶
Return a
dict
representation of this object suitable for search indexing.Subclasses should implement this, providing a dictionary of solr_field => value. These fields & values will be stored by Solr. Subclasses should call the super().index() and then extend it with more fields.
You probably want to override at least title and text to have meaningful search results and email senders.
You can take advantage of Solr’s dynamic field typing by adding a type suffix to your field names, e.g.:
_s (string) (not analyzed) _t (text) (analyzed) _b (bool) _i (int) _f (float) _dt (datetime)
- classmethod is_limit_exceeded(app_config, user=None, count_by_user=None)¶
Returns True if any of artifact creation rate limits are exceeded, False otherwise
- link_text()¶
Return the link text to use when a shortlink to this artifact is expanded into an <a></a> tag.
By default this method returns
type_s
+shorthand_id()
. Subclasses should override this method to provide more descriptive link text.
- message_id()¶
Persistent, email-friendly (Message-ID header) id of this artifact
- parent_security_context()¶
Return the
allura.model.project.AppConfig
instance for this Artifact.ACL processing for this Artifact continues at the AppConfig object. This lets AppConfigs provide a ‘default’ ACL for all artifacts in the tool.
- primary()¶
If an artifact is a “secondary” artifact (discussion of a ticket, for instance), return the artifact that is the “primary”.
- property project¶
Return the
allura.model.project.Project
instance to which this Artifact belongs.
- property project_id¶
Return the
_id
of theallura.model.project.Project
instance to which this Artifact belongs.
Return all Artifacts that are related to this one.
- shorthand_id()¶
How to refer to this artifact within the app instance context.
For a wiki page, it might be the title. For a ticket, it might be the ticket number. For a discussion, it might be the message ID. Generally this should have a strong correlation to the URL.
- subscribe(user=None, topic=None, type='direct', n=1, unit='day')¶
Subscribe
user
to theallura.model.notification.Mailbox
for this Artifact.- Parameters:
user –
allura.model.auth.User
If
user
is None,c.user
will be subscribed.
- unsubscribe(user=None)¶
Unsubscribe
user
from theallura.model.notification.Mailbox
for this Artifact.- Parameters:
user –
allura.model.auth.User
If
user
is None,c.user
will be unsubscribed.
- url()¶
Return the URL for this Artifact.
Subclasses must implement this.
- class allura.model.artifact.Snapshot¶
A snapshot of an
Artifact
, used inVersionedArtifact
- clear_user_data()¶
Redact author data for a given user
- index()¶
Return a
dict
representation of this object suitable for search indexing.Subclasses should implement this, providing a dictionary of solr_field => value. These fields & values will be stored by Solr. Subclasses should call the super().index() and then extend it with more fields.
You probably want to override at least title and text to have meaningful search results and email senders.
You can take advantage of Solr’s dynamic field typing by adding a type suffix to your field names, e.g.:
_s (string) (not analyzed) _t (text) (analyzed) _b (bool) _i (int) _f (float) _dt (datetime)
- shorthand_id()¶
How to refer to this artifact within the app instance context.
For a wiki page, it might be the title. For a ticket, it might be the ticket number. For a discussion, it might be the message ID. Generally this should have a strong correlation to the URL.
- class allura.model.artifact.VersionedArtifact¶
An
Artifact
that has versions. Associated data like attachments and discussion thread are not versioned.- commit(update_stats=True)¶
Save off a snapshot of the artifact and increment the version #
- delete()¶
Delete this Artifact.
- classmethod is_limit_exceeded(*args, **kwargs)¶
Returns True if any of artifact creation rate limits are exceeded, False otherwise
- class allura.model.artifact.Message¶
A message
- Variables:
_id – an email friendly (e.g. message-id) string id
slug – slash-delimeted random identifier. Slashes useful for threaded searching and ordering
full_slug – string of slash-delimited “timestamp:slug” components. Useful for sorting by timstamp
- index()¶
Return a
dict
representation of this object suitable for search indexing.Subclasses should implement this, providing a dictionary of solr_field => value. These fields & values will be stored by Solr. Subclasses should call the super().index() and then extend it with more fields.
You probably want to override at least title and text to have meaningful search results and email senders.
You can take advantage of Solr’s dynamic field typing by adding a type suffix to your field names, e.g.:
_s (string) (not analyzed) _t (text) (analyzed) _b (bool) _i (int) _f (float) _dt (datetime)
- shorthand_id()¶
How to refer to this artifact within the app instance context.
For a wiki page, it might be the title. For a ticket, it might be the ticket number. For a discussion, it might be the message ID. Generally this should have a strong correlation to the URL.
- class allura.model.artifact.Feed¶
Used to generate rss/atom feeds. This does not need to be extended; all feed items go into the same collection
- clear_user_data()¶
Redact author data
- classmethod feed(q, feed_type, title, link, description, since=None, until=None, page=None, limit=None)¶
Produces feedgenerator Feed
- classmethod post(artifact, title=None, description=None, author=None, author_link=None, author_name=None, pubdate=None, link=None, **kw)¶
Create a Feed item. Returns the item. But if anon doesn’t have read access, create does not happen and None is returned.
- class allura.model.artifact.VotableArtifact¶
Voting support for the Artifact. Use as a mixin.
- user_voted(user)¶
Check that user voted for this artifact.
Return: 1 if user voted up -1 if user voted down 0 if user doesn’t vote
- class allura.model.artifact.MovedArtifact¶